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 GameReport from "../../../../FrameWork/Report/ZyZyReport"; import WordGameBaseComponent from "../../../../FrameWork/Base/WordGameBaseComptent"; const {ccclass, property} = cc._decorator; enum YeYeStatus{ xuehua, beixin, mianfu, } // "toolTip": "1.将钱拖动到三轮车\n2.将钱拖动到柴火堆", // "answer": "n\n\n7.将爷爷拖动到垃圾桶上\n8.爷爷拖动到垃圾桶上之后,再将钱拖动到垃圾桶上\n\n\n\n\n13.将钱拖动到右墙\n14.将钱拖动到墙上的海报\n15.将钱拖动到老鼠洞\n16.将钱拖动到鸡身上", let answer = [ '将钱拖动到三轮车', //0 '将钱拖动到柴火堆',//1 '将钱拖动到桌子',//2 '上划盒饭打开,再将钱拖动到馒头',//3 '将钱拖到雪堆爷爷身上',//4 '将钱第二次拖动爷爷',//5 '将爷爷拖动到垃圾桶上,再将钱拖动到垃圾桶上',//6 '将钱拖动奶奶',//7 '将钱拖动到凉席',//8 '将钱拖动到盖在奶奶的报纸上',//9 '将钱拖动到地面',//10 '将钱拖动到墙壁',//11 '将钱拖动到墙上的海报',//12 '将钱拖动到老鼠洞',//13 '将钱拖动到鸡身上',//14 '将龙虾拖到地上,将钱拖给老鼠'//15 ] let CurGameConfig = { CheckNode:[ 'jiji_check', 'check_sanlun', 'check_qiangbi1', 'yeyeanmo_check', 'check_qiangbi2', 'check_qiangbi3', 'yeyexue_check', '火堆', 'yeyezuo_check', '垃圾桶Check', '普通老鼠洞', 'nainaizuo_check', 'nainaitang_check', 'liangxi_check', '普通桌子', '发霉馒头', '男模海报', '泥土地面', '老鼠fixedNode' ], } @ccclass export default class QiaoXiaLaoren extends WordGameBaseComponent{ @property(cc.Node) maskNode:cc.Node = null; @property(cc.Node) mapNode: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 isStepRight:boolean = true isKaiChuang:boolean = false YeYeCurStatus = YeYeStatus.xuehua yeyeMove = false yeyeAnmo: boolean = false; nainaiIsTang = false isAnmoNan: boolean = false; onLoad(){ DaDianScript.userEnterDaDian() Common.Type = 3; Common.subLevel = 0; Common.GameSubTipConfigs=answer//[Common5.gameConfig.zmGameConfig[Common5.selectGameNum].toolTip] // Common.GameSubAnswerConfigs=[Common5.gameConfig.zmGameConfig[Common5.selectGameNum].answer] this.bundle = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].bundle EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => { Game.ins.showFail();; }, this); EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => { // if(data_.targetNode.name == '窗户关'){ // this.isKaiChuang = true // } }, this); } start(){ super.start(); cc.macro.ENABLE_MULTI_TOUCH = true; this.initMapNodeTouchEvent() Common5.playMusicCustom('qiaoxialaoren','sound/背景音') EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => { this.normalTouchCallback(data_.targetNode); }, this); } normalTouchCallback(targetNode){ this.yeyeMove = true if(this.YeYeCurStatus == YeYeStatus.beixin){ this.mapNode.getChildByName('爷爷坐').getComponent(sp.Skeleton).setAnimation(0,'背心', true) }else if(this.YeYeCurStatus == YeYeStatus.mianfu){ this.mapNode.getChildByName('爷爷坐').getComponent(sp.Skeleton).setAnimation(0,'棉服', true) this.mapNode.getChildByName('yeyezuo_check').active = false } if(this.yeyeAnmo){ this.mapNode.getChildByName('按摩女').active = false this.mapNode.getChildByName('按摩女2').active = true } } //初始化触摸监听 initMapNodeTouchEvent(){ this.initMouseEvent(); this.mapNode.on(cc.Node.EventType.TOUCH_START, this.touchStart_mapNode,this) this.mapNode.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove_mapNode,this) this.mapNode.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEnd_mapNode,this) this.mapNode.on(cc.Node.EventType.TOUCH_END, this.touchEnd_mapNode,this) 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= 0 && this.touchId2 >= 0){ // console.log("邵阳1—双点触摸开始") } this.touchStartTime = Date.now() } touchMove_mapNode(event){ let touches = event.getTouches() if(touches.length == 2){ //缩放 if(this.originalTouchDistance == 0){ this.originalTouchDistance = this.getDistance(touches[0].getLocation(),touches[1].getLocation()) } //获取双指移动数据 let curDistance = this.getDistance(touches[0].getLocation(),touches[1].getLocation()) let tempScale = curDistance/this.originalTouchDistance let y = 0.5*tempScale + 0.5 let scale = y * this.lastScale if(scale < this.mapNodeFixedScale){ scale = this.mapNodeFixedScale }else if(scale > 3){ scale = 3 }else{ } this.mapNode.scale = scale this.curScale = scale this.goToBoundary(); }else if(touches.length == 1){ //拖动 let delta = event.getDelta() this.mapNode.x += delta.x this.mapNode.y += delta.y // console.log(this.mapNode.scale,this.mapNode.x,this.mapNode.y); this.goToBoundary() } } touchEnd_mapNode(event){ console.log('touchEnd===') let dateNow = Date.now() if(dateNow - this.touchStartTime > 0.2 * 1000){ // console.log('0.2===') // //补丁,长按两秒 // if(dateNow - this.touchStartTime > 1.5 * 1000){ // console.log('2===') // let wl_fangzi = this.mapNode.getChildByName('wl_房子') // let chuanghuguan = wl_fangzi.getChildByName('窗户关') // let chuanghukai = wl_fangzi.getChildByName('窗户开') // let rect = chuanghuguan.getBoundingBoxToWorld() // if(wl_fangzi.active && chuanghuguan.active && rect.contains(event.getLocation())){ // chuanghuguan.active = false // chuanghukai.active = true // this.isKaiChuang = true // } // } }else{ // this.isFind = false; let touchPos = event.getLocation(); this.checkIsInAreaNewVersion(touchPos) } if(event.touch.getID() == this.touchId1){ this.touchId1 = -1 }else if(event.touch.getID() == this.touchId2){ this.touchId2 = -2 } if(this.touchId1 < 0 && this.touchId2 < 0){ this.originalTouchDistance = 0 this.lastScale = this.curScale // this.goToBoundary() } } //距离 getDistance(startPos,endPos){ var pos = cc.v2(startPos.x - endPos.x,startPos.y - endPos.y) var dis = Math.sqrt(pos.x * pos.x + pos.y * pos.y) return dis } //检测边界 goToBoundary(){ let widthMask = this.maskNode.width let heightMask = this.maskNode.height let widthMap = this.mapNode.width*this.curScale let heightMap = this.mapNode.height*this.curScale //右边界 if(this.mapNode.x + widthMap/2 <= widthMask/2){ this.mapNode.x = widthMask/2 - widthMap/2 //左边界 }else if(this.mapNode.x - widthMap/2>= -widthMask/2){ this.mapNode.x = -widthMask/2 + widthMap/2 } //上边界 if(this.mapNode.y + heightMap/2 <= heightMask/2){ this.mapNode.y = heightMask/2 - heightMap/2 //下边界 }else if(this.mapNode.y - heightMap/2 >= -heightMask/2){ this.mapNode.y = -heightMask/2 + heightMap/2 } } initMouseEvent(){ this.mapNode.on(cc.Node.EventType.MOUSE_WHEEL,function(event){//监听名称+事件参数 console.log(event); let tmpscale = this.mapNode.scale; if (event._scrollY > 0){ if (this.mapNode.scale < 3){ tmpscale+=0.2; this.mapNode.scale = tmpscale this.curScale = tmpscale this.lastScale = tmpscale } } else { if (this.mapNode.scale > this.mapNodeFixedScale){ tmpscale-=0.2; this.mapNode.scale = tmpscale this.curScale = tmpscale this.lastScale = tmpscale } } // console.log(this.mapNode.scale,this.mapNode.x,this.mapNode.y); this.goToBoundary(); },this); } //检测node是否进入target区域(新版) checkIsInAreaNewVersion(pos){ // //茬点触碰逻辑 // let childrens = this.mapNode.getChildByName("chaDianNode").children // for(var i =0;i{ laoShu.getComponent(sp.Skeleton).clearTracks() this.mapNode.getChildByName('老鼠fixedNode').active = true }) .start() return }else if(checkTarget.name == '老鼠fixedNode'){ this.unlockLevel(15) this.mapNode.getChildByName('老鼠衣服').active = true } this.curFinishNum ++ console.log(checkTarget.name, 'checkTarget.name+++++====') console.log('this.curFinishNum===',this.curFinishNum) this.checkIsFinish() }else{ event.target.setPosition(event.target.startPos) } } checkArea(node,checkNodeTab){ let checkIndex = null for(let i=0;i= 16){ console.log('结算+++===',this.curFinishNum) this.scheduleOnce(()=>{ if(this.curFinishNum >= 16){ if(this.isStepRight){ Game.ins.showSuccess() }else{ Game.ins.showFail() } } },2) } } unlockLevel(sublevel){ Game.ins.tipUnlock(sublevel) } }