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 GameReport from "../../../../FrameWork/Report/ZyZyReport"; 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 JiYiZhongDeLaoJiaConfig from "./JiYiZhongDeLaoJiaConfig"; const { ccclass, property } = cc._decorator; @ccclass export default class JiYiZhongDeLaoJia extends WordGameBaseComponent { @property(cc.Node) chooseLayer: cc.Node = null; @property(cc.Node) chooseContent: cc.Node = null; @property([cc.Node]) NodeListA: cc.Node[] = []; @property([cc.Node]) NodeListB: cc.Node[] = []; //当前层级下标 curLayerIndex = 0; //当前进度 curSchedule: number = 0; correctTimes: number = 0; //文本配置 titleArrayConfig: string[] = []; duihuaArrayConfig: any[] = []; chooseListConfig: any = null; start() { super.start(); DaDianScript.userEnterDaDian(); this.openTouchEvent(this.node.getChildByName('bg')); Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/JiYiZhongDeLaoJiaConfig',(assest)=>{ this.jsonData = assest.json this.initParameters(); this.initComponent(); }) Common5.playMusicCustom('jiyizhongdelaojia', 'sound/背景音'); } //初始化参数 initParameters() { this.curLayerIndex = 0; this.curSchedule = 0; this.correctTimes = 0; this.titleArrayConfig = this.jsonData.titleArray //JiYiZhongDeLaoJiaConfig.getInstance().getGameConfig('titleArray') as string[]; this.duihuaArrayConfig = this.jsonData.duihuaArray //JiYiZhongDeLaoJiaConfig.getInstance().getGameConfig('duihuaArray') as any[]; this.chooseListConfig = this.jsonData.chooseList //JiYiZhongDeLaoJiaConfig.getInstance().getGameConfig('chooseList'); Common.Type = 0 Common.subLevel = this.curLayerIndex; Common.GameSubTipConfigs = this.jsonData.tipsArray //JiYiZhongDeLaoJiaConfig.getInstance().getGameConfig('tipsArray'); Common.GameSubAnswerConfigs = this.jsonData.answersArray //JiYiZhongDeLaoJiaConfig.getInstance().getGameConfig('answersArray'); EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => { this.normalTouchCallback(data_.targetNode); }, this); EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => { this.endGameView(0); }, this); } //初始化组件 initComponent() { let title = this.titleArrayConfig[0]; let lab = this.node.getChildByName("标题").getChildByName("lab"); lab.getComponent(cc.Label).string = title; Game.ins.setGameTitle(title) for (let index = 0; index < this.chooseContent.children.length; index++) { let icon = this.chooseContent.children[index].getChildByName('icon'); let callbacks = CccGame.onNodeTouchMoreClickEvent(icon, false, 1, { touchIndex: index }); callbacks.setCompleteListener((data_) => { this.nodeTouchClickCallback(data_.targetNode); }); } this.chooseLayer.active = false; this.showDuiHua(this.duihuaArrayConfig[0], () => { this.refreshSchedule(); }); } //刷新进度 refreshSchedule() { let chooseInfo = this.chooseListConfig[this.curSchedule]; this.showDuiHua(chooseInfo.chooseLog, () => { for (let index = 0; index < chooseInfo.chooseIconList.length; index++) { const element = chooseInfo.chooseIconList[index]; let icon = this.chooseContent.children[index].getChildByName('icon'); Common5.getSpriteFrameFromBundle('jiyizhongdelaojia', element.url, icon.getComponent(cc.Sprite)); } this.chooseLayer.active = true; }); } nodeTouchClickCallback(targetNode: cc.Node) { console.log("+++++++++++++++++++++>" + targetNode.name); this.chooseLayer.active = false; let chooseIcon = this.chooseListConfig[this.curSchedule].chooseIconList[targetNode['touchIndex']]; GameReport.BtnsReport(chooseIcon.name, Common5.selectGameInfo.titleUrl); console.log("[GameReport]++++++++++++++++++++++>" + chooseIcon.name); let showNode: cc.Node = null; if (chooseIcon.result) { showNode = this.NodeListA[this.curSchedule]; this.correctTimes++; } else { showNode = this.NodeListB[this.curSchedule]; } cc.tween(showNode) .set({ active: true, opacity: 0 }) .to(1, { opacity: 255 }) .delay(1) .call(() => { this.curSchedule++; if (this.curSchedule == this.chooseListConfig.length) { if (this.correctTimes >= this.chooseListConfig.length) { this.node.getChildByName('layerNode').getChildByName('operate').active = true; this.showDuiHua(this.duihuaArrayConfig[2]); } else { this.showDuiHua(this.duihuaArrayConfig[1], () => { this.endGameView(0); }) } } else { this.refreshSchedule(); } }) .start(); } //触摸回调 normalTouchCallback(targetNode) { console.log("+++++++++++++++++++++>" + targetNode.name); switch (targetNode.name) { case '照片': this.showDuiHua(this.duihuaArrayConfig[3], () => { this.endGameView(1); }); break; default: break; } } //显示对话 showDuiHua(curLog, func?) { console.log("curLog==", curLog); if (curLog.effectUrl) { Common5.playEffectCustom("jiyizhongdelaojia", curLog.effectUrl); } let string_ = curLog.str; let qiPaoPos_ = curLog.qiPaoPos; let delayTime_ = curLog.delayTime || 3; let node = this.node.getChildByName('layerNode'); 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_); } //关闭对话框 closeDuiHua(qiPaoPos_) { if (qiPaoPos_ != -1) { let node = this.node.getChildByName("layerNode"); let qiPao = node.getChildByName("qiPao").getChildByName("qiPao_" + qiPaoPos_); qiPao.stopAllActions(); qiPao.active = false; } else { let logPrefab = this.node.getChildByName('logPrefab'); let duihua = logPrefab.getChildByName('duihua'); duihua.stopAllActions(); duihua.active = false; } } //结束视图 endGameView(touchIndex) { this.node.getChildByName("mask").active = true; Game.ins.stopTime(); if (touchIndex == 0) { this.scheduleOnce(() => { Game.ins.showFail(); }, 3); } else { this.scheduleOnce(() => { 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; } onClick(event) { let target = event.target as cc.Node; console.log("+++++++++++++++++++++>" + target.name); Common5.playEffect("点击音效"); switch (target.name) { case "时钟": break; default: break; } } //update(dt) { } }