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 HeadNodeList from "../../../WordGame/gameComScript/HeadNodeList"; import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript"; // import YiChangWuHuiConfig from "./YiChangWuHuiConfig"; const { ccclass, property } = cc._decorator; @ccclass export default class ZhongYuanGuiJiaScript 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[] = []; //当前层级下标 curLayerIndex = 0; //当前进度 curSchedule = 0; yingziNum = 0; chadianNum = 0; //文本配置 titleArrayConfig: string[] = []; conclusionArray: any[] = []; duihuaArrayConfig: any[] = []; renyingConfig: any = null; chadianListConfig: any = null; yingziTargetArray: any = null; //计时 Timer = 0; start() { super.start(); DaDianScript.userEnterDaDian(); this.openTouchEvent(this.node.getChildByName('bg')); // this.initParameters(); // this.initComponent(); Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/YiChangWuHuiConfig',(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.yingziTargetArray = [this.yingziTarget1, this.yingziTarget2, this.yingziTarget3, this.yingziTarget4]; this.titleArrayConfig = this.jsonData.titleArray//YiChangWuHuiConfig.getInstance().getGameConfig('titleArray') as string[]; this.conclusionArray = this.jsonData.conclusionArray//YiChangWuHuiConfig.getInstance().getGameConfig('conclusionArray') as any[]; this.duihuaArrayConfig = this.jsonData.duihuaArray//YiChangWuHuiConfig.getInstance().getGameConfig('duihuaArray') as any[]; this.renyingConfig = this.jsonData.renying//YiChangWuHuiConfig.getInstance().getGameConfig('renying'); this.chadianListConfig = this.jsonData.chadianList//YiChangWuHuiConfig.getInstance().getGameConfig('chadianList'); Common.Type = this.curLayerIndex; Common.subLevel = this.curLayerIndex; Common.GameSubTipConfigs = this.jsonData.tipsArray//YiChangWuHuiConfig.getInstance().getGameConfig('tipsArray'); Common.GameSubAnswerConfigs = this.jsonData.answersArray//YiChangWuHuiConfig.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); } 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) 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[2], () => { this.maskNode.active = false; }); break; case 1: this.maskNode.active = true; this.showQiPao(this.duihuaArrayConfig[1], () => { this.maskNode.active = false; }); break; default: break; } } refreshConclusion() { if (this.curLayerIndex == 1 || this.curLayerIndex == 3) { this.nextLayer(); 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("yichangwuhui", conclusion.effectUrl); } this.nextLayer(); }) .delay(2) .set({ active: false, opacity: 0 }) .start(); this.curSchedule = 2; } nextLayer() { this.curLayerIndex++; Common.subLevel = this.curLayerIndex; Game.ins.updateTishiBtn() if (this.curLayerIndex > 3) { this.curLayerIndex = 3; Common.subLevel = this.curLayerIndex; Game.ins.showSuccess(); } 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; } }; } } 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 0: this.scheduleOnce(() => { this.maskNode.active = true; this.showQiPao(this.duihuaArrayConfig[0], () => { this.maskNode.active = false; this.refreshConclusion(); }); }, 3); break; case 2: this.scheduleOnce(() => { this.maskNode.active = true; this.showQiPao(this.duihuaArrayConfig[3], () => { this.maskNode.active = false; this.refreshConclusion(); }); }, 3); break; default: this.scheduleOnce(() => { this.refreshConclusion(); }, 3); break; } } } } showQiPao(curLog, func?) { console.log("curLog==", curLog) if (!curLog) { console.log("xxxxxx") return; } if (curLog.effectUrl && curLog.effectUrl.length > 0) { Common5.playEffectCustom("yichangwuhui", 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(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); } } } //失败展示 // 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) { } }