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.
371 lines
13 KiB
371 lines
13 KiB
3 months 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 MultipleChooseLayer from "../../../WordGame/gameComScript/MultipleChooseLayer";
|
||
|
import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript";
|
||
|
// import FeiXingWeiJiConfig from "./FeiXingWeiJiConfig";
|
||
|
const { ccclass, property } = cc._decorator;
|
||
|
|
||
|
@ccclass
|
||
|
export default class FeiXingWeiJiScript extends WordGameBaseComponent {
|
||
|
|
||
|
@property(cc.Node)
|
||
|
layerNode: cc.Node[] = [];
|
||
|
|
||
|
@property(cc.Node)
|
||
|
maskNode: cc.Node = null;
|
||
|
|
||
|
@property(cc.Node)
|
||
|
blackMaskNode: cc.Node = null;
|
||
|
|
||
|
@property(cc.Node)
|
||
|
doorNode: cc.Node = null;
|
||
|
|
||
|
@property(cc.Node)
|
||
|
multipleChooseLayer: cc.Node = null;
|
||
|
|
||
|
@property(cc.ProgressBar)
|
||
|
progressBar: cc.ProgressBar = null;
|
||
|
|
||
|
@property(cc.Label)
|
||
|
heightText: cc.Label = null;
|
||
|
|
||
|
@property(cc.Node)
|
||
|
background: cc.Node = null;
|
||
|
|
||
|
@property(cc.Node)
|
||
|
yunNode: cc.Node = null;
|
||
|
|
||
|
//当前层级下标
|
||
|
curLayerIndex = 0;
|
||
|
//当前进度
|
||
|
curSchedule = 0;
|
||
|
chadianNum = 0;
|
||
|
isEndTimer = false;
|
||
|
|
||
|
//文本配置
|
||
|
titleArrayConfig: string[] = [];
|
||
|
duihuaArrayConfig: any[] = [];
|
||
|
chadianListConfig: any = null;
|
||
|
preambleArrayConfig: any[] = [];
|
||
|
|
||
|
start() {
|
||
|
super.start();
|
||
|
DaDianScript.userEnterDaDian();
|
||
|
this.openTouchEvent(this.node.getChildByName('bg'));
|
||
|
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/FeiXingWeiJiConfig',(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.isEndTimer = false;
|
||
|
this.titleArrayConfig =this.jsonData.titleArray //FeiXingWeiJiConfig.getInstance().getGameConfig('titleArray') as string[];
|
||
|
this.duihuaArrayConfig = this.jsonData.duihuaArray //FeiXingWeiJiConfig.getInstance().getGameConfig('duihuaArray') as any[];
|
||
|
this.chadianListConfig = this.jsonData.chadianList //FeiXingWeiJiConfig.getInstance().getGameConfig('chadianList');
|
||
|
this.preambleArrayConfig =this.jsonData.preambleArray // FeiXingWeiJiConfig.getInstance().getGameConfig('preambleArray') as any[];
|
||
|
Common.Type = 0
|
||
|
Common.subLevel = this.curLayerIndex;
|
||
|
Common.GameSubTipConfigs = this.jsonData.tipsArray //FeiXingWeiJiConfig.getInstance().getGameConfig('tipsArray');
|
||
|
Common.GameSubAnswerConfigs =this.jsonData.answersArray // FeiXingWeiJiConfig.getInstance().getGameConfig('answersArray');
|
||
|
}
|
||
|
|
||
|
initComponent() {
|
||
|
for (const node of this.layerNode) {
|
||
|
node.active = false;
|
||
|
}
|
||
|
|
||
|
this.refreshLayer();
|
||
|
|
||
|
EventMgr.onEvent_custom(ryw_Event.touchChaDianCheck, (data_) => {
|
||
|
this.gameChaDianStep(data_.touchIndex);
|
||
|
}, this);
|
||
|
|
||
|
EventMgr.onEvent_custom(ryw_Event.chooseResult, (data_) => {
|
||
|
this.chooseResultCallback(data_.touchIndexs);
|
||
|
}, this);
|
||
|
|
||
|
EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => {
|
||
|
this.touchEndCheckCallback(data_.targetNode);
|
||
|
}, this);
|
||
|
}
|
||
|
|
||
|
refreshLayer() {
|
||
|
|
||
|
let node = this.layerNode[this.curLayerIndex];
|
||
|
node.active = true;
|
||
|
|
||
|
let title = this.titleArrayConfig[0];
|
||
|
let lab = this.node.getChildByName("标题").getChildByName("lab");
|
||
|
lab.getComponent(cc.Label).string = title;
|
||
|
Game.ins.setGameTitle(title)
|
||
|
if (this.curLayerIndex == 0) {
|
||
|
let curLog = this.preambleArrayConfig[0];
|
||
|
node.getChildByName("text").getComponent(cc.Label).string = curLog.str;
|
||
|
if (curLog.effectUrl && curLog.effectUrl.length > 0) {
|
||
|
Common5.playEffectCustom("feixingweiji", curLog.effectUrl);
|
||
|
}
|
||
|
|
||
|
this.scheduleOnce(() => {
|
||
|
this.nextLayer();
|
||
|
}, 2);
|
||
|
|
||
|
} else if (this.curLayerIndex == 1) {
|
||
|
this.refreshChadian();
|
||
|
|
||
|
} else if (this.curLayerIndex == 2) {
|
||
|
this.showQiPao(this.duihuaArrayConfig[4], () => {
|
||
|
|
||
|
|
||
|
this.scheduleOnce(()=>{
|
||
|
Game.ins.showSuccess();
|
||
|
},3.0)
|
||
|
});
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
refreshChadian() {
|
||
|
let node = this.layerNode[this.curLayerIndex];
|
||
|
let chadianIconList = node.getChildByName('chadianIconList');
|
||
|
let chadianTouchList = node.getChildByName('chadianTouchList');
|
||
|
chadianIconList.active = true;
|
||
|
chadianTouchList.active = true;
|
||
|
|
||
|
let config = this.chadianListConfig[0];
|
||
|
if (config) {
|
||
|
let chadianIconList = node.getChildByName('chadianIconList');
|
||
|
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;
|
||
|
|
||
|
this.showQiPao(this.duihuaArrayConfig[0], () => {
|
||
|
this.showQiPao(this.duihuaArrayConfig[5], () => {
|
||
|
let timer = 100;
|
||
|
this.doorNode.active = false;
|
||
|
this.multipleChooseLayer.active = true;
|
||
|
this.isEndTimer = false;
|
||
|
|
||
|
let chooseArray = this.jsonData.chooseArray//FeiXingWeiJiConfig.getInstance().getGameConfig("chooseArray");
|
||
|
let scr = this.multipleChooseLayer.getComponent(MultipleChooseLayer);
|
||
|
scr.setChooseBtnView(chooseArray.btnArray, chooseArray.chooseTitle);
|
||
|
this.yunNode.active = true;
|
||
|
node.getChildByName("suduxian").active = true;
|
||
|
|
||
|
this.schedule(() => {
|
||
|
if (!this.isEndTimer) {
|
||
|
timer--;
|
||
|
this.heightText.string = "高度" + Math.floor(50 + (timer * 19.5)) + "m";
|
||
|
this.progressBar.progress = timer / 100;
|
||
|
this.background.y++;
|
||
|
if (timer == 70) {
|
||
|
Common5.playEffectCustom("feixingweiji", "sound/来不及了,需要赶紧做出决定");
|
||
|
}
|
||
|
if (timer == 0) {
|
||
|
this.isEndTimer = true;
|
||
|
this.maskNode.active = true;
|
||
|
this.multipleChooseLayer.active = false;
|
||
|
this.yunNode["stop"]();
|
||
|
this.scheduleOnce(() => {
|
||
|
this.blackMaskNode.active = true;
|
||
|
Common5.playEffectCustom("feixingweiji", "sound/爆炸声");
|
||
|
}, 0.5);
|
||
|
this.scheduleOnce(() => {
|
||
|
Game.ins.showFail();
|
||
|
}, 3);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}, 0.1, 99, 0);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
this.curSchedule = 1;
|
||
|
}
|
||
|
|
||
|
nextLayer() {
|
||
|
this.curLayerIndex++;
|
||
|
//Common.subLevel = 0;
|
||
|
|
||
|
if (this.curLayerIndex > 5) {
|
||
|
// this.curLayerIndex = 3;
|
||
|
// Common.subLevel = this.curLayerIndex;
|
||
|
// WordScene.ins.showSuccess("success1");
|
||
|
}
|
||
|
else {
|
||
|
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;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
gameChaDianStep(touchIndex) {
|
||
|
let config = this.chadianListConfig[0];
|
||
|
let chadianLog = config.chadianLog;
|
||
|
|
||
|
this.showQiPao(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);
|
||
|
} else if (this.chadianNum == (chadianLog.length - 1)) {
|
||
|
let laoren = this.layerNode[this.curLayerIndex].getChildByName("laoren");
|
||
|
laoren.getChildByName("老太太1").active = false;
|
||
|
laoren.getChildByName("老太太2").active = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
chooseResultCallback(touchIndexs: Set<number>) {
|
||
|
this.isEndTimer = true;
|
||
|
this.maskNode.active = true;
|
||
|
this.yunNode["stop"]();
|
||
|
if (touchIndexs.size == 3) {
|
||
|
this.nextLayer();
|
||
|
} else {
|
||
|
if (touchIndexs.has(2)) {
|
||
|
this.showQiPao(this.duihuaArrayConfig[3], () => {
|
||
|
Game.ins.showFail();
|
||
|
});
|
||
|
} else if (touchIndexs.has(1)) {
|
||
|
this.showQiPao(this.duihuaArrayConfig[2], () => {
|
||
|
Game.ins.showFail();
|
||
|
});
|
||
|
} else if (touchIndexs.has(0)) {
|
||
|
this.showQiPao(this.duihuaArrayConfig[1], () => {
|
||
|
Game.ins.showFail();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
touchEndCheckCallback(targetNode) {
|
||
|
if (targetNode.name == "door") {
|
||
|
let ChooseLayer = this.node.getChildByName('GZChooseLayer2');
|
||
|
ChooseLayer.active = false;
|
||
|
|
||
|
this.maskNode.active = true;
|
||
|
targetNode.active = false;
|
||
|
this.showQiPao(this.duihuaArrayConfig[4], () => {
|
||
|
this.showQiPao(this.duihuaArrayConfig[5], () => {
|
||
|
this.node.getChildByName("tipsBtn").active = false;
|
||
|
this.nextLayer();
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
showQiPao(curLog, func?, delay = 3) {
|
||
|
|
||
|
console.log("curLog==", curLog)
|
||
|
if (!curLog) {
|
||
|
console.log("xxxxxx")
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (curLog.effectUrl && curLog.effectUrl.length > 0) {
|
||
|
Common5.playEffectCustom("feixingweiji", curLog.effectUrl);
|
||
|
}
|
||
|
|
||
|
let string_ = curLog.str
|
||
|
let qiPaoPos_ = curLog.qiPaoPos
|
||
|
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(delay)
|
||
|
.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, delay);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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) { }
|
||
|
}
|