You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
478 lines
16 KiB
478 lines
16 KiB
4 weeks ago
|
import DaDianScript from "../../../FrameWork/Base/DaDianScript";
|
||
|
import WordGameBaseComponent from "../../../FrameWork/Base/WordGameBaseComptent";
|
||
|
import { ryw_Event } from "../../../FrameWork/Event/EventEnum";
|
||
|
import EventMgr from "../../../FrameWork/Event/EventMgr";
|
||
|
import Common from "../../../FrameWork/Util/Common";
|
||
|
import Common5 from "../../../Platform/th/Common5";
|
||
|
import Game from "../../../Scripts/Game";
|
||
|
import ChaDianListScript from "../../../WordGame/gameComScript/ChaDianListScript";
|
||
|
import ChooseBtnLayer from "../../../WordGame/gameComScript/ChooseBtnLayer";
|
||
|
import HeadNodeList from "../../../WordGame/gameComScript/HeadNodeList";
|
||
|
import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript";
|
||
|
// import ZhenAiZhiShangConfig from "./ZhenAiZhiShangConfig";
|
||
|
|
||
|
const { ccclass, property } = cc._decorator;
|
||
|
|
||
|
@ccclass
|
||
|
export default class ZhenAiZhiShangScript extends WordGameBaseComponent {
|
||
|
|
||
|
@property(cc.Node)
|
||
|
layerNode: cc.Node[] = [];
|
||
|
|
||
|
@property(cc.Node)
|
||
|
maskNode: cc.Node = null;
|
||
|
|
||
|
@property(cc.Node)
|
||
|
yingziTarget1: cc.Node[] = [];
|
||
|
@property(cc.Node)
|
||
|
yingziTarget2: cc.Node[] = [];
|
||
|
@property(cc.Node)
|
||
|
yingziTarget3: cc.Node[] = [];
|
||
|
@property(cc.Node)
|
||
|
yingziTarget4: cc.Node[] = [];
|
||
|
@property(cc.Node)
|
||
|
yingziTarget5: cc.Node[] = [];
|
||
|
|
||
|
|
||
|
//当前层级下标
|
||
|
curLayerIndex = 0;
|
||
|
//当前进度
|
||
|
curSchedule = 0;
|
||
|
yingziNum = 0;
|
||
|
chadianNum = 0;
|
||
|
endChoose = 0;
|
||
|
|
||
|
//文本配置
|
||
|
titleArrayConfig: string[] = [];
|
||
|
conclusionArray: any[] = [];
|
||
|
duihuaArrayConfig: any[] = [];
|
||
|
renyingConfig: any = null;
|
||
|
chadianListConfig: any = null;
|
||
|
yingziTargetArray: any = null;
|
||
|
chooseArrayName: string = null;
|
||
|
|
||
|
start() {
|
||
|
super.start();
|
||
|
DaDianScript.userEnterDaDian();
|
||
|
this.openTouchEvent(this.node.getChildByName('bg'));
|
||
|
// this.initParameters();
|
||
|
// this.initComponent();
|
||
|
|
||
|
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/ZhenAiZhiShangConfig',(assest)=>{
|
||
|
//this.jsonData = JSON.stringify(assest.json)
|
||
|
|
||
|
this.jsonData =assest.json
|
||
|
|
||
|
this.initParameters();
|
||
|
this.initComponent();
|
||
|
} )
|
||
|
|
||
|
}
|
||
|
|
||
|
//初始化参数
|
||
|
initParameters() {
|
||
|
this.curLayerIndex = 0;
|
||
|
this.curSchedule = 0;
|
||
|
this.chadianNum = 0;
|
||
|
this.yingziNum = 0;
|
||
|
this.endChoose = 0;
|
||
|
this.yingziTargetArray = [this.yingziTarget1, this.yingziTarget2, this.yingziTarget3, this.yingziTarget4, this.yingziTarget5];
|
||
|
this.titleArrayConfig = this.jsonData.titleArray//ZhenAiZhiShangConfig.getInstance().getGameConfig('titleArray') as string[];
|
||
|
this.conclusionArray = this.jsonData.conclusionArray//ZhenAiZhiShangConfig.getInstance().getGameConfig('conclusionArray') as any[];
|
||
|
this.duihuaArrayConfig = this.jsonData.duihuaArray//ZhenAiZhiShangConfig.getInstance().getGameConfig('duihuaArray') as any[];
|
||
|
this.renyingConfig = this.jsonData.renying//ZhenAiZhiShangConfig.getInstance().getGameConfig('renying');
|
||
|
this.chadianListConfig = this.jsonData.chadianList//ZhenAiZhiShangConfig.getInstance().getGameConfig('chadianList');
|
||
|
Common.Type = this.curLayerIndex;
|
||
|
Common.subLevel = this.curLayerIndex;
|
||
|
Common.GameSubTipConfigs = this.jsonData.tipsArray//ZhenAiZhiShangConfig.getInstance().getGameConfig('tipsArray');
|
||
|
Common.GameSubAnswerConfigs = this.jsonData.answersArray//ZhenAiZhiShangConfig.getInstance().getGameConfig('answersArray');
|
||
|
}
|
||
|
|
||
|
//初始化组件
|
||
|
initComponent() {
|
||
|
|
||
|
for (const node of this.layerNode) {
|
||
|
node.active = false;
|
||
|
}
|
||
|
|
||
|
this.refreshLayer();
|
||
|
|
||
|
EventMgr.onEvent_custom(ryw_Event.touchMoveCheck, () => {
|
||
|
this.gameYingziStep();
|
||
|
}, this);
|
||
|
|
||
|
EventMgr.onEvent_custom(ryw_Event.touchChaDianCheck, (data_) => {
|
||
|
this.gameChaDianStep(data_.touchIndex);
|
||
|
}, this);
|
||
|
|
||
|
EventMgr.onEvent_custom(ryw_Event.chooseResult, (data_) => {
|
||
|
this.chooseResultCallback(data_.touchIndex);
|
||
|
}, this);
|
||
|
}
|
||
|
|
||
|
|
||
|
//刷新场景
|
||
|
refreshLayer() {
|
||
|
let node = this.layerNode[this.curLayerIndex];
|
||
|
node.active = true;
|
||
|
this.changePosi(node)
|
||
|
let title = this.titleArrayConfig[this.curLayerIndex];
|
||
|
let lab = this.node.getChildByName("标题").getChildByName("lab");
|
||
|
lab.getComponent(cc.Label).string = title;
|
||
|
|
||
|
|
||
|
Game.ins.setGameTitle(title)
|
||
|
|
||
|
this.refreshYingzi();
|
||
|
|
||
|
}
|
||
|
|
||
|
//刷新影子
|
||
|
refreshYingzi() {
|
||
|
let node = this.layerNode[this.curLayerIndex];
|
||
|
let chadianTouchList = node.getChildByName('chadianTouchList')
|
||
|
chadianTouchList.active = false;
|
||
|
|
||
|
if (this.renyingConfig[this.curLayerIndex]) {
|
||
|
let config = this.renyingConfig[this.curLayerIndex]
|
||
|
let renyingList = node.getChildByName('renyingList');
|
||
|
let headNodeList = node.getChildByName('HeadNodeList');
|
||
|
renyingList.active = true;
|
||
|
headNodeList.active = true;
|
||
|
let scr: HeadNodeList = headNodeList.getComponent('HeadNodeList')
|
||
|
let targetRenyin = this.yingziTargetArray[this.curLayerIndex]
|
||
|
for (let i = 0; i < targetRenyin.length; i++) {
|
||
|
targetRenyin[i].active = false;
|
||
|
}
|
||
|
scr.setHeadData(config.HeadIconNodeList, renyingList, this.yingziTargetArray[this.curLayerIndex]);
|
||
|
}
|
||
|
|
||
|
this.curSchedule = 0;
|
||
|
}
|
||
|
|
||
|
//刷新茬点
|
||
|
refreshChadian() {
|
||
|
let node = this.layerNode[this.curLayerIndex];
|
||
|
let headNodeList = node.getChildByName('HeadNodeList');
|
||
|
let chadianIconList = node.getChildByName('chadianIconList');
|
||
|
let chadianTouchList = node.getChildByName('chadianTouchList');
|
||
|
headNodeList.active = false;
|
||
|
chadianIconList.active = true;
|
||
|
chadianTouchList.active = true;
|
||
|
|
||
|
let config = this.chadianListConfig[this.curLayerIndex];
|
||
|
if (config) {
|
||
|
let chadianIconList = node.getChildByName('chadianIconList');
|
||
|
let scr: ChaDianListScript = chadianIconList.getComponent('ChaDianListScript');
|
||
|
scr.setChaDianData(config.chadianIconList);
|
||
|
}
|
||
|
|
||
|
this.curSchedule = 1;
|
||
|
|
||
|
switch (this.curLayerIndex) {
|
||
|
case 0:
|
||
|
this.maskNode.active = true;
|
||
|
this.showQiPao(this.duihuaArrayConfig[0], () => {
|
||
|
this.showQiPao(this.duihuaArrayConfig[1], () => {
|
||
|
this.maskNode.active = false;
|
||
|
});
|
||
|
});
|
||
|
break;
|
||
|
case 4:
|
||
|
this.maskNode.active = true;
|
||
|
this.showQiPao(this.duihuaArrayConfig[7], () => {
|
||
|
this.showQiPao(this.duihuaArrayConfig[8], () => {
|
||
|
this.maskNode.active = false;
|
||
|
});
|
||
|
});
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//刷新结语
|
||
|
refreshConclusion() {
|
||
|
if (this.curLayerIndex == 3 || this.curLayerIndex == 4) {
|
||
|
Game.ins.showSuccess();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
let narratage = this.node.getChildByName("narratage");
|
||
|
narratage.getChildByName("bar").active = false;
|
||
|
cc.tween(narratage)
|
||
|
.set({ active: true, opacity: 0 })
|
||
|
.to(1, { opacity: 255 })
|
||
|
.call(() => {
|
||
|
let conclusion = this.conclusionArray[this.curLayerIndex];
|
||
|
narratage.getChildByName("bar").getChildByName("text").getComponent(cc.Label).string = conclusion.str;
|
||
|
narratage.getChildByName("bar").active = true;
|
||
|
if (conclusion.effectUrl) {
|
||
|
Common5.playEffectCustom("zhenaizhishang", conclusion.effectUrl);
|
||
|
}
|
||
|
this.nextLayer();
|
||
|
})
|
||
|
.delay(2)
|
||
|
.set({ active: false, opacity: 0 })
|
||
|
.start();
|
||
|
this.curSchedule = 2;
|
||
|
}
|
||
|
|
||
|
//影子步骤
|
||
|
gameYingziStep() {
|
||
|
if (this.curSchedule == 0) {
|
||
|
this.yingziNum++;
|
||
|
let targetRenyin = this.yingziTargetArray[this.curLayerIndex];
|
||
|
if (this.yingziNum == targetRenyin.length) {
|
||
|
this.yingziNum = 0;
|
||
|
this.refreshChadian();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//茬点步骤
|
||
|
gameChaDianStep(touchIndex) {
|
||
|
let config = this.chadianListConfig[this.curLayerIndex];
|
||
|
let chadianLog = config.chadianLog;
|
||
|
|
||
|
this.showQiPao(chadianLog[touchIndex]);
|
||
|
console.log(this.chadianNum, ' this.chadianNum++=');
|
||
|
|
||
|
if (this.curSchedule == 1) {
|
||
|
this.chadianNum++;
|
||
|
if (this.chadianNum == chadianLog.length) {
|
||
|
this.chadianNum = 0;
|
||
|
switch (this.curLayerIndex) {
|
||
|
case 1:
|
||
|
this.scheduleOnce(() => {
|
||
|
this.maskNode.active = true;
|
||
|
this.showQiPao(this.duihuaArrayConfig[2], () => {
|
||
|
this.showQiPao(this.duihuaArrayConfig[3], () => {
|
||
|
this.maskNode.active = false;
|
||
|
this.refreshConclusion();
|
||
|
});
|
||
|
});
|
||
|
}, 3);
|
||
|
break;
|
||
|
case 2:
|
||
|
this.scheduleOnce(() => {
|
||
|
this.maskNode.active = true;
|
||
|
this.showQiPao(this.duihuaArrayConfig[4], () => {
|
||
|
this.maskNode.active = false;
|
||
|
this.showChooseLayer("chooseArray");
|
||
|
});
|
||
|
}, 3);
|
||
|
break;
|
||
|
case 3:
|
||
|
this.scheduleOnce(() => {
|
||
|
this.maskNode.active = true;
|
||
|
this.showQiPao(this.duihuaArrayConfig[5], () => {
|
||
|
this.showQiPao(this.duihuaArrayConfig[6], () => {
|
||
|
this.maskNode.active = false;
|
||
|
this.refreshConclusion();
|
||
|
});
|
||
|
});
|
||
|
}, 3);
|
||
|
break;
|
||
|
default:
|
||
|
this.scheduleOnce(() => {
|
||
|
this.refreshConclusion();
|
||
|
}, 3);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//选择事件回调
|
||
|
chooseResultCallback(touchIndex: number) {
|
||
|
switch (this.chooseArrayName) {
|
||
|
case "chooseArray":
|
||
|
this.choose_chooseArray(touchIndex);
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//选择事件1
|
||
|
choose_chooseArray(touchIndex: number) {
|
||
|
this.endChoose = touchIndex;
|
||
|
if (touchIndex == 0) {
|
||
|
let popUpNode = this.node.getChildByName("popUpNode");
|
||
|
cc.tween(popUpNode)
|
||
|
.set({ active: true, opacity: 0 })
|
||
|
.to(1, { opacity: 255 })
|
||
|
.call(() => {
|
||
|
popUpNode.getChildByName("手机消息").active = true;
|
||
|
})
|
||
|
.delay(3)
|
||
|
.call(() => {
|
||
|
this.refreshConclusion();
|
||
|
})
|
||
|
.delay(1)
|
||
|
.set({ active: false, opacity: 0 })
|
||
|
.start();
|
||
|
} else {
|
||
|
this.scheduleOnce(() => {
|
||
|
this.refreshConclusion();
|
||
|
}, 2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//显示选项
|
||
|
showChooseLayer(chooseArrayName: string) {
|
||
|
let ChooseLayer = this.node.getChildByName('ChooseLayer');
|
||
|
ChooseLayer.active = true;
|
||
|
|
||
|
this.chooseArrayName = chooseArrayName;
|
||
|
Common.GameSubChooseArray = this.jsonData[chooseArrayName]//ZhenAiZhiShangConfig.getInstance().getGameConfig(chooseArrayName);
|
||
|
let script_: ChooseBtnLayer = ChooseLayer.getComponent('ChooseBtnLayer');
|
||
|
script_.setChooseBtnView();
|
||
|
}
|
||
|
|
||
|
//展示气泡
|
||
|
showQiPao(curLog, func?) {
|
||
|
|
||
|
console.log("curLog==", curLog)
|
||
|
if (!curLog) {
|
||
|
console.log("xxxxxx")
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (curLog.effectUrl && curLog.effectUrl.length > 0) {
|
||
|
Common5.playEffectCustom("zhenaizhishang", curLog.effectUrl);
|
||
|
}
|
||
|
|
||
|
let string_ = curLog.str
|
||
|
let qiPaoPos_ = curLog.qiPaoPos
|
||
|
|
||
|
|
||
|
if (qiPaoPos_ != -1) {
|
||
|
let node = this.layerNode[this.curLayerIndex];
|
||
|
let qiPao = node.getChildByName("qiPao").getChildByName("qiPao_" + qiPaoPos_);
|
||
|
qiPao.stopAllActions()
|
||
|
qiPao.getChildByName("str").getComponent(cc.Label).string = string_
|
||
|
qiPao.active = true
|
||
|
qiPao.scale = 0
|
||
|
cc.tween(qiPao)
|
||
|
.to(0.2, { scale: 1 })
|
||
|
.delay(3)
|
||
|
.call(() => {
|
||
|
qiPao.active = false;
|
||
|
if (func) {
|
||
|
func();
|
||
|
}
|
||
|
})
|
||
|
.start();
|
||
|
}
|
||
|
else {
|
||
|
let logPrefab = this.node.getChildByName('logPrefab')
|
||
|
let script_: logPrefabScript = logPrefab.getComponent('logPrefabScript')
|
||
|
script_.setDailogShow(string_)
|
||
|
if (func) {
|
||
|
this.scheduleOnce(func, 3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//转场
|
||
|
nextLayer() {
|
||
|
this.curLayerIndex++;
|
||
|
if (this.endChoose == 1) {
|
||
|
this.curLayerIndex++;
|
||
|
}
|
||
|
Common.subLevel = this.curLayerIndex;
|
||
|
Game.ins.updateTishiBtn()
|
||
|
for (let i = 0; i < this.layerNode.length; i++) {
|
||
|
if (this.layerNode[i].active) {
|
||
|
cc.tween(this.layerNode[i])
|
||
|
.delay(1.0)
|
||
|
.to(1, { opacity: 0 })
|
||
|
.call(() => {
|
||
|
this.layerNode[i].active = false;
|
||
|
this.refreshLayer();
|
||
|
})
|
||
|
.start();
|
||
|
} else {
|
||
|
this.layerNode[i].active = false;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
//失败展示
|
||
|
// failShow(curResultIndex, duihuaIndex = null, callFunc?: Function) {
|
||
|
// Common5.playEffect("人物跳脸");
|
||
|
// let node = this.resultLayer[curResultIndex]
|
||
|
// let renwuNode = node.getChildByName('renwuNode')
|
||
|
// renwuNode.scale = 0.01
|
||
|
// let zhuahengBg = node.getChildByName('zhuahengBg')
|
||
|
// node.active = true
|
||
|
// cc.tween(renwuNode)
|
||
|
// .to(0.3, { scale: 1 }, { easing: 'elasticOut' })
|
||
|
// .delay(1.0)
|
||
|
// .call(() => {
|
||
|
// if (zhuahengBg) {
|
||
|
// Common5.playEffect("跳脸抓痕");
|
||
|
// zhuahengBg.active = true
|
||
|
// let zhuhen = zhuahengBg.getChildByName('抓痕')
|
||
|
// zhuhen.getComponent(sp.Skeleton).setAnimation(0, 'animation', false)
|
||
|
// }
|
||
|
// if (duihuaIndex) {
|
||
|
// this.showQiPao(duihuaIndex);
|
||
|
// }
|
||
|
// if (callFunc) {
|
||
|
// callFunc()
|
||
|
// }
|
||
|
// this.scheduleOnce(() => {
|
||
|
// WordScene.ins.showFail();
|
||
|
// }, 2)
|
||
|
// })
|
||
|
// .start();
|
||
|
// }
|
||
|
|
||
|
openTouchEvent(node) {
|
||
|
node.on(cc.Node.EventType.TOUCH_START, this.touchStartNode, this)
|
||
|
node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveNode, this)
|
||
|
node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this)
|
||
|
node.on(cc.Node.EventType.TOUCH_END, this.touchEndNode, this)
|
||
|
}
|
||
|
|
||
|
closeTouchEvent(node: cc.Node) {
|
||
|
node.off(cc.Node.EventType.TOUCH_START, this.touchStartNode, this)
|
||
|
node.off(cc.Node.EventType.TOUCH_MOVE, this.touchMoveNode, this)
|
||
|
node.off(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this)
|
||
|
node.off(cc.Node.EventType.TOUCH_END, this.touchEndNode, this)
|
||
|
}
|
||
|
|
||
|
touchStartNode(event) {
|
||
|
let target = event.target;
|
||
|
console.log('touchStartNode');
|
||
|
}
|
||
|
|
||
|
touchMoveNode(event) {
|
||
|
|
||
|
}
|
||
|
|
||
|
touchEndNode(event) {
|
||
|
let target = event.target
|
||
|
let logPrefab = this.node.getChildByName('logPrefab')
|
||
|
logPrefab.getChildByName('duihua').active = false;
|
||
|
}
|
||
|
|
||
|
// onClick(event) {
|
||
|
// let buttonName = event.target.name;
|
||
|
// switch (buttonName) {
|
||
|
// case "kaimen":
|
||
|
// this.nextLayer();
|
||
|
// event.target.active = false;
|
||
|
// break;
|
||
|
|
||
|
// default:
|
||
|
// break;
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
//update(dt) { }
|
||
|
}
|