// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html 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"; const {ccclass, property} = cc._decorator; @ccclass export default class ShuiShiJianDie extends WordGameBaseComponent { @property(cc.Node) qipaoNode:cc.Node = null; @property(cc.Node) renwu1:cc.Node = null; @property(cc.Node) renwu2:cc.Node = null; @property(cc.Node) renwu3:cc.Node = null; @property(cc.Node) renwu4:cc.Node = null; @property(cc.Node) renwu5BaoAn:cc.Node = null; @property(cc.Node) chooseNode:cc.Node = null; peopleArray = [] titleArrayConfig: string[] = []; isGameEnd = false; curPeopleIndex = 0 peopleState = ['放行', '放行', '放行', '放行'] // 直接抓走,发现抓走,直接放行,发现放行 isPoshui = false isFindBingli= false isUseJianDao = false // start () { this.peopleArray = [this.renwu1, this.renwu2, this.renwu3, this.renwu4] super.start(); DaDianScript.userEnterDaDian(); Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/ShuiShiJianDieConfig',(assest)=>{ this.jsonData = assest.json this.initParameters(); }) EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => { this.normalTouchCheckCallback(data_.targetNode,data_); }, this); EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => { this.normalTouchCheckCallback(data_.targetNode,data_); }, this); EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => { this.normalTouchCheckCallback(data_.targetNode,data_); }, this); //this.showQiPao(this.qipaoNan, '赶紧换回来,这破地方本少爷一秒都呆不下去',3) } normalTouchCheckCallback(targetNode,data_){ console.log("targetNodeName+++++++++++++++++++++>" + targetNode.name); if(targetNode.name == '剪刀'){ //变化 this.renwu4.getComponent(sp.Skeleton).setAnimation(0,'剪衣服', false) this.scheduleOnce(()=>{ this.renwu4.getComponent(sp.Skeleton).setAnimation(0,'瘦呼吸', true) },1.5) this.isUseJianDao = true }else if(targetNode.name == '杯子'){ //泼水 this.node.getChildByName('泼水').active = true this.scheduleOnce(()=>{ this.renwu2.getComponent(sp.Skeleton).setAnimation(0,'女呼吸', true) },1.0) this.isPoshui = true }else if(targetNode.name == '病历'){ this.isFindBingli = true } } moveToscree(node:cc.Node, posiX, callfunc=null){ let recovePosi = node.getPosition() cc.tween(node) .to(0.7, {x:posiX, y:recovePosi.y}) .call(()=>{ if(callfunc){ callfunc() } }) .start() } enterToscree(node:cc.Node, callfunc=null){ let recovePosi = node.getPosition() cc.tween(node) .to(0.3, {x:recovePosi.x+700, y:recovePosi.y}) .call(()=>{ if(callfunc){ callfunc() } }) .start() } moveLevelscree(node:cc.Node,callfunc=null){ let recovePosi = node.getPosition() cc.tween(node) .to(0.3, {x:-760, y:recovePosi.y}) .call(()=>{ if(callfunc){ callfunc() } }) .start() } initParameters(){ this.titleArrayConfig = this.jsonData.titleArray; Common.Type = 0; Common.subLevel = 0; Common.GameSubTipConfigs=[this.jsonData.tipsArray] Common.GameSubAnswerConfigs=[this.jsonData.answersArray] Game.ins.setGameTitle(this.titleArrayConfig[0]); this.enterPeople() } showQiPao(qipaoNode, str, delayTime=3, callFunc=null, str2=null){ qipaoNode.scale = 0 qipaoNode.active = true qipaoNode.stopAllActions() qipaoNode.getChildByName("str").getComponent(cc.Label).string = str if (str2) { Common5.playEffectCustom(Common5.selectGameInfo.bundle, "sound/"+str2); }else{ Common5.playEffectCustom(Common5.selectGameInfo.bundle, "sound/"+str); } cc.tween(qipaoNode) .to(0.2,{scale:1.5}) .delay(delayTime) .call(()=>{ qipaoNode.active = false if(callFunc){ callFunc() } }) .start() } endGameView(isSuccess, delay = 3) { if( this.isGameEnd ){ return } this.isGameEnd = true if(isSuccess){ Game.ins.stopTime(); this.scheduleOnce(()=>{ Game.ins.showSuccess() },delay) }else{ Game.ins.stopTime(); this.scheduleOnce(()=>{ Game.ins.showFail() },delay) } } unlockLevel(sublevel) { Game.ins.tipUnlock(sublevel) } // 直接抓走,发现抓走,直接放行,发现放行 showEndGame(){ console.log('peopleState', this.peopleState) let isSuccess = false let peopeoshuohua = '说话' let duihua = '你做的很好,再接再厉' let delayTime = 3 if(this.peopleState[0] == '直接放行' && this.peopleState[1] == '发现抓走' && this.peopleState[2] == '发现放行' && this.peopleState[3] == '发现抓走'){ isSuccess = true duihua = '你做的很好,再接再厉' delayTime = 2 peopeoshuohua = '说话' }else if(this.peopleState[0] == '直接抓走' || this.peopleState[1] == '直接抓走' || this.peopleState[2] == '直接抓走' || this.peopleState[3] == '直接抓走' ){ isSuccess = false duihua = '你居然在公司胡乱抓人,你跟我走一趟吧' delayTime = 3 peopeoshuohua = '生气' }else{ isSuccess = false duihua = '因为你的疏忽,公司进入了间谍,你跟我走一趟吧' delayTime = 4 peopeoshuohua = '生气' } this.node.getChildByName('gameEnd').active = true this.scheduleOnce(()=>{ this.node.getChildByName('gameEnd').active = false this.moveToscree(this.renwu5BaoAn, 0, ()=>{ this.renwu5BaoAn.getComponent(sp.Skeleton).setAnimation(0, peopeoshuohua, true) this.showQiPao(this.qipaoNode, duihua,delayTime, ()=>{ this.renwu5BaoAn.getComponent(sp.Skeleton).setAnimation(0, '呼吸', true) this.endGameView(isSuccess, 1) }) }) },2.0) } enterPeople(){ let curPeople = this.peopleArray[this.curPeopleIndex] let poxiArray = [0,-70,75,50] let duihuastrs = ['麻烦快点,我吃完饭还要加班', '快点检查,我还要去公关呢','每天这样好烦啊','快点检查,我还要去健身呢'] let duihua = duihuastrs[this.curPeopleIndex] let posix = poxiArray[this.curPeopleIndex] curPeople.getComponent(sp.Skeleton).setAnimation(0, '说话', true) let kaAnim = this.curPeopleIndex+1+'进来' let xinxiNodeName = '详情'+this.curPeopleIndex this.node.getChildByName('信息表2').getChildByName('详情0').active = false this.node.getChildByName('信息表2').getChildByName('详情1').active = false this.node.getChildByName('信息表2').getChildByName('详情2').active = false this.node.getChildByName('信息表2').getChildByName('详情3').active = false this.moveToscree(curPeople, posix, ()=>{ this.node.getChildByName('信息表2').active = true this.node.getChildByName('信息表2').getChildByName(xinxiNodeName).active = true this.node.getChildByName('卡动画').active = true this.node.getChildByName('卡动画').getComponent(sp.Skeleton).setAnimation(0,kaAnim,false) this.showQiPao(this.qipaoNode, duihua,3, ()=>{ curPeople.getComponent(sp.Skeleton).setAnimation(0, '呼吸', true) }) }) } zhuazouPeople(){ } fangxingPeople(){ } zhuazouClickEvent(){ this.chooseNode.active = false this.node.getChildByName('信息表click').active = false let curPeople = this.peopleArray[this.curPeopleIndex] let duihuaStr = '' let peopeoshuohua = '说话' let peopeoshuohuaStop = '呼吸' let mulustr = '' let kaAnim = this.curPeopleIndex+1+'出去' this.node.getChildByName('卡动画').getComponent(sp.Skeleton).setAnimation(0,kaAnim,false) if(this.curPeopleIndex == 0){ duihuaStr = '你肯定是搞错了' mulustr = '你肯定是搞错了(李大力)' this.peopleState[0] = '直接抓走' peopeoshuohua = '生气' }else if(this.curPeopleIndex == 1){ if(this.isPoshui){ duihuaStr = '这都被你发现了' mulustr = '这都被你发现了(白复枚)' this.peopleState[1] = '发现抓走' peopeoshuohua = '女说话' peopeoshuohuaStop = '女呼吸' }else{ duihuaStr = '你肯定是搞错了' mulustr = '你肯定是搞错了(白复枚)' this.peopleState[1] = '直接抓走' peopeoshuohua = '生气' peopeoshuohuaStop = '生气' } }else if(this.curPeopleIndex == 2){ duihuaStr = '你肯定是搞错了' mulustr = '你肯定是搞错了(王小美)' this.peopleState[2] = '直接抓走' peopeoshuohua = '生气' peopeoshuohuaStop = '生气' }else if(this.curPeopleIndex == 3){ if(this.isUseJianDao){ duihuaStr = '这都被你发现了' mulustr = '这都被你发现了!(张健深)' this.peopleState[3] = '发现抓走' peopeoshuohua = '瘦生气' peopeoshuohuaStop = '瘦生气' }else{ duihuaStr = '你肯定是搞错了' mulustr = '你肯定是搞错了!(张健深)' this.peopleState[3] = '直接抓走' peopeoshuohua = '生气' peopeoshuohuaStop = '生气' } } this.curPeopleIndex++ this.moveToscree(this.renwu5BaoAn,-150, ()=>{ //对话 curPeople.getComponent(sp.Skeleton).setAnimation(0, peopeoshuohua, true) this.showQiPao(this.qipaoNode, duihuaStr ,1.5, ()=>{ // curPeople.getComponent(sp.Skeleton).setAnimation(0, peopeoshuohuaStop, true) this.moveLevelscree(curPeople, ()=>{ if(this.curPeopleIndex>=4){ this.showEndGame() }else{ this.enterPeople() } }) this.moveLevelscree(this.renwu5BaoAn) },mulustr) }) } //直接抓走,发现抓走,直接放行,发现放行 fangxingClickEvent(){ this.chooseNode.active = false this.node.getChildByName('信息表click').active = false let curPeople = this.peopleArray[this.curPeopleIndex] let duihuaStr = '' let peopeoshuohua = '说话' let peopeoshuohuaStop = '呼吸' let mulustr = '' let kaAnim = this.curPeopleIndex+1+'出去' this.node.getChildByName('卡动画').getComponent(sp.Skeleton).setAnimation(0,kaAnim,false) if(this.curPeopleIndex == 0){ duihuaStr = '谢谢' this.peopleState[0] = '直接放行' mulustr = '谢谢(李大力)' }else if(this.curPeopleIndex == 1){ duihuaStr = '谢谢' mulustr = '谢谢(白复枚)' this.peopleState[1] = '直接放行' if(this.isPoshui){ peopeoshuohua = '女说话' peopeoshuohuaStop = '女呼吸' }else{ peopeoshuohua = '说话' peopeoshuohuaStop = '呼吸' } }else if(this.curPeopleIndex == 2){ if(this.isFindBingli){ duihuaStr = '你做事真仔细' mulustr = '你做事真仔细' this.peopleState[2] = '发现放行' }else{ duihuaStr = '谢谢' mulustr = '谢谢(王小美)' this.peopleState[2] = '直接放行' } peopeoshuohua = '说话' peopeoshuohuaStop = '呼吸' }else if(this.curPeopleIndex == 3){ duihuaStr = '谢谢' mulustr = '谢谢(张健深)' this.peopleState[3] = '直接放行' if(this.isUseJianDao){ peopeoshuohua = '瘦呼吸' peopeoshuohuaStop = '瘦呼吸' }else{ peopeoshuohua = '说话' peopeoshuohuaStop = '呼吸' } } this.curPeopleIndex++ curPeople.getComponent(sp.Skeleton).setAnimation(0, peopeoshuohua, true) this.showQiPao(this.qipaoNode, duihuaStr ,1.0, ()=>{ curPeople.getComponent(sp.Skeleton).setAnimation(0, peopeoshuohuaStop, true) this.enterToscree(curPeople, ()=>{ //对话 if(this.curPeopleIndex>=4){ this.showEndGame() return }else{ this.enterPeople() } }) },mulustr) } // update (dt) {} }