import EventMgr from "../../../FrameWork/Event/EventMgr"; import { ryw_Event } from "../../../FrameWork/Event/EventEnum"; import Common5 from "../../../Platform/th/Common5"; import Game from "../../../Scripts/Game"; import Common from "../../../FrameWork/Util/Common"; import DaDianScript from "../../../FrameWork/Base/DaDianScript"; import WordGameBaseComponent from "../../../FrameWork/Base/WordGameBaseComptent"; // import BGMove from "../../../WordGame/gameComScript/BGMove"; const {ccclass, property} = cc._decorator; @ccclass export default class TiZhongZhiMi extends WordGameBaseComponent{ @property(cc.Node) maskNode:cc.Node = null; @property(cc.Node) mapNode:cc.Node = null; @property(cc.Node) qipaoNode:cc.Node = null; @property(cc.Node) tizhongLab:cc.Node = null; @property(cc.Node) tizhongAdd:cc.Node = null; curLayerIndex = 0; mapNodeFixedScale:number = 0.6//固定缩放(图片太大了) touchStartTime:number = 0//触摸开始时间 originalTouchDistance:number = 0 //起始双指触摸间距 lastScale:number = 1//上次缩放值 curScale:number = 1//当前缩放值 touchId1:number = -1 touchId2:number = -2 isStop = false curFinishNum:number = 0 chadianMax1 = 190 isShowResuit: boolean = false; tizhongNum = 20 onLoad(){ DaDianScript.userEnterDaDian() } start(){ super.start(); //this.mapNode.getChildByName('maskNode').active = true this.initMapNodeTouchEvent() //Common5.playEffectCustom('tizhongzhimi','sound/滑雪') Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/TiZhongZhiMiConfigs',(assest)=>{ this.jsonData = assest.json this.initParameters(); }) this.tizhongLab.getComponent(cc.Label).string = this.tizhongNum+'' EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => { this.normalTouchCallback(data_.targetNode); }, this); EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => { this.normalTouchCallback(data_.targetNode); }, this); EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => { this.normalTouchCallback(data_.targetNode); }, this); EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => { this.scheduleOnce(() => { Game.ins.showFail(); }, 3); }, this); } addLab(addNum){ this.tizhongNum+=addNum let node = cc.instantiate(this.tizhongAdd) node.parent = this.tizhongAdd.parent node.getComponent(cc.Label).string = "+"+addNum node.active = true cc.tween(node) .to(0.8, {y:30}) .call(()=>{ this.tizhongLab.getComponent(cc.Label).string = this.tizhongNum+'' node.removeFromParent() node.destroy() }) .start() } normalTouchCallback(targetNode){ console.log(targetNode.name) if(targetNode.name == '牛排汉堡'){ this.unlockLevel(1) this.scheduleOnce(()=>{ this.mapNode.getChildByName('女人').getChildByName('吃汉堡').active = false this.showQiPao('汉堡不能多吃,一个就够了') this.addLab(10) },1.0) }else if(targetNode.name == '可乐'){ this.unlockLevel(0) this.scheduleOnce(()=>{ this.mapNode.getChildByName('女人').getChildByName('喝可乐').active = false this.showQiPao('宅女也爱喝快乐水') this.addLab(10) },1.0) }else if(targetNode.name == '剪刀'){ this.unlockLevel(6) this.scheduleOnce(()=>{ this.mapNode.getChildByName('剪刀2').active = false this.mapNode.getChildByName('女人').getChildByName('胖身体').active = true this.showQiPao('勒紧点,就看不出来了') this.addLab(15) },1.0) }else if(targetNode.name == '遥控器click'){ this.unlockLevel(2) this.showQiPao('你不知道热胀冷缩吗') this.addLab(20) }else if(targetNode.name == '女人'){ this.unlockLevel(3) this.scheduleOnce(()=>{ this.mapNode.getChildByName('有人睡的床').active = false targetNode.active = true this.showQiPao('睡觉是快乐的源泉') this.addLab(10) },1.0) }else if(targetNode.name == 'toucheckMove'){ this.unlockLevel(4) this.showQiPao('遮脸显瘦你不知道吗') this.addLab(15) }else if(targetNode.name == 'jincheckcheck'){ this.unlockLevel(7) this.showQiPao('难道一斤不等于一公斤吗') this.addLab(30) }else if(targetNode.name == 'clickJiao'){ this.unlockLevel(5) this.showQiPao('原来是要双脚站上面啊') this.addLab(20) }else if(targetNode.name == 'siwaMoveCheck'){ this.unlockLevel(9) this.showQiPao('黑丝袜显瘦') this.addLab(20) }else if(targetNode.name == '地毯'){ this.unlockLevel(8) this.showQiPao('垫个垫子怎么了') this.addLab(20) } this.checkIsFinish() } initParameters(){ Common.Type = 3; Common.subLevel = 0; Common.GameSubTipConfigs = this.jsonData.tipsArray; this.refreshTitle() } wordGameReviveCallback(){ } //初始化触摸监听 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{ }) .delay(2) .to(0.2,{scale:0}) .start() } checkIsFinish(){ if(this.tizhongNum == this.chadianMax1){ if(this.isShowResuit){ return } this.isShowResuit = true Common5.stopMusic() this.scheduleOnce(()=>{ Game.ins.showSuccess() },4.0) } // if(this.curFinishNum