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 BangXinLangJieQinConfig from "./BangXinLangJieQinConfig"; enum ActionType{ GuoMaLu, TaDiao, ZuanJiZuanDong, GuoQiao, FeiNiu, ZhiZhu, ChengYun, HuoJianPenSheQi, Gou, ChuZuChe, } const { ccclass, property } = cc._decorator; @ccclass export default class BangXinLangJieQin extends WordGameBaseComponent { @property(cc.Node) chuZuCheTouchArea1:cc.Node = null //文本配置 titleArrayConfig: string[] = []; duihuaArrayConfig: any[] = []; // duihuaArray_Ying: any[] = []; // duihuaArray_PingJu: any[] = []; // duihuaArray_Shu: any[] = []; //初始化节点 curFinishNum:number = 0 isAction:boolean = false isUseHouZi:boolean = false isUseTaDiao:boolean = false isUseZuanJiZuanDong:boolean = false isUseZuanJiZuanQiang:boolean = false isClickCunQianGuan:boolean = false isClickChuZuChe:boolean = false isNiuDaQi:boolean = false isNiuQiQiu:boolean = false checkAreaIndex:number = 0 start() { super.start(); DaDianScript.userEnterDaDian(); Common5.stopMusic() Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/BangXinLangJieQinConfig',(assest)=>{ //this.jsonData = JSON.stringify(assest.json) this.jsonData =assest.json this.initParameters(); this.initComponent(); this.initView() }) } //初始化参数 initParameters() { EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => { this.endGameView(0); }, this); // this.fireNodeInfoArray = []; this.titleArrayConfig = this.jsonData.titleArray//BangXinLangJieQinConfig.getInstance().getGameConfig('titleArray') as string[]; this.duihuaArrayConfig = this.jsonData.duihuaArray//BangXinLangJieQinConfig.getInstance().getGameConfig('duihuaArray') as any[]; // this.duihuaArray_Ying = BuYaoLangFeiConfig.getInstance().getGameConfig('duihuaArray_Ying') as any[]; // this.duihuaArray_PingJu = BuYaoLangFeiConfig.getInstance().getGameConfig('duihuaArray_PingJu') as any[]; // this.duihuaArray_Shu = BuYaoLangFeiConfig.getInstance().getGameConfig('duihuaArray_Shu') as any[]; Common.Type = 0; Common.subLevel = 0; Common.GameSubTipConfigs = this.jsonData.tipsArray//BangXinLangJieQinConfig.getInstance().getGameConfig('tipsArray'); Common.GameSubAnswerConfigs = this.jsonData.answersArray//BangXinLangJieQinConfig.getInstance().getGameConfig('answersArray'); } initView(){ this.initTouchEvent(this.node.getChildByName('背景').getChildByName('猴子1'),[this.node.getChildByName('背景').getChildByName('红绿灯touchArea')]) for(let i=0;i<10;i++){ this.initTouchEvent(this.node.getChildByName('背景').getChildByName('nvRenNode_'+i),[this.node.getChildByName('背景').getChildByName('塔吊touchArea'),this.node.getChildByName('背景').getChildByName('牛气球touchArea')],'nvRen') } this.initTouchEvent(this.node.getChildByName('背景').getChildByName('钻机'),[this.node.getChildByName('背景').getChildByName('女touchArea'),this.node.getChildByName('背景').getChildByName('围墙touchArea')]) this.initTouchEvent(this.node.getChildByName('背景').getChildByName('打气筒'),[this.node.getChildByName('背景').getChildByName('牛touchArea')]) this.initTouchEvent(this.node.getChildByName('背景').getChildByName('蜘蛛'),[this.node.getChildByName('背景').getChildByName('女touchArea')]) this.initTouchEvent(this.node.getChildByName('背景').getChildByName('云朵'),[this.node.getChildByName('背景').getChildByName('女touchArea')]) this.initTouchEvent(this.node.getChildByName('背景').getChildByName('小男孩touchArea'),[]) this.initTouchEvent(this.node.getChildByName('背景').getChildByName('狗'),[this.node.getChildByName('背景').getChildByName('boyNode')]) this.initTouchEvent(this.chuZuCheTouchArea1,[]) } initTouchEvent(node, checkNodeTab,targetName?) { var attrs = { checkNodeTab: checkNodeTab, targetName:targetName, recoveposi: node.getPosition(),//初始位置 recoveparent: node.parent, }; node.attr(attrs); this.openTouchEvent(node) } 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) { Common5.playEffect("点击音效"); if(this.isAction){ return } let target = event.target; if(target.targetName && target.targetName == 'nvRen'){ target = this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum) }else if(target.name == '小男孩touchArea'){ return }else if(target.name == 'chuZuCheTouchArea1'){ return } let posi = event.getLocation()//世界坐标 posi = target.parent.convertToNodeSpaceAR(posi) target.setPosition(posi) } touchMoveNode(event) { if(this.isAction){ return } let posi = event.getLocation()//世界坐标 let target = event.target if(target.targetName && target.targetName == 'nvRen'){ target = this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum) }else if(target.name == '小男孩touchArea'){ return }else if(target.name == 'chuZuCheTouchArea1'){ return } posi = target.parent.convertToNodeSpaceAR(posi) target.setPosition(posi) } checkArea(target,checkNodeTab){ for(let i=0;i{ this.node.getChildByName('背景').getChildByName('zuanJiZuanQiangSpine').active = false this.node.getChildByName('背景').getChildByName('钻机').active = true this.node.getChildByName('背景').getChildByName('围墙1').active = false this.node.getChildByName('背景').getChildByName('围墙2').active = true this.node.getChildByName('背景').getChildByName('砖头堆').active = true this.initTouchEvent(this.node.getChildByName('背景').getChildByName('砖头堆'),[this.node.getChildByName('背景').getChildByName('马路touchArea')]) this.isAction = false }) .start() //天桥 }else if(target.name == '砖头堆'){ target.active = false this.setWomenSpine(ActionType.GuoQiao) return //牛打气 }else if(target.name == '打气筒' && !this.isNiuDaQi){ this.isAction = true this.isNiuDaQi = true this.node.getChildByName('背景').getChildByName('打气筒').active = false this.node.getChildByName('背景').getChildByName('牛Spine').getComponent(sp.Skeleton).setAnimation(0,'打气',false) cc.tween(this.node) .delay(2.66) .call(()=>{ this.isAction = false this.node.getChildByName('背景').getChildByName('打气筒').active = true this.node.getChildByName('背景').getChildByName('牛Spine').getComponent(sp.Skeleton).setAnimation(0,'牛气球',false) }) .start() //牛气球 }else if(target.targetName && target.targetName == 'nvRen' && this.isNiuDaQi && !this.isNiuQiQiu && this.checkAreaIndex == 1){ this.isNiuQiQiu = true this.node.getChildByName('背景').getChildByName('牛Spine').active = false this.setWomenSpine(ActionType.FeiNiu) //蜘蛛 }else if(target.name == '蜘蛛'){ Common5.playEffectCustom("bangxinlangjieqin", 'sound/腾云驾雾'); this.node.getChildByName('背景').getChildByName('蜘蛛').active = false this.setWomenSpine(ActionType.ZhiZhu) return //云朵 }else if(target.name == '云朵'){ Common5.playEffectCustom("bangxinlangjieqin", 'sound/蜘蛛侠'); this.node.getChildByName('背景').getChildByName('云朵').active = false this.setWomenSpine(ActionType.ChengYun) return //打开售货机 }else if(target.name == '金币'){ this.node.getChildByName('背景').getChildByName('金币').active = false this.node.getChildByName('背景').getChildByName('售货机玻璃罩').active = false this.initTouchEvent(this.node.getChildByName('背景').getChildByName('火箭喷射器'),[this.node.getChildByName('背景').getChildByName('女touchArea')]) return //售货机 }else if(target.name == '火箭喷射器'){ this.node.getChildByName('背景').getChildByName('火箭喷射器').active = false this.setWomenSpine(ActionType.HuoJianPenSheQi) return //狗 }else if(target.name == '狗'){ this.node.getChildByName('背景').getChildByName('狗').active = false this.setWomenSpine(ActionType.Gou) return } } if (target["recoveposi"]) { target.setPosition(target["recoveposi"]) } } //初始化组件 initComponent() { let lab = this.node.getChildByName("标题").getChildByName("lab"); lab.getComponent(cc.Label).string = this.titleArrayConfig[0]; let title = this.titleArrayConfig[0]; Game.ins.setGameTitle(title) } showQiPao(curLog,func?) { console.log("curLog==", curLog); Common5.playEffectCustom("bangxinlangjieqin", curLog.effectUrl); let qiPao = this.node.getChildByName("qiPao").getChildByName("qiPao_" + curLog.qiPaoPos); qiPao.stopAllActions() qiPao.getChildByName("str").getComponent(cc.Label).string = curLog.dialogStr qiPao.active = true qiPao.scale = 0 cc.tween(qiPao) .to(0.2, { scale: 1 }) .delay(curLog.delayTime) .call(() => { qiPao.active = false if (func) { func(); } }) .start(); } endGameView(touchIndex) { Game.ins.stopTime(); this.scheduleOnce(()=>{ // this.node.getChildByName("mask").active = true; if (touchIndex == 0) { Game.ins.showFail();; } else { Game.ins.showSuccess();; } },3.5) } setWomenSpine(type){ //红绿灯过马路 if(type == ActionType.GuoMaLu){ this.isAction = true this.node.getChildByName('背景').getChildByName('猴子1').active = false this.node.getChildByName('背景').getChildByName('猴子2').active = true this.node.getChildByName('背景').getChildByName('cheSpine').getComponent(sp.Skeleton).setAnimation(0,'车流停车',false) this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('guoMaLuNvSpine1').active = true this.node.getChildByName('背景').getChildByName('guoMaLuNvSpine1').getComponent(sp.Skeleton).setAnimation(0,'过马路',false) cc.tween(this.node) .delay(2.83) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[7]) this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('guoMaLuNvSpine1').active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('猴子2').active = false this.node.getChildByName('背景').getChildByName('猴子1').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.node.getChildByName('背景').getChildByName('cheSpine').getComponent(sp.Skeleton).setAnimation(0,'车流',true) this.checkIsFinish() this.isAction = false }) .start() //塔吊 }else if(type == ActionType.TaDiao){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('taDiaoNvSpine1').active = true this.node.getChildByName('背景').getChildByName('taDiaoNvSpine1').getComponent(sp.Skeleton).setAnimation(0,'吊钩',false) cc.tween(this.node) .delay(1.16) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[6]) this.node.getChildByName('背景').getChildByName('taDiaoNvSpine1').getComponent(sp.Skeleton).setAnimation(0,'吊钩待机',false) this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() //钻机凿洞 }else if(type == ActionType.ZuanJiZuanDong){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('daDongNvSpine1').active = true this.node.getChildByName('背景').getChildByName('daDongNvSpine1').getComponent(sp.Skeleton).setAnimation(0,'钻机打洞',false) cc.tween(this.node) .delay(1.06) .call(()=>{ this.node.getChildByName('背景').getChildByName('daDongNvSpine1').active = false this.node.getChildByName('背景').getChildByName('daDongNvSpine2').active = true this.node.getChildByName('背景').getChildByName('daDongNvSpine2').getComponent(sp.Skeleton).setAnimation(0,'钻机打洞2',false) }) .delay(1) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[4]) this.node.getChildByName('背景').getChildByName('daDongNvSpine2').active = false this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('钻机').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() //过桥 }else if(type == ActionType.GuoQiao){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('拱桥底层').active = true this.node.getChildByName('背景').getChildByName('qiaoSpine').active = true this.node.getChildByName('背景').getChildByName('qiaoSpine').getComponent(sp.Skeleton).setAnimation(0,'过桥',false) cc.tween(this.node) .delay(1) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[3]) this.node.getChildByName('背景').getChildByName('拱桥底层').active = false this.node.getChildByName('背景').getChildByName('qiaoSpine').active = false this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() //飞牛 }else if(type == ActionType.FeiNiu){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('feiNiuSpine').active = true this.node.getChildByName('背景').getChildByName('feiNiuSpine').getComponent(sp.Skeleton).setAnimation(0,'牛',false) cc.tween(this.node) .delay(1.33) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[9]) this.node.getChildByName('背景').getChildByName('feiNiuSpine').active = false this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() //蜘蛛 }else if(type == ActionType.ZhiZhu){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('zhiZhuNvSpine').active = true this.node.getChildByName('背景').getChildByName('zhiZhuNvSpine').getComponent(sp.Skeleton).setAnimation(0,'蛛丝',false) cc.tween(this.node) .delay(0.83) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[5]) this.node.getChildByName('背景').getChildByName('zhiZhuNvSpine').active = false this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() //云朵 }else if(type == ActionType.ChengYun){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('chengYuNvSpine').active = true this.node.getChildByName('背景').getChildByName('chengYuNvSpine').getComponent(sp.Skeleton).setAnimation(0,'云',false) cc.tween(this.node) .delay(0.83) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[0]) this.node.getChildByName('背景').getChildByName('chengYuNvSpine').active = false this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() //火箭喷射器 }else if(type == ActionType.HuoJianPenSheQi){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('beiBaoNvSpine').active = true this.node.getChildByName('背景').getChildByName('beiBaoNvSpine').getComponent(sp.Skeleton).setAnimation(0,'火箭喷射器',false) cc.tween(this.node) .delay(0.83) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[8]) this.node.getChildByName('背景').getChildByName('beiBaoNvSpine').active = false this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() //狗 }else if(type == ActionType.Gou){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false if(!this.isClickCunQianGuan){ this.node.getChildByName('背景').getChildByName('boyNode').getChildByName('boySpine').getComponent(sp.Skeleton).setAnimation(0,'小男孩有钱罐',false) }else{ this.node.getChildByName('背景').getChildByName('boyNode').getChildByName('boySpine').getComponent(sp.Skeleton).setAnimation(0,'小男孩没钱灌',false) } cc.tween(this.node) .delay(1.53) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[2]) if(!this.isClickCunQianGuan){ this.node.getChildByName('背景').getChildByName('boyNode').getChildByName('boySpine').getComponent(sp.Skeleton).setAnimation(0,'小男孩有钱罐0',false) }else{ this.node.getChildByName('背景').getChildByName('boyNode').getChildByName('boySpine').getComponent(sp.Skeleton).setAnimation(0,'小男孩没钱罐0',false) } this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() //出租车 }else if(type == ActionType.ChuZuChe){ this.isAction = true this.node.getChildByName('背景').getChildByName('nvRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('cheSpine').active = false this.node.getChildByName('背景').getChildByName('chuZuCheSpine').active = true this.node.getChildByName('背景').getChildByName('chuZuCheSpine').getComponent(sp.Skeleton).setAnimation(0,'出租',false) cc.tween(this.node) .delay(2.5) .call(()=>{ this.showQiPao(this.duihuaArrayConfig[1]) this.node.getChildByName('背景').getChildByName('chuZuCheSpine').active = false this.node.getChildByName('背景').getChildByName('nanRenNode_'+this.curFinishNum).active = false this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').getComponent(sp.Skeleton).setAnimation(0,'公主抱',false) }) .delay(1) .call(()=>{ this.node.getChildByName('背景').getChildByName('cheSpine').active = true this.node.getChildByName('背景').getChildByName('baoZouNvSpine').active = false this.checkIsFinish() this.isAction = false }) .start() } } checkIsFinish(){ this.curFinishNum++ if(this.curFinishNum >= 10){ this.endGameView(1) } } }