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.
584 lines
22 KiB
584 lines
22 KiB
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 CccGame from "../../../WordGame/gameComScript/CccGame/CccGame";
|
|
import ChaDianListScript from "../../../WordGame/gameComScript/ChaDianListScript";
|
|
import ChooseBtnLayer from "../../../WordGame/gameComScript/ChooseBtnLayer";
|
|
import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript";
|
|
// import ShengWuShiYanShiConfig from "./ShengWuShiYanShiConfig";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class ShengWuShiYanShi extends WordGameBaseComponent {
|
|
|
|
@property(cc.Node)
|
|
layerNode: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
chooseLayer: cc.Node = null;
|
|
|
|
//当前层级下标
|
|
curLayerIndex = 0;
|
|
//当前进度
|
|
curSchedule = 0;
|
|
chadianNum = 0;
|
|
chooseIndex: number = -1;
|
|
chadianIndex: number = 0;
|
|
|
|
//文本配置
|
|
titleArrayConfig: string[] = [];
|
|
duihuaArrayConfig: any[] = [];
|
|
chadianListConfig: any = null;
|
|
chooseArrayConfig: any = null;
|
|
zombieLogConfig: any = null;
|
|
|
|
|
|
|
|
start() {
|
|
super.start();
|
|
DaDianScript.userEnterDaDian();
|
|
this.openTouchEvent(this.node.getChildByName('bg'));
|
|
// this.initParameters();
|
|
// this.initComponent();
|
|
|
|
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/ShengWuShiYanShiConfig',(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.chooseIndex = -1;
|
|
this.chadianIndex = 0;
|
|
this.titleArrayConfig = this.jsonData.titleArray//ShengWuShiYanShiConfig.getInstance().getGameConfig('titleArray') as string[];
|
|
this.duihuaArrayConfig = this.jsonData.duihuaArray//ShengWuShiYanShiConfig.getInstance().getGameConfig('duihuaArray') as any[];
|
|
this.chadianListConfig = this.jsonData.chadianList//ShengWuShiYanShiConfig.getInstance().getGameConfig('chadianList');
|
|
this.chooseArrayConfig = this.jsonData.chooseArray//ShengWuShiYanShiConfig.getInstance().getGameConfig('chooseArray');
|
|
this.zombieLogConfig = this.jsonData.zombieLog//ShengWuShiYanShiConfig.getInstance().getGameConfig('zombieLog');
|
|
Common.Type = this.curLayerIndex;
|
|
Common.subLevel = this.curLayerIndex;
|
|
Common.GameSubTipConfigs = this.jsonData.tipsArray//ShengWuShiYanShiConfig.getInstance().getGameConfig('tipsArray');
|
|
Common.GameSubAnswerConfigs = this.jsonData.answersArray//ShengWuShiYanShiConfig.getInstance().getGameConfig('answersArray');
|
|
}
|
|
|
|
initComponent() {
|
|
for (const node of this.layerNode) {
|
|
node.active = false;
|
|
}
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.touchChaDianCheck, (data_) => {
|
|
this.gameChaDianStep(data_.touchIndex);
|
|
}, this);
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => {
|
|
this.normalTouchCallback(data_.targetNode);
|
|
}, this);
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => {
|
|
this.normalTouchCallback(data_.targetNode);
|
|
}, this);
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.chooseResult, (data_) => {
|
|
this.chooseResultCallback(data_.touchIndex);
|
|
}, this);
|
|
|
|
// EventMgr.onEvent_custom(ryw_Event.WordGameRevive, () => {
|
|
// this.wordGameReviveCallback();
|
|
// }, this);
|
|
}
|
|
|
|
refreshLayer() {
|
|
let node = this.layerNode[this.curLayerIndex];
|
|
node.active = true;
|
|
|
|
let title = this.titleArrayConfig[this.curLayerIndex];
|
|
let lab = this.node.getChildByName("标题").getChildByName("lab");
|
|
lab.getComponent(cc.Label).string = title;
|
|
|
|
|
|
Game.ins.setGameTitle(title)
|
|
|
|
switch (this.curLayerIndex) {
|
|
case 0:
|
|
Common5.playMusicCustom("shengwushiyanshi", "sound/场景一");
|
|
this.showDuiHua(this.duihuaArrayConfig[0], () => {
|
|
cc.tween(node.getChildByName('背景1'))
|
|
.to(0.5, { opacity: 0 })
|
|
.call(() => {
|
|
cc.tween(node.getChildByName('背景2'))
|
|
.set({ active: true, opacity: 0 })
|
|
.to(0.5, { opacity: 255 })
|
|
.call(() => {
|
|
this.showDuiHua(this.duihuaArrayConfig[1], () => {
|
|
this.refreshChadian(0);
|
|
});
|
|
})
|
|
.start();
|
|
})
|
|
.start();
|
|
});
|
|
break;
|
|
case 1:
|
|
Common5.playMusicCustom("shengwushiyanshi", "sound/场景二三");
|
|
this.node.getChildByName("mask").active = true;
|
|
this.showDuiHua(this.duihuaArrayConfig[3], () => {
|
|
this.showDuiHua(this.duihuaArrayConfig[4], () => {
|
|
this.node.getChildByName("mask").active = false;
|
|
});
|
|
});
|
|
break;
|
|
case 2:
|
|
this.node.getChildByName("mask").active = true;
|
|
this.showDuiHua(this.duihuaArrayConfig[7], () => {
|
|
this.node.getChildByName("mask").active = false;
|
|
this.refreshChadian(1);
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
refreshChadian(chadianIndex: number) {
|
|
let node = this.layerNode[this.curLayerIndex];
|
|
let chadianIconList = node.getChildByName('chadianIconList');
|
|
let chadianTouchList = node.getChildByName('chadianTouchList');
|
|
chadianIconList.active = true;
|
|
chadianTouchList.active = true;
|
|
|
|
this.chadianIndex = chadianIndex;
|
|
let config = this.chadianListConfig[chadianIndex];
|
|
if (config) {
|
|
let chadianIconList = node.getChildByName('chadianIconList');
|
|
let scr: ChaDianListScript = chadianIconList.getComponent('ChaDianListScript');
|
|
scr.setChaDianData(config.chadianIconList);
|
|
}
|
|
|
|
this.curSchedule = 0;
|
|
}
|
|
|
|
refreshChadian2(chadianIndex: number) {
|
|
let node = this.layerNode[this.curLayerIndex];
|
|
let chadianIconList = node.getChildByName('chadianIconList2');
|
|
let chadianTouchList = node.getChildByName('chadianTouchList2');
|
|
chadianIconList.active = true;
|
|
chadianTouchList.active = true;
|
|
|
|
Common.GameSubTipConfigs = this.jsonData.tipsArray2//ShengWuShiYanShiConfig.getInstance().getGameConfig('tipsArray2');
|
|
this.chadianIndex = chadianIndex;
|
|
let config = this.chadianListConfig[chadianIndex];
|
|
if (config) {
|
|
let chadianIconList = node.getChildByName('chadianIconList2');
|
|
let scr: ChaDianListScript = chadianIconList.getComponent('ChaDianListScript');
|
|
scr.setChaDianData(config.chadianIconList);
|
|
}
|
|
|
|
this.curSchedule = 0;
|
|
}
|
|
|
|
refreshConclusion() {
|
|
let node = this.layerNode[this.curLayerIndex];
|
|
let chadianIconList = node.getChildByName('chadianIconList');
|
|
let chadianTouchList = node.getChildByName('chadianTouchList');
|
|
chadianIconList.active = false;
|
|
chadianTouchList.active = false;
|
|
|
|
switch (this.curLayerIndex) {
|
|
case 0:
|
|
this.showDuiHua(this.duihuaArrayConfig[2], () => {
|
|
this.nextLayer();
|
|
});
|
|
break;
|
|
case 1:
|
|
cc.tween(node.getChildByName('背景1'))
|
|
.to(0.5, { opacity: 0 })
|
|
.call(() => {
|
|
cc.tween(node.getChildByName('背景2'))
|
|
.set({ active: true, opacity: 0 })
|
|
.to(0.5, { opacity: 255 })
|
|
.call(() => {
|
|
this.showDuiHua(this.duihuaArrayConfig[5], () => {
|
|
this.showDuiHua(this.duihuaArrayConfig[6], () => {
|
|
this.nextLayer();
|
|
});
|
|
});
|
|
})
|
|
.start();
|
|
})
|
|
.start();
|
|
break;
|
|
case 2:
|
|
if (this.chadianIndex == 1) {
|
|
node.getChildByName('背景').getChildByName('开门').active = true;
|
|
cc.tween(node.getChildByName('背景').getChildByName('角色'))
|
|
.delay(1)
|
|
.set({ active: true, opacity: 0 })
|
|
.to(1, { opacity: 255 })
|
|
.call(() => {
|
|
this.showDuiHua(this.duihuaArrayConfig[8], () => {
|
|
this.refreshChadian2(2);
|
|
});
|
|
})
|
|
.start();
|
|
} else if (this.chadianIndex == 2) {
|
|
let chadianIconList = node.getChildByName('chadianIconList2');
|
|
let chadianTouchList = node.getChildByName('chadianTouchList2');
|
|
chadianIconList.active = false;
|
|
chadianTouchList.active = false;
|
|
this.showDuiHua(this.duihuaArrayConfig[9], () => {
|
|
this.showChooseLayer(0);
|
|
node.getChildByName('operate').active = true;
|
|
});
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
this.curSchedule = 1;
|
|
}
|
|
|
|
gameChaDianStep(touchIndex) {
|
|
let config = this.chadianListConfig[this.chadianIndex];
|
|
let chadianLog = config.chadianLog;
|
|
|
|
this.showDuiHua(chadianLog[touchIndex]);
|
|
console.log(this.chadianNum, ' this.chadianNum++=');
|
|
|
|
if (this.curSchedule == 0) {
|
|
this.chadianNum++;
|
|
if (this.chadianNum == chadianLog.length) {
|
|
this.chadianNum = 0;
|
|
this.scheduleOnce(() => {
|
|
this.refreshConclusion();
|
|
}, 3);
|
|
}
|
|
}
|
|
}
|
|
|
|
normalTouchCallback(targetNode) {
|
|
let node = this.layerNode[this.curLayerIndex];
|
|
switch (targetNode.name) {
|
|
case "领取任务":
|
|
cc.tween(this.node.getChildByName('layer0'))
|
|
.delay(1.0)
|
|
.to(1, { opacity: 0 })
|
|
.call(() => {
|
|
this.node.getChildByName('layer0').active = false;
|
|
this.refreshLayer();
|
|
})
|
|
.start();
|
|
break;
|
|
case "牛肉":
|
|
targetNode.checkNode.active = true;
|
|
this.showDuiHua(this.zombieLogConfig[0], () => {
|
|
cc.tween(targetNode.attrNodeArray[0])
|
|
.to(1, { opacity: 0 })
|
|
.set({ active: false })
|
|
.call(() => {
|
|
this.chadianNum++;
|
|
if (this.chadianNum == 6) {
|
|
this.chadianNum = 0;
|
|
this.scheduleOnce(() => {
|
|
this.refreshConclusion();
|
|
}, 3);
|
|
}
|
|
})
|
|
.start();
|
|
});
|
|
break;
|
|
case "砖":
|
|
targetNode.checkNode.active = true;
|
|
this.showDuiHua(this.zombieLogConfig[1], () => {
|
|
cc.tween(targetNode.attrNodeArray[0])
|
|
.to(1, { opacity: 0 })
|
|
.set({ active: false })
|
|
.call(() => {
|
|
this.chadianNum++;
|
|
if (this.chadianNum == 6) {
|
|
this.chadianNum = 0;
|
|
this.scheduleOnce(() => {
|
|
this.refreshConclusion();
|
|
}, 3);
|
|
}
|
|
})
|
|
.start();
|
|
});
|
|
break;
|
|
case "打火机":
|
|
targetNode.checkNode.active = true;
|
|
this.showDuiHua(this.zombieLogConfig[2], () => {
|
|
cc.tween(targetNode.attrNodeArray[0])
|
|
.to(1, { opacity: 0 })
|
|
.set({ active: false })
|
|
.call(() => {
|
|
this.chadianNum++;
|
|
if (this.chadianNum == 6) {
|
|
this.chadianNum = 0;
|
|
this.scheduleOnce(() => {
|
|
this.refreshConclusion();
|
|
}, 3);
|
|
}
|
|
})
|
|
.start();
|
|
});
|
|
break;
|
|
case "手电筒":
|
|
this.showDuiHua(this.zombieLogConfig[3], () => {
|
|
cc.tween(targetNode.attrNodeArray[0])
|
|
.to(1, { opacity: 0 })
|
|
.set({ active: false })
|
|
.call(() => {
|
|
this.chadianNum++;
|
|
if (this.chadianNum == 6) {
|
|
this.chadianNum = 0;
|
|
this.scheduleOnce(() => {
|
|
this.refreshConclusion();
|
|
}, 3);
|
|
}
|
|
})
|
|
.start();
|
|
});
|
|
break;
|
|
case "鞋子道具":
|
|
targetNode.checkNode.active = true;
|
|
this.showDuiHua(this.zombieLogConfig[4], () => {
|
|
cc.tween(targetNode.attrNodeArray[0])
|
|
.to(1, { opacity: 0 })
|
|
.set({ active: false })
|
|
.call(() => {
|
|
this.chadianNum++;
|
|
if (this.chadianNum == 6) {
|
|
this.chadianNum = 0;
|
|
this.scheduleOnce(() => {
|
|
this.refreshConclusion();
|
|
}, 3);
|
|
}
|
|
})
|
|
.start();
|
|
});
|
|
break;
|
|
case "符咒":
|
|
targetNode.checkNode.active = true;
|
|
this.showDuiHua(this.zombieLogConfig[5], () => {
|
|
cc.tween(targetNode.attrNodeArray[0])
|
|
.to(1, { opacity: 0 })
|
|
.set({ active: false })
|
|
.call(() => {
|
|
this.chadianNum++;
|
|
if (this.chadianNum == 6) {
|
|
this.chadianNum = 0;
|
|
this.scheduleOnce(() => {
|
|
this.refreshConclusion();
|
|
}, 3);
|
|
}
|
|
})
|
|
.start();
|
|
});
|
|
break;
|
|
case "针":
|
|
CccGame.playAnimation2(node.getChildByName('针管'), '针管', false, null, (spineNode) => {
|
|
this.chooseLayer.active = false;
|
|
spineNode.active = false;
|
|
this.node.getChildByName('mask').active = true;
|
|
cc.tween(node.getChildByName('背景').getChildByName('角色'))
|
|
.to(1, { opacity: 0 })
|
|
.set({ active: false })
|
|
.call(() => {
|
|
this.showDuiHua(this.duihuaArrayConfig[12], () => {
|
|
node.getChildByName('胜利').active = true;
|
|
Common5.playEffectCustom("shengwushiyanshi", 'sound/开门');
|
|
this.showDuiHua(this.duihuaArrayConfig[13], () => {
|
|
this.endGameView(1);
|
|
});
|
|
});
|
|
})
|
|
.start();
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
chooseResultCallback(touchIndex: number) {
|
|
this.node.getChildByName("mask").active = false;
|
|
let node = this.layerNode[this.curLayerIndex];
|
|
if (this.chooseIndex == 0) {
|
|
this.node.getChildByName('mask').active = true;
|
|
if (touchIndex == 0) {
|
|
this.showDuiHua(this.duihuaArrayConfig[10], () => {
|
|
CccGame.playAnimation2(node.getChildByName('场景3死亡'), 'animation');
|
|
this.scheduleOnce(() => {
|
|
this.wordGameReviveCallback();
|
|
}, 2);
|
|
});
|
|
} else {
|
|
this.showDuiHua(this.duihuaArrayConfig[11], () => {
|
|
CccGame.playAnimation2(node.getChildByName('场景3死亡'), 'animation');
|
|
this.scheduleOnce(() => {
|
|
this.wordGameReviveCallback();
|
|
}, 2);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
//重玩回调
|
|
wordGameReviveCallback() {
|
|
this.node.getChildByName("mask").active = false;
|
|
let node = this.layerNode[this.curLayerIndex];
|
|
switch (this.curLayerIndex) {
|
|
case 2:
|
|
cc.tween(node)
|
|
.set({ opacity: 0 })
|
|
.call(() => {
|
|
node.getChildByName('场景3死亡').active = false;
|
|
})
|
|
.delay(1)
|
|
.to(1, { opacity: 255 })
|
|
.call(() => {
|
|
this.showDuiHua(this.duihuaArrayConfig[9], () => {
|
|
this.showChooseLayer(0);
|
|
node.getChildByName('operate').active = true;
|
|
});
|
|
})
|
|
.start();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
//显示选项
|
|
showChooseLayer(chooseIndex: number) {
|
|
this.chooseLayer.active = true;
|
|
this.chooseIndex = chooseIndex;
|
|
Common.GameSubChooseArray = this.chooseArrayConfig[chooseIndex];
|
|
let script_: ChooseBtnLayer = this.chooseLayer.getComponent('ChooseBtnLayer');
|
|
script_.setChooseBtnView();
|
|
}
|
|
|
|
//显示对话
|
|
showDuiHua(curLog, func?) {
|
|
console.log("curLog==", curLog);
|
|
|
|
if (curLog.str == '') {
|
|
return;
|
|
}
|
|
|
|
if (curLog.effectUrl) {
|
|
Common5.playEffectCustom("shengwushiyanshi", curLog.effectUrl);
|
|
}
|
|
|
|
let string_ = curLog.str
|
|
let qiPaoPos_ = curLog.qiPaoPos
|
|
let delayTime_ = curLog.delayTime || 3;
|
|
|
|
let node = this.layerNode[this.curLayerIndex];
|
|
if (qiPaoPos_ != -1) {
|
|
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(delayTime_)
|
|
.call(() => {
|
|
qiPao.active = false
|
|
})
|
|
.start();
|
|
}
|
|
else {
|
|
let logPrefab = this.node.getChildByName('logPrefab')
|
|
let script_: logPrefabScript = logPrefab.getComponent('logPrefabScript')
|
|
script_.setDailogShow(string_, delayTime_)
|
|
}
|
|
|
|
this.scheduleOnce(() => {
|
|
if (func) {
|
|
func();
|
|
}
|
|
}, delayTime_);
|
|
}
|
|
|
|
nextLayer() {
|
|
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;
|
|
}
|
|
};
|
|
}
|
|
|
|
endGameView(touchIndex) {
|
|
this.node.getChildByName("mask").active = true;
|
|
Game.ins.stopTime();
|
|
this.scheduleOnce(() => {
|
|
|
|
// this.node.getChildByName("mask").active = true;
|
|
if (touchIndex == 0) {
|
|
Game.ins.showFail();;
|
|
} else {
|
|
Game.ins.showSuccess();;
|
|
}
|
|
}, 3)
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
//update(dt) { }
|
|
}
|
|
|