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/WenZiRes/ui/Game"; import CccGame from "../../../WordGame/gameComScript/CccGame/CccGame"; import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript"; // import PoWuNvHaiConfig from "./PoWuNvHaiConfig"; const { ccclass, property } = cc._decorator; @ccclass export default class PoWuNvHai extends WordGameBaseComponent { @property(cc.Node) layerNode: cc.Node[] = []; @property(cc.Node) props: cc.Node = null; @property(cc.Node) checkNodeList: cc.Node = null; @property(cc.Node) moveParentNode: cc.Node = null; @property(cc.Node) hideNodeList: cc.Node[] = []; @property(cc.Node) showNodeList: cc.Node[] = []; @property(cc.Node) operateNodeList: cc.Node[] = []; //当前层级下标 curLayerIndex = 0; //当前进度 curSchedule: number = 0; //文本配置 titleArrayConfig: string[] = []; duihuaArrayConfig: any[] = []; chadianArrayConfig: any[] = []; answersIndexConfig: number[] = []; wrongAnswerConfig: string[] = []; isResult: boolean = false; start() { super.start(); DaDianScript.userEnterDaDian(); //this.openTouchEvent(this.node.getChildByName('bg')); Common5.stopMusic(); Common5.getJsonFromBundle(Common5.selectGameInfo.bundle, 'script/PoWuNvHaiConfig', (assest) => { this.jsonData = assest.json this.initParameters(); this.initComponent(); }) } //初始化参数 initParameters() { this.curLayerIndex = 0; this.curSchedule = 0; this.titleArrayConfig = this.jsonData.titleArray //PoWuNvHaiConfig.getInstance().getGameConfig('titleArray') as string[]; this.duihuaArrayConfig = this.jsonData.duihuaArray //PoWuNvHaiConfig.getInstance().getGameConfig('duihuaArray') as any[]; this.chadianArrayConfig = this.jsonData.chadianArray //PoWuNvHaiConfig.getInstance().getGameConfig('chadianArray'); this.answersIndexConfig = this.jsonData.answersIndex //PoWuNvHaiConfig.getInstance().getGameConfig('answersIndex'); this.wrongAnswerConfig = this.jsonData.wrongAnswer //PoWuNvHaiConfig.getInstance().getGameConfig('wrongAnswer'); Common.Type = 3; Common.subLevel = 0; Common.GameSubTipConfigs = this.jsonData.answersArray //PoWuNvHaiConfig.getInstance().getGameConfig('answersArray'); EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => { this.normalTouchCallback(data_.targetNode); }, this); EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => { this.normalTouchCallback(data_.targetNode); }, this); EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => { this.normalTouchCallback(data_.targetNode); }, this); EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => { this.endGameView(0); }, this); } //初始化组件 initComponent() { for (const node of this.layerNode) { node.active = false; } let node = this.layerNode[this.curLayerIndex]; node.active = true; Game.ins.setGameTitle(this.titleArrayConfig[0]); Common5.playMusicCustom(Common5.selectGameInfo.bundle, 'sound/窗户变后音效消失'); for (const iterator of this.props.children) { let callbacks = CccGame.onNodeTouchMoreCheckEvent(iterator, this.checkNodeList.children, null, this.moveParentNode); callbacks.setSuccessListener((data_) => { this.nodeCheckSuccessCallback(data_.targetNode); }); } // this.node.getChildByName("mask").active = true; // this.showDuiHua(this.duihuaArrayConfig[0], () => { // this.node.getChildByName("mask").active = false; // }); } //节点碰撞回调 nodeCheckSuccessCallback(targetNode) { let index = this.checkNodeList.children.indexOf(targetNode.checkNode); console.log("[checkNode]++++++++++++++++++++++>" + targetNode.checkNode.name, index); if (this.hideNodeList[index]) { this.hideNodeList[index].active = false; } if (this.showNodeList[index]) { this.showNodeList[index].active = true; } // if (index == 5 && !this['wrong1']) { // Common.SpeTip = this.wrongAnswerConfig[0] || ''; // } else { // this.unlockLevel(this.answersIndexConfig[index]); // } this.unlockLevel(this.answersIndexConfig[index]); let log = this.chadianArrayConfig[index].log; if (log && log[0]) { //this.node.getChildByName("mask").active = true; this.showDuiHua(log[0], () => { if (log[1]) { this.showDuiHua(log[1], () => { this.node.getChildByName("mask").active = false; this.determine(); }); } else { this.node.getChildByName("mask").active = false; this.determine(); } }); } else { this.determine(); } if (targetNode.checkNode.name == '破旧窗户') { Common5.stopMusic(); } } //触摸回调 normalTouchCallback(targetNode) { console.log("+++++++++++++++++++++>" + targetNode.name); switch (targetNode.name) { case '老鼠_': this['wrong1'] = true; break; default: break; } } determine() { this.curSchedule++; if (this.curSchedule == this.chadianArrayConfig.length) { this.scheduleOnce(() => { this.endGameView(1); }, 2); } // else if (this.curSchedule == this.chadianArrayConfig.length - 1) { // this.operateNodeList[0].active = true; // } } //显示对话 showDuiHua(curLog, func?) { console.log("curLog==", curLog); if (curLog.effectUrl) { Common5.playEffectCustom(Common5.selectGameInfo.bundle, 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_ cc.tween(qiPao) .set({ active: true, scale: 0 }) .to(0.2, { scale: 1 }) .delay(delayTime_) .set({ 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_); } //结束弹窗 endGameView(touchIndex) { this.node.getChildByName("mask").active = true; Game.ins.stopTime(); if (this.isResult) { return } this.isResult = true if (touchIndex == 0) { this.scheduleOnce(() => { Game.ins.showFail();; }, 2); } else { this.scheduleOnce(() => { Game.ins.showSuccess();; }, 2); } } //解锁提示 unlockLevel(sublevel) { Game.ins.tipUnlock(sublevel) } 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 target = event.target as cc.Node; console.log("+++++++++++++++++++++>" + target.name); Common5.playEffect("点击音效"); switch (target.name) { case "BtnAddTimes": default: break; } } //update(dt) { } }