import EventMgr from "../../../../FrameWork/Event/EventMgr"; import { ryw_Event } from "../../../../FrameWork/Event/EventEnum"; import Common5 from "../../../../Platform/th/Common5"; import Game from "../../../../Scripts/WenZiRes/ui/Game"; import Common from "../../../../FrameWork/Util/Common"; import DaDianScript from "../../../../FrameWork/Base/DaDianScript"; import WordGameBaseComponent from "../../../../FrameWork/Base/WordGameBaseComptent"; const {ccclass, property} = cc._decorator; @ccclass export default class ZhaoChuZhenXiong extends WordGameBaseComponent{ @property(cc.Node) maskNode:cc.Node = null; @property(cc.Node) mapNode:cc.Node = null; @property(cc.Node) chadianList:cc.Node[] = []; @property(cc.Node) chadianList2:cc.Node[] = []; @property(cc.Node) chadianList3:cc.Node[] = []; @property(cc.Node) layerNodeList:cc.Node[] = []; @property(cc.Node) chadianNodeList:cc.Node = null; @property(cc.Node) chadianContent:cc.Node = null; @property(cc.Node) chadianPrefab:cc.Node = null; @property(cc.Node) chooseNode:cc.Node = null; @property(cc.ScrollView) my_scrollView:cc.ScrollView = null; @property(cc.Node) duihuaNode:cc.Node = null; @property(cc.Node) qipaoNode:cc.Node = null; gameInfo = null bundle = null mapNodeFixedScale:number = 0.6//固定缩放(图片太大了) touchStartTime:number = 0//触摸开始时间 originalTouchDistance:number = 0 //起始双指触摸间距 lastScale:number = 1//上次缩放值 curScale:number = 1//当前缩放值 touchId1:number = -1 touchId2:number = -2 curFinishNum:number = 0 chadianMax1 = 5 chadianMax2 = 6 chadianMax3 = 2 posScx = null isStepRight = false; curLayer = null curLayerIndex = 0 clickCallBack = null onLoad(){ DaDianScript.userEnterDaDian() } start(){ super.start(); cc.macro.ENABLE_MULTI_TOUCH = true; this.chadianNodeList.active = true // Common5.playMusicCustom('pingkurenjia','sound/背景音') this.posScx = this.my_scrollView.getContentPosition() Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/ZhaoChuZhenXiongConfig',(assest)=>{ this.jsonData = assest.json this.initParameters(); this.initMapNodeTouchEvent() }) EventMgr.onEvent_custom(ryw_Event.WordGameRevive, () => { this.wordGameReviveCallback(); }, this); } initParameters(){ Common.Type = 0; Common.subLevel = 0; Common.GameSubTipConfigs = this.jsonData.tipsArray; Common.GameSubAnswerConfigs = this.jsonData.answersArray; this.refreshTitle() this.bundle = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].bundle } wordGameReviveCallback(){ this.mapNode.getChildByName('结束场景2').active = false this.mapNode.getChildByName('chooseLayer').active = true } //初始化触摸监听 initMapNodeTouchEvent(){ let prefabWidth = this.mapNode.width let prefabHeight = this.mapNode.height let maskWidth = this.maskNode.width let maskHeight = this.maskNode.height let widthScale = maskWidth/prefabWidth let heightScale = maskHeight/prefabHeight if(prefabWidth{ Common5.playEffect("点击茬点音效") let chooseNode:cc.Node = cc.instantiate(this.chooseNode) chooseNode.parent = this.curLayer.getChildByName('chadianParentNode') chooseNode.active = true Common5.setNodeToTargetPos(chooseNode,target) let curChadian = this.chadianContent.children[this.curFinishNum-1] let chadianSpr = curChadian.getChildByName('茬点框').getComponent(cc.Sprite) let str = chadianConfig.duihuaStr let imgUrl = chadianConfig.chadianImg let kuangNode = curChadian.getChildByName('茬点框') cc.tween(kuangNode) .call(()=>{ Common5.getSpriteFrameFromBundle("zhaochuzhenxiong", "texture/茬点/"+ imgUrl, chadianSpr); let lab = curChadian.getChildByName('lab').getComponent(cc.Label) curChadian.getChildByName('lab').active = true lab.string = chadianConfig.chadianName if(this.curLayerIndex==0 || this.curLayerIndex==2){ this.showDuihua(str) }else{ this.showQiPao(str) } this.checkIsFinish() }) .to(0.2, {scale:1.2}) .to(0.2, {scale:1.0}) .start() } return }else{ Common5.playEffect("点击茬点音效") let chooseNode:cc.Node = cc.instantiate(this.chooseNode) chooseNode.parent = this.curLayer.getChildByName('chadianParentNode') chooseNode.active = true Common5.setNodeToTargetPos(chooseNode,target) let curChadian = this.chadianContent.children[this.curFinishNum-1] let chadianSpr = curChadian.getChildByName('茬点框').getComponent(cc.Sprite) let str = chadianConfig.duihuaStr let imgUrl = chadianConfig.chadianImg let kuangNode = curChadian.getChildByName('茬点框') cc.tween(kuangNode) .call(()=>{ Common5.getSpriteFrameFromBundle("zhaochuzhenxiong", "texture/茬点/"+ imgUrl, chadianSpr); let lab = curChadian.getChildByName('lab').getComponent(cc.Label) curChadian.getChildByName('lab').active = true lab.string = chadianConfig.chadianName if(this.curLayerIndex==0 || this.curLayerIndex==2){ this.showDuihua(str) }else{ this.showQiPao(str) } this.checkIsFinish() }) .to(0.2, {scale:1.2}) .to(0.2, {scale:1.0}) .start() } }else{ } } showDuihua(str, delaytime=2,callfunc=null){ this.duihuaNode.active = true this.duihuaNode.stopAllActions() let labstr= this.duihuaNode.getChildByName('lab').getComponent(cc.Label) if (str) { Common5.playEffectCustom("zhaochuzhenxiong", "sound/"+str); } labstr.string = str cc.tween(this.duihuaNode) .delay(delaytime) .call(()=>{ this.duihuaNode.active = false if(callfunc){ callfunc() } }) .start() } showQiPao(str){ let qipaoNode = this.qipaoNode qipaoNode.scale = 0 qipaoNode.active = true qipaoNode.stopAllActions() qipaoNode.getChildByName("lab").getComponent(cc.Label).string = str if (str) { Common5.playEffectCustom("zhaochuzhenxiong", "sound/"+str); } cc.tween(qipaoNode) .to(0.2,{scale:1}) .call(()=>{ }) .delay(2) .to(0.2,{scale:0}) .start() } checkArea(node,checkNodeTab){ let checkIndex = null for(let i=0;i{ this.chadianNodeList.active = false this.curLayer.getChildByName('chadianParentNode').active = false this.mapNode.getChildByName('maskNode').active = true Common5.playEffectCustom("zhaochuzhenxiong", "sound/报警"); this.scheduleOnce(()=>{ this.mapNode.getChildByName('maskNode').active = false this.changeLayer('喂,你好,我要报一起入室伤人!',4.0, ()=>{ this.chadianListRegist('chadianList2', this.chadianList2) }) },1.0) },2.5) } }else if(this.curLayerIndex == 1){ //跳转到选择界面 if(this.curFinishNum == this.chadianMax2){ this.scheduleOnce(()=>{ this.mapNode.getChildByName('chooseLayer').active = true },2.0) } }else if(this.curLayerIndex == 2){ if(this.curFinishNum == this.chadianMax3){ this.scheduleOnce(()=>{ this.chadianNodeList.active = false this.mapNode.getChildByName('结束场景').active = true this.mapNode.getChildByName('结束场景').opacity = 0 cc.tween(this.mapNode.getChildByName('结束场景')) .to(1.0, {opacity:255}) .call(()=>{ Common5.playEffectCustom("zhaochuzhenxiong", "sound/结算语音"); this.scheduleOnce(()=>{ Game.ins.showSuccess() },6.0) }) .start() },3.0) } } } unlockLevel(sublevel){ Game.ins.tipUnlock(sublevel) } changeLayer(str,delayTime=3, callFunc){ let changelayer = this.mapNode.getChildByName('changelayer') changelayer.active = true let lab = changelayer.getChildByName('lab').getComponent(cc.Label) lab.string = str if (str) { Common5.playEffectCustom("zhaochuzhenxiong", "sound/"+str); } cc.tween(changelayer) .delay(delayTime) .call(()=>{ changelayer.active = false this.layerNodeList[this.curLayerIndex].active = false cc.tween(this.layerNodeList[this.curLayerIndex]) .to(1.0, {opacity:0}) .hide() .start() this.curLayerIndex++ this.refreshTitle() this.layerNodeList[this.curLayerIndex].opacity = 0 this.layerNodeList[this.curLayerIndex].active = true this.curLayer = this.layerNodeList[this.curLayerIndex] cc.tween(this.layerNodeList[this.curLayerIndex]) .to(1.0, {opacity:255}) .call(()=>{ if(callFunc){ callFunc() } }) .start() }) .start() } clickMaskNodeEvent(){ this.mapNode.getChildByName('layer1').getChildByName('maskNode').active = false this.mapNode.getChildByName('layer1').getChildByName('保证书').active = false this.mapNode.getChildByName('layer1').getChildByName('孕检单').active = false this.mapNode.getChildByName('layer1').getChildByName('手机放大').active = false if(this.clickCallBack){ this.clickCallBack() } } clickMaskNodeEvent2(){ this.mapNode.getChildByName('layer2').getChildByName('maskNode').active = false this.mapNode.getChildByName('layer2').getChildByName('保证书').active = false this.mapNode.getChildByName('layer2').getChildByName('手机短信').active = false if(this.clickCallBack){ this.clickCallBack() } } chooseLGClickEvent(){ //继续 this.mapNode.getChildByName('chooseLayer').active = false this.chadianNodeList.active = false this.curLayer.getChildByName('chadianParentNode').active = false this.showDuihua('为什么是老公?',3.0, ()=>{ // this.mapNode.getChildByName('layer2').getChildByName('快递真相').active = true this.showQiPao('我才不是凶手,你搞错了!') this.curLayerIndex++ this.refreshTitle() this.curLayer.getChildByName('chadianParentNode').removeAllChildren() this.curLayer.getChildByName('chadianParentNode').active = true this.curLayer.getChildByName('快递真相茬点').active = true this.curLayer.getChildByName('手机check').active = true this.chadianListRegist('chadianList3', this.chadianList3) }) } chooseKDYClickEvent(){ //失败 this.mapNode.getChildByName('结束场景2').active = true Common5.playEffectCustom("zhaochuzhenxiong", "sound/失败语音"); this.scheduleOnce(()=>{ Game.ins.showFailFuHuo() },6.0) } zhenxiangClickEvent(){ if(!this.isStepRight){ this.isStepRight = true this.showDuihua('快递员不可能放好快递再来行凶的',3.0, ()=>{ this.mapNode.getChildByName('结束场景').active = true this.mapNode.getChildByName('结束场景').opacity = 0 cc.tween(this.mapNode.getChildByName('结束场景')) .to(1.0, {opacity:255}) .delay(5.0) .call(()=>{ Game.ins.showSuccess() }) .start() }) } } refreshTitle(){ Common.subLevel = this.curLayerIndex; Game.ins.updateTishiBtn() let title = this.jsonData.titleArray[this.curLayerIndex] Game.ins.setGameTitle(title) } }