我智商爆棚
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1058 lines
54 KiB

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 ZhaoChaConfig_v7 from "./ZhaoChaConfig_v7";
import Common from "../../../FrameWork/Util/Common";
import DaDianScript from "../../../FrameWork/Base/DaDianScript";
const {ccclass, property} = cc._decorator;
@ccclass
export default class ZhaoChaV4 extends cc.Component{
gameId:number = 0;
gameInfo = null
originalTouchDistance:number = 0 //起始双指触摸间距
lastScale:number = 1//上次缩放值
oldScale:number = 1//上次缩放值
curScale:number = 1//当前缩放值
touchId1:number = -1
touchId2:number = -2
findTimes:number = 0//已找出个数
mapNode: cc.Node = null; //map图片
mapNodeFixedScale:number = 0.6//固定缩放(图片太大了)
touchStartTime:number = 0//触摸开始时间
isFind = false;
curZIndex:number = 100;
allMoneyNum_ = 0
@property(cc.Node)
timeNode:cc.Node = null;
@property(cc.Node)
maskNode:cc.Node = null;
@property(cc.Node)
blackNode:cc.Node = null;
@property(cc.Node)
markSp: cc.Node = null;
@property(cc.Node)
answerNodeType1: cc.Node = null;
@property(cc.Node)
answerNodeType2: cc.Node = null;
@property(cc.Node)
answerNodeType3: cc.Node = null;
@property(cc.Label)
taici: cc.Label = null;
curSceneIndex:number = 0;
subBundle = null
subUrl = null
isFailShow=false;
isSuccessShow = false;
update(dt: number){
}
onLoad(){
Common.Type = 2;
Common.subLevel = 0;
Common.GameSubTipConfigs=[Common5.gameConfig.zmGameConfig[Common5.selectGameNum].toolTip]
this.subBundle = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].subbundle
this.subUrl = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].suburl
this.gameId = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].gameId
this.gameInfo = ZhaoChaConfig_v7.getInstance().getHideGoodsInfo(this.gameId)
EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => {
Game.ins.showFail();
}, this);
DaDianScript.userEnterDaDian()
}
start(){
cc.macro.ENABLE_MULTI_TOUCH = true;
this.init_line();
this.setTimeNode();
this.initKaichang();
if (this.gameInfo.bgMusic!=""){
Common5.playMusicCustom(this.subBundle,this.gameInfo.bgMusic);
}
}
initKaichang(){
// this.taici.string = this.gameInfo.PrefabInfo[this.curSceneIndex].kaichang;
Game.ins.setTitle(this.gameInfo.PrefabInfo[this.curSceneIndex].title);
if (this.gameInfo.PrefabInfo[this.curSceneIndex].kaichang&& this.gameInfo.PrefabInfo[this.curSceneIndex].kaichang!=""){
this.showSay(this.gameInfo.PrefabInfo[this.curSceneIndex].kaichang);
}
this.initMapNodeTouchEvent(this.gameInfo.PrefabInfo[this.curSceneIndex].delay);
if (this.gameInfo.PrefabInfo[this.curSceneIndex].kaichangSound && this.gameInfo.PrefabInfo[this.curSceneIndex].kaichangSound!=""){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+this.gameInfo.PrefabInfo[this.curSceneIndex].kaichangSound);
}
this.specialKaichang();
}
specialKaichang(){
if (this.gameId == 1702){
this.scheduleOnce(()=>{
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"妈妈,你还没检查床底呢");
this.showSay("妈妈,你还没检查床底呢",true,1);
},2)
}
else if (this.gameId == 1703){
this.scheduleOnce(()=>{
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"走开走开,别挡老子的路");
this.showSay("走开走开,别挡老子的路");
},6)
}
}
setTimeNode(){
let worldPos = this.timeNode.getPosition()
Game.ins.setTimePos(worldPos.x,worldPos.y)
Game.ins.setTimeScale(0.7)
}
init_line(){
let answerNode = null
if(this.gameInfo.PrefabInfo[this.curSceneIndex].zhaoChaType == ZhaoChaConfig_v7.getInstance().getZhaoChaType().Type1){
answerNode = null;
this.answerNodeType1.active = false;
this.answerNodeType2.active = false;
this.answerNodeType3.active = false;
}
else if(this.gameInfo.PrefabInfo[this.curSceneIndex].zhaoChaType == ZhaoChaConfig_v7.getInstance().getZhaoChaType().Type2){
answerNode = this.answerNodeType1;
this.answerNodeType1.active = true;
this.answerNodeType2.active = false;
this.answerNodeType3.active = false;
}
else if(this.gameInfo.PrefabInfo[this.curSceneIndex].zhaoChaType == ZhaoChaConfig_v7.getInstance().getZhaoChaType().Type3){
answerNode = this.answerNodeType2;
this.answerNodeType1.active = false;
this.answerNodeType2.active = true;
this.answerNodeType3.active = false;
}
else if(this.gameInfo.PrefabInfo[this.curSceneIndex].zhaoChaType == ZhaoChaConfig_v7.getInstance().getZhaoChaType().Type4){
answerNode = this.answerNodeType3;
this.answerNodeType1.active = false;
this.answerNodeType2.active = false;
this.answerNodeType3.active = true;
}
for(var i=0;i<this.gameInfo.PrefabInfo[this.curSceneIndex].num;i++){
answerNode.getChildByName("xhx_"+i).active = true;
}
}
//初始化触摸监听
initMapNodeTouchEvent(delayClick){
let prefabUrl = this.gameInfo.PrefabInfo[this.curSceneIndex].prefabUrl
Common5.getPrefabFromBundle(this.subBundle,prefabUrl,this.maskNode,(prefabNode)=>{
this.mapNode = prefabNode
this.scheduleOnce(()=>{
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)
},delayClick)
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<prefabHeight){
this.mapNodeFixedScale = widthScale
}else{
this.mapNodeFixedScale = heightScale
}
this.mapNode.scale = this.mapNodeFixedScale
this.curScale = this.mapNodeFixedScale
this.lastScale = this.mapNodeFixedScale
this.oldScale = this.curScale;
this.specialNodeTouchEvent()
});
}
touchStart_mapNode(event){
Common5.playEffect("click")
if(this.touchId1 < 0){
this.touchId1 = event.touch.getID()
}else if(this.touchId2 < 0){
this.touchId2 = event.touch.getID()
}
if(this.touchId1 >= 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
}else if(touches.length == 1){ //拖动
let delta = event.getDelta()
this.mapNode.x += delta.x
this.mapNode.y += delta.y
this.goToBoundary()
}
}
touchEnd_mapNode(event){
if(Date.now() - this.touchStartTime > 0.2 * 1000){
}else{
if (this.gameInfo.PrefabInfo[this.curSceneIndex].num == 0){
this.changeScene();
}
else {
this.isFind = false;
let touchPos = event.getLocation();
this.checkIsInAreaNewVersion(touchPos)
if(!this.isFind && this.gameInfo.AddTime){
let pos = Common5.getPosInWorld_custom(this.timeNode);
pos.x = pos.x + 80;
// Common5.showTips_customTimeNew(this.gameInfo.AddTime.toString(), 0.3, pos);
// Game.ins.addTick(this.gameInfo.AddTime);
}
}
}
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
}
}
showBlack(delay){
let node = this.node.getChildByName("black")
node.active = true;
node.opacity = 0;
cc.tween(node).to(delay/2,{opacity:255}).delay(1).to(delay/2,{opacity:0}).call(()=>{
node.active = false;
}).start();
}
callSceneEnd(){
if (this.gameId == 1701){
if (this.curSceneIndex == 0){
this.mapNode.getChildByName("dianti").active = true;
}
else if (this.curSceneIndex == 1){
this.gameInfo.ChaNode[this.curSceneIndex]["xie"].isCanTouch = false;
this.mapNode.getChildByName("xiegui").active = false;
this.mapNode.getChildByName("chaDianNode").getChildByName("xie").active = false;
this.mapNode.getChildByName("changjing2dianti").getComponent(sp.Skeleton).animation = "xiaonvhai";
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"小孩开始出现时");
this.scheduleOnce(()=>{
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"叔叔,我在这住了好几年了,我帮你带路吧");
this.showSay("叔叔,我在这住了好几年了,我帮你带路吧");
this.scheduleOnce(()=>{
this.mapNode.getChildByName("changjing2dianti").getComponent(sp.Skeleton).animation = "5lou";
},3)
},3)
}
}
else if (this.gameId == 1702){
this.mapNode.getChildByName("lightOff1").active = true;
this.mapNode.getChildByName("lightOff2").active = true;
this.mapNode.getChildByName("finish").active = true;
this.mapNode.getChildByName("feiChaDianNode").getChildByName("submit").active = true;
this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn3").active = true;
this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn2").active = true;
this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn1").active = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["submit"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["btn3"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["btn2"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["btn1"].isCanTouch = true;
}
}
callSceneBegin(){
}
changeScene(){
let delay = 0;
this.callSceneEnd();
delay = this.gameInfo.PrefabInfo[this.curSceneIndex].finishDelay;
this.scheduleOnce(()=>{
if (this.gameInfo.PrefabInfo[this.curSceneIndex].finishSound && this.gameInfo.PrefabInfo[this.curSceneIndex].finishSound!=""){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+this.gameInfo.PrefabInfo[this.curSceneIndex].finishSound);
this.showSay(this.gameInfo.PrefabInfo[this.curSceneIndex].finishTaici);
}},delay)
this.scheduleOnce(()=>{
this.findTimes = 0;
let time = 4;
if (this.curSceneIndex < this.gameInfo.PrefabInfo.length-1){
this.curSceneIndex++;
this.scheduleOnce(()=>{
this.mapNode.removeFromParent();
this.init_line();
this.initKaichang();
},time/2)
this.showBlack(time);
}
else{
let timeNum = 0.1
this.scheduleOnce(()=>{
if (this.gameInfo.autoFinish){
this.endGameView(1)
}
},timeNum)
}
},delay*2)
}
//距离
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
}
}
//找到一个茬点
findOnChaDian(curNode){
let markParent = curNode
Common5.playEffect("success2")
if(this.gameInfo.PrefabInfo[this.curSceneIndex].isShowMark){
let mark = cc.instantiate(this.markSp)
mark.active = true
markParent.addChild(mark)
}
let parentNode = null
if(this.gameInfo.PrefabInfo[this.curSceneIndex].zhaoChaType == ZhaoChaConfig_v7.getInstance().getZhaoChaType().Type1){
parentNode = null
}else if(this.gameInfo.PrefabInfo[this.curSceneIndex].zhaoChaType == ZhaoChaConfig_v7.getInstance().getZhaoChaType().Type2){
parentNode = this.answerNodeType1
}
else if(this.gameInfo.PrefabInfo[this.curSceneIndex].zhaoChaType == ZhaoChaConfig_v7.getInstance().getZhaoChaType().Type3){
parentNode = this.answerNodeType2
}
else if(this.gameInfo.PrefabInfo[this.curSceneIndex].zhaoChaType == ZhaoChaConfig_v7.getInstance().getZhaoChaType().Type4){
parentNode = this.answerNodeType3
}
let childNode = parentNode.getChildByName("xhx_"+this.findTimes)
let answerIcon = cc.instantiate(curNode.getChildByName("childIcon"));
answerIcon.active = true;
answerIcon.parent = childNode
Common5.setNodeToTargetPos(answerIcon,curNode.getChildByName("childIcon"))
this.findTimes += 1
// answerIcon.scale = 0
let endDelay = 0.4
if (this.gameInfo.ChaNode[this.curSceneIndex][curNode.name].sound != ""){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+this.gameInfo.ChaNode[this.curSceneIndex][curNode.name].sound);
if (this.gameInfo.ChaNode[this.curSceneIndex][curNode.name].index){
this.showSay(this.gameInfo.ChaNode[this.curSceneIndex][curNode.name].text,true,this.gameInfo.ChaNode[this.curSceneIndex][curNode.name].index);
}
else{
this.showSay(this.gameInfo.ChaNode[this.curSceneIndex][curNode.name].text);
}
}
if(this.findTimes >= this.gameInfo.PrefabInfo[this.curSceneIndex].num){
endDelay = this.gameInfo.PrefabInfo.endDelay||1
cc.tween(answerIcon)
.to(0.4,{x:0,y:0})
.delay(endDelay)
.call(()=>{
if(!cc.isValid(childNode)){
return
}
childNode.getChildByName("desc").active = true
childNode.getChildByName("desc").getComponent(cc.Label).string = this.gameInfo.ChaNode[this.curSceneIndex][curNode.name].desc
console.log("已完成个数==",this.findTimes)
if(this.findTimes >= this.gameInfo.PrefabInfo[this.curSceneIndex].num){
console.log("完成任务===")
this.changeScene();
return
}
})
.start()
}else{
cc.tween(answerIcon)
.to(0.4,{x:0,y:0})
.call(()=>{
childNode.getChildByName("desc").active = true
childNode.getChildByName("desc").getComponent(cc.Label).string = this.gameInfo.ChaNode[this.curSceneIndex][curNode.name].desc
console.log("已完成个数==",this.findTimes)
if(this.findTimes >= this.gameInfo.PrefabInfo[this.curSceneIndex].num){
console.log("完成任务===")
this.changeScene();
return
}
})
.start()
}
this.findChaDianSpecialLogic(curNode,answerIcon)
}
//检测node是否进入target区域(新版)
checkIsInAreaNewVersion(pos){
//茬点触碰逻辑
if (this.gameInfo.PrefabInfo[this.curSceneIndex].num <= 0){
return;
}
let childrens = this.mapNode.getChildByName("chaDianNode").children;
for(var i =childrens.length-1;i>=0;i--){
let rect = childrens[i].getBoundingBoxToWorld()
if(rect.contains(pos)){
if(this.gameInfo.ChaNode[this.curSceneIndex][childrens[i].name].isFindOut){
continue
}else{
//暂不可点击
if(!this.gameInfo.ChaNode[this.curSceneIndex][childrens[i].name].isCanTouch){
continue
}
this.gameInfo.ChaNode[this.curSceneIndex][childrens[i].name].isFindOut = true
this.gameInfo.ChaNode[this.curSceneIndex][childrens[i].name].isCanTouch = false
this.findOnChaDian(childrens[i])
console.log(this.gameInfo.ChaNode[this.curSceneIndex][childrens[i].name].needHid)
if (this.gameInfo.ChaNode[this.curSceneIndex][childrens[i].name].needHid){
childrens[i].active = false;
}
this.isFind = true
}
break
}
else{
}
}
this.handSpecialGameLogic(pos)
}
//特殊节点的点击事件(主要处理节点可以移动的问题)
specialNodeTouchEvent(){
if (this.gameId == 1701){
if (this.curSceneIndex == 2){
this.openTouchEvent1(this.mapNode.getChildByName("zhengtou"));
}
}
else if (this.gameId == 1703){
this.mapNode.getChildByName("kuangquanshui")["startPos"] = this.mapNode.getChildByName("kuangquanshui").position;
this.openTouchEvent1(this.mapNode.getChildByName("kuangquanshui"));
this.mapNode.getChildByName("bangqiugun")["startPos"] = this.mapNode.getChildByName("bangqiugun").position;
this.openTouchEvent1(this.mapNode.getChildByName("bangqiugun"));
}
}
//特殊关卡处理
handSpecialGameLogic(pos){
//非茬点触碰逻辑
if(!this.mapNode.getChildByName("feiChaDianNode")){
return
}
if(this.gameId == 1701){
this.specialMap1701(pos)
}
else if (this.gameId == 1702){
this.specialMap1702(pos);
}
else if (this.gameId == 1703){
this.specialMap1703(pos);
}
}
openTouchEvent(node,attrs){
node.attr(attrs)
this.openTouchEvent1(node)
}
openMaptouch(){
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)
}
closeMaptouch(){
this.mapNode.off(cc.Node.EventType.TOUCH_START)
this.mapNode.off(cc.Node.EventType.TOUCH_MOVE)
this.mapNode.off(cc.Node.EventType.TOUCH_CANCEL)
this.mapNode.off(cc.Node.EventType.TOUCH_END)
}
openTouchEvent1(node){
node.on(cc.Node.EventType.TOUCH_START,this.touchStartSpecicalNode,this)
node.on(cc.Node.EventType.TOUCH_MOVE,this.touchMoveSpecicalNode,this)
node.on(cc.Node.EventType.TOUCH_CANCEL,this.touchEndSpecicalNode,this)
node.on(cc.Node.EventType.TOUCH_END,this.touchEndSpecicalNode,this)
}
closeTouchEvent(node){
node.off(cc.Node.EventType.TOUCH_START,this.touchStartSpecicalNode,this)
node.off(cc.Node.EventType.TOUCH_MOVE,this.touchMoveSpecicalNode,this)
node.off(cc.Node.EventType.TOUCH_CANCEL,this.touchEndSpecicalNode,this)
node.off(cc.Node.EventType.TOUCH_END,this.touchEndSpecicalNode,this)
}
touchStartSpecicalNode(event){
Common5.playEffect("click")
this.closeMaptouch();
let target = event.target;
if (target.getChildByName("show")){
target.getChildByName("show").active = true;
}
if (this.gameId == 1703){
if (target.name == "kuangquanshui"){
this.mapNode.getChildByName("dage").getComponent(sp.Skeleton).setSkin("default");
}
}
// event.target.startPos = event.target.getPosition();
// event.target.zIndex = this.curZIndex++;
}
touchMoveSpecicalNode(event){
let nodeLoc = event.getLocation()
let nodePos = event.target.parent.convertToNodeSpaceAR(nodeLoc)
event.target.setPosition(nodePos)
if (event.target["realTarget"]){
event.target["realTarget"].setPosition(nodePos)
}
}
touchEndSpecicalNode(event){
this.openMaptouch();
event.target.zIndex = 0
let target = event.target;
if (this.gameId == 1701){
if (event.target.name == "zhengtou"){
if (!Common5.checkContainsNode(this.mapNode.getChildByName("zhengtou"),this.mapNode.getChildByName("chaDianNode").getChildByName("pinganfu"))){
this.mapNode.getChildByName("zhengtou").active = false;
this.mapNode.getChildByName("chaDianNode").getChildByName("pinganfu").active = true;
this.gameInfo.ChaNode[this.curSceneIndex]["pinganfu"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["zhengtou"].isCanTouch = false;
}
}
}
else if (this.gameId == 1703){
if (target.name == "kuangquanshui"){
if (Common5.checkIntersectsBox(target,this.mapNode.getChildByName("chaDianNode").getChildByName("nanlian"))
&& this.gameInfo.ChaNode[this.curSceneIndex]["nanlian"].isCanTouch == false){
this.mapNode.getChildByName("daoshuinan").active = true;
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"泼水");
this.mapNode.getChildByName("dahan").getComponent(sp.Skeleton).animation = "daoshui";
this.scheduleOnce(()=>{
this.mapNode.getChildByName("daoshuinan").active = false;
this.gameInfo.ChaNode[this.curSceneIndex]["nanlian"].isCanTouch = true;
this.mapNode.getChildByName("dahan").getComponent(sp.Skeleton).animation = "daoshuidaiji";
this.mapNode.getChildByName("dahan")["daiji"] = "daoshuidaiji";
this.mapNode.getChildByName("dage").getComponent(sp.Skeleton).setSkin("kuangquanshui");
},2)
}
else if (Common5.checkIntersectsBox(target,this.mapNode.getChildByName("chaDianNode").getChildByName("nvlian"))
&& this.gameInfo.ChaNode[this.curSceneIndex]["nvlian"].isCanTouch == false){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"泼水");
this.mapNode.getChildByName("daoshuinv").active = true;
this.mapNode.getChildByName("dama").getComponent(sp.Skeleton).animation = "daoshui";
this.gameInfo.ChaNode[this.curSceneIndex]["nvlian"].isCanTouch = true;
this.gameInfo.ChaNode[this.curSceneIndex]["shouwan"].isCanTouch = true;
this.scheduleOnce(()=>{
this.mapNode.getChildByName("daoshuinv").active = false;
this.mapNode.getChildByName("dama").getComponent(sp.Skeleton).animation = "daoshuidaiji";
this.mapNode.getChildByName("dage").getComponent(sp.Skeleton).setSkin("kuangquanshui");
},2)
}
}
else if (target.name == "bangqiugun"){
if (Common5.checkIntersectsBox(target,this.mapNode.getChildByName("bangqiugunSpin"))){
this.mapNode.getChildByName("bangqiugunSpin").active = true;
this.mapNode.getChildByName("bangqiugun").active = false;
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"棒子打人");
this.scheduleOnce(()=>{
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"哎呀怎么还动手呢,我要告你");
this.showSay("哎呀怎么还动手呢,我要告你");
},1)
this.mapNode.getChildByName("bangqiugunSpin").getComponent(sp.Skeleton).setAnimation(0,"qiao",false)
if (this.mapNode.getChildByName("dahan")["daiji"]){
this.mapNode.getChildByName("dahan").getComponent(sp.Skeleton).animation = "xionglianbeida";
}
else{
this.mapNode.getChildByName("dahan").getComponent(sp.Skeleton).animation = "beida";
}
this.scheduleOnce(()=>{
this.mapNode.getChildByName("bangqiugun").active = true;
this.mapNode.getChildByName("bangqiugunSpin").active = false;
if (this.mapNode.getChildByName("dahan")["daiji"]){
this.mapNode.getChildByName("dahan").getComponent(sp.Skeleton).animation = "daoshuidaiji";
}
else {
this.mapNode.getChildByName("dahan").getComponent(sp.Skeleton).animation = "daiji";
}
if (this.mapNode.getChildByName("dahan")["beida"]){
this.mapNode.getChildByName("dahan")["beida"]++;
if (this.mapNode.getChildByName("dahan")["beida"] ==5){
this.mapNode.getChildByName("chaDianNode").getChildByName("shouji").active = true;
this.mapNode.getChildByName("chaDianNode").getChildByName("bangbangtang").active = true;
this.mapNode.getChildByName("chaDianNode").getChildByName("menghanyao").active = true;
this.mapNode.getChildByName("chaDianNode").getChildByName("yifu").active = true;
cc.tween(this.mapNode.getChildByName("chaDianNode").getChildByName("shouji")).by(0.5,{y:-150}).start();
cc.tween(this.mapNode.getChildByName("chaDianNode").getChildByName("bangbangtang")).by(0.5,{y:-150}).start();
cc.tween(this.mapNode.getChildByName("chaDianNode").getChildByName("menghanyao")).by(0.5,{y:-150}).start();
cc.tween(this.mapNode.getChildByName("chaDianNode").getChildByName("yifu")).by(0.5,{y:-150}).start();
this.scheduleOnce(()=>{
this.gameInfo.ChaNode[this.curSceneIndex]["shouji"].isCanTouch = true;
this.gameInfo.ChaNode[this.curSceneIndex]["bangbangtang"].isCanTouch = true;
this.gameInfo.ChaNode[this.curSceneIndex]["menghanyao"].isCanTouch = true;
this.gameInfo.ChaNode[this.curSceneIndex]["yifu"].isCanTouch = true;
},0.5)
}
}
else{
this.mapNode.getChildByName("dahan")["beida"] = 1;
}
},2)
}
}
else if (target.name == "qian"){
if (Common5.checkIntersectsBox(target,this.mapNode.getChildByName("dahan"))
|| Common5.checkIntersectsBox(target,this.mapNode.getChildByName("dama"))){
target.active = false;
this.mapNode.getChildByName("dahan").getComponent(sp.Skeleton).setAnimation(0,"taomadai",false);
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"给你给你,赶紧给我把路让开");
this.showSay("给你给你,赶紧给我把路让开");
this.scheduleOnce(()=>{
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"嘿嘿,又骗到一个");
this.showSay("嘿嘿,又骗到一个");
},3.5)
this.scheduleOnce(()=>{
this.mapNode.getChildByName("black").active = true;
cc.tween(this.mapNode.getChildByName("black")).to(0.2,{opacity:255}).delay(1).call(()=>{
this.endGameView(0)
}).start();
},4.5)
}
}
}
if(event.target.touchArea && Common5.checkContainsNode(event.target.touchArea,event.target)){
this.closeTouchEvent(event.target)
event.target.active = false
event.target.endNode && (event.target.endNode.active = true)
event.target.bindChaNodeInfo && (event.target.bindChaNodeInfo.isCanTouch = true)
event.target.callFunction && event.target.callFunction()
}else{
if (event.target.startPos){
if (target.getChildByName("show")){
target.getChildByName("show").active = false;
}
event.target.setPosition(event.target.startPos)
if (this.gameId == 1703){
if (target.name == "kuangquanshui"){
this.mapNode.getChildByName("dage").getComponent(sp.Skeleton).setSkin("kuangquanshui");
}
}
}
}
}
findChaDianSpecialLogic(curNode,answerIcon){
if (this.gameId == 1701){
if (curNode.name == "jinzhishiyong"){
this.scheduleOnce(()=>{
this.mapNode.getChildByName("changjing2dianti").getComponent(sp.Skeleton).animation = "3lou";
this.scheduleOnce(()=>{
this.gameInfo.ChaNode[this.curSceneIndex]["xie"].isCanTouch = true;
this.mapNode.getChildByName("xiegui").active = true;
this.mapNode.getChildByName("chaDianNode").getChildByName("xie").active = true;
},3.5)
this.scheduleOnce(()=>{
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"ding");
},2.5)
},2)
}
if (this.curSceneIndex == 2 && this.findTimes == 5){
this.scheduleOnce(()=>{
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"王院长,他已经在慢慢找回记忆了");
},3.5)
}
}
else if (this.gameId == 1703){
if (curNode.name == "shouwan"){
this.mapNode.getChildByName("dage").getComponent(sp.Skeleton).setAnimation(0,"zhuaxiaonvhai",false);
this.mapNode.getChildByName("dama").getComponent(sp.Skeleton).setAnimation(0,"xiaonvhaibeizhuazou",false);
this.scheduleOnce(()=>{
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"这都抓出印子了,谁家妈这么牵孩子的");
this.showSay("这都抓出印子了,谁家妈这么牵孩子的");
this.mapNode.getChildByName("dage").getComponent(sp.Skeleton).setAnimation(0,"xiaonvhaidaiji",true);
this.mapNode.getChildByName("dama").getComponent(sp.Skeleton).setAnimation(0,"damadaiji",true);
this.mapNode.getChildByName("dage")["xiaonvhai"] = true;
},1)
}
}
}
//map_1701
specialMap1701(pos){
let feiChaDianChildrens = this.mapNode.getChildByName("feiChaDianNode").children
for(var i =feiChaDianChildrens.length-1;i >= 0;i--){
//可以触摸且未触发过
if(this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name] && this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name].isCanTouch && !this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name].isTouchOff){
let rect = feiChaDianChildrens[i].getBoundingBoxToWorld()
if(rect.contains(pos)){
if (feiChaDianChildrens[i].name == "baozhiXiao"){
this.mapNode.getChildByName("chaDianNode").getChildByName("baozhi").active = true;
this.mapNode.getChildByName("feiChaDianNode").getChildByName("baozhiXiao").active = false;
this.gameInfo.ChaNode[this.curSceneIndex]["baozhi"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["baozhiXiao"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "chufentongzhiFei"){
this.mapNode.getChildByName("chaDianNode").getChildByName("chufentongzhi").active = true;
this.mapNode.getChildByName("feiChaDianNode").getChildByName("chufentongzhiFei").active = false;
this.gameInfo.ChaNode[this.curSceneIndex]["chufentongzhi"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["chufentongzhiFei"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "bingweitongzhiFei"){
this.mapNode.getChildByName("feiChaDianNode").getChildByName("bingweitongzhiFei").active = false;
this.mapNode.getChildByName("chaDianNode").getChildByName("bingweitongzhi").active = true;
this.gameInfo.ChaNode[this.curSceneIndex]["bingweitongzhi"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["bingweitongzhiFei"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "yishuFei"){
this.mapNode.getChildByName("feiChaDianNode").getChildByName("yishuFei").active = false;
this.mapNode.getChildByName("chaDianNode").getChildByName("yishu").active = true;
this.gameInfo.ChaNode[this.curSceneIndex]["yishu"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["yishuFei"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "zhengtou"){
// this.mapNode.getChildByName("zhengtou").active = false;
// this.mapNode.getChildByName("chaDianNode").getChildByName("pinganfu").active = true;
// this.gameInfo.ChaNode[this.curSceneIndex]["pinganfu"].isCanTouch = true;
// this.gameInfo.FeiChaDian[this.curSceneIndex]["zhengtou"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "guizi"){
this.mapNode.getChildByName("guiziguan").active = false;
this.mapNode.getChildByName("chaDianNode").getChildByName("maoyi").active = true;
this.mapNode.getChildByName("chaDianNode").getChildByName("naiping").active = true;
this.mapNode.getChildByName("guizikai").active = true;
this.gameInfo.ChaNode[this.curSceneIndex]["maoyi"].isCanTouch = true;
this.gameInfo.ChaNode[this.curSceneIndex]["naiping"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["guizi"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "qianbaoFei"){
this.mapNode.getChildByName("feiChaDianNode").getChildByName("qianbaoFei").active = false;
this.mapNode.getChildByName("chaDianNode").getChildByName("qianbao").active = true;
this.gameInfo.ChaNode[this.curSceneIndex]["qianbao"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["qianbaoFei"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "chuangyan"){
this.mapNode.getChildByName("feiChaDianNode").getChildByName("chuangdi").active = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["chuangdi"].isCanTouch = true;
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"叔叔,我在和妈妈躲猫猫");
this.showSay("叔叔,我在和妈妈躲猫猫");
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "chuangdi"){
this.mapNode.getChildByName("feiChaDianNode").getChildByName("chuangdi").active = false;
this.gameInfo.FeiChaDian[this.curSceneIndex]["chuangdi"].isCanTouch = false;
this.isFind = true;
}
break;
}
}
}
}
specialMap1702(pos){
let feiChaDianChildrens = this.mapNode.getChildByName("feiChaDianNode").children
for(var i =feiChaDianChildrens.length-1;i >= 0;i--){
//可以触摸且未触发过
if(this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name] && this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name].isCanTouch && !this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name].isTouchOff){
let rect = feiChaDianChildrens[i].getBoundingBoxToWorld()
if(rect.contains(pos)){
if (feiChaDianChildrens[i].name == "chuangtougui"){
this.mapNode.getChildByName("chaDianNode").getChildByName("cd2").active = true;
this.gameInfo.ChaNode[this.curSceneIndex]["cd2"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["chuangtougui"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "kaiguan"){
if (!this.mapNode.getChildByName("chaDianNode").getChildByName("cd7").active){
this.mapNode.getChildByName("chaDianNode").getChildByName("cd7").active = true;
this.mapNode.getChildByName("chaDianNode").getChildByName("cd10").active = true;
this.mapNode.getChildByName("lightOff1").active = true;
this.mapNode.getChildByName("lightOff2").active = true;
this.gameInfo.ChaNode[this.curSceneIndex]["cd7"].isCanTouch = true;
this.gameInfo.ChaNode[this.curSceneIndex]["cd10"].isCanTouch = true;
this.gameInfo.ChaNode[this.curSceneIndex]["cd9"].isCanTouch = true;
this.mapNode.getChildByName("taideng").getComponent(sp.Skeleton).animation = "shanshuo";
}
else{
this.mapNode.getChildByName("chaDianNode").getChildByName("cd7").active = false;
this.mapNode.getChildByName("chaDianNode").getChildByName("cd10").active = false;
this.gameInfo.ChaNode[this.curSceneIndex]["cd7"].isCanTouch = false;
this.gameInfo.ChaNode[this.curSceneIndex]["cd10"].isCanTouch = false;
this.gameInfo.ChaNode[this.curSceneIndex]["cd9"].isCanTouch = false;
this.mapNode.getChildByName("lightOff1").active = false;
this.mapNode.getChildByName("lightOff2").active = false;
this.mapNode.getChildByName("taideng").getComponent(sp.Skeleton).animation = "an";
}
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "guiziguan"){
this.mapNode.getChildByName("feiChaDianNode").getChildByName("guiziguan").active = false;
this.gameInfo.FeiChaDian[this.curSceneIndex]["guiziguan"].isCanTouch = false;
this.mapNode.getChildByName("guiziheren").active = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["shijuan"].isCanTouch = true;
this.gameInfo.ChaNode[this.curSceneIndex]["cd4"].isCanTouch = true;
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"妈妈,你怎么这么快就发现我了");
this.showSay("妈妈,你怎么这么快就发现我了",true,3);
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "chuangdi"){
this.mapNode.getChildByName("feiChaDianNode").getChildByName("chuangxiayouren").active = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["chuangxiayouren"].isCanTouch = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["chuangdi"].isCanTouch = false;
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"妈妈,有人占了我的床");
this.showSay("妈妈,有人占了我的床",true,2);
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "chuangxiayouren"){
this.mapNode.getChildByName("feiChaDianNode").getChildByName("chuangxiayouren").active = false;
this.gameInfo.FeiChaDian[this.curSceneIndex]["chuangxiayouren"].isCanTouch = false;
this.gameInfo.FeiChaDian[this.curSceneIndex]["chuangdi"].isCanTouch = true;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "shijuan"){
this.mapNode.getChildByName("chaDianNode").getChildByName("cd1").active = true;
this.gameInfo.FeiChaDian[this.curSceneIndex]["shijuan"].isCanTouch = false;
this.gameInfo.ChaNode[this.curSceneIndex]["cd1"].isCanTouch = true;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "submit"){
this.gameInfo.FeiChaDian[this.curSceneIndex]["submit"].isCanTouch = false;
this.scheduleOnce(()=>{
if (this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn1").getChildByName("check").active
&& this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn2").getChildByName("check").active
&& this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn3").getChildByName("check").active){
this.endGameView(1)
}
else{
this.endGameView(0)
}
},3.0)
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "btn1"){
let node = this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn1").getChildByName("check");
node.active = !node.active;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "btn2"){
let node = this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn2").getChildByName("check");
node.active = !node.active;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "btn3"){
let node = this.mapNode.getChildByName("feiChaDianNode").getChildByName("btn3").getChildByName("check");
node.active = !node.active;
this.isFind = true;
}
break;
}
}
}
}
specialMap1703(pos){
let feiChaDianChildrens = this.mapNode.getChildByName("feiChaDianNode").children
for(var i =feiChaDianChildrens.length-1;i >= 0;i--){
//可以触摸且未触发过
if(this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name] && this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name].isCanTouch && !this.gameInfo.FeiChaDian[this.curSceneIndex][feiChaDianChildrens[i].name].isTouchOff){
let rect = feiChaDianChildrens[i].getBoundingBoxToWorld()
if(rect.contains(pos)){
if (feiChaDianChildrens[i].name == "xunrenqishiFei"){
this.mapNode.getChildByName("chaDianNode").getChildByName("xunrenqishi").active = true;
this.gameInfo.ChaNode[this.curSceneIndex]["xunrenqishi"].isCanTouch = true;
this.mapNode.getChildByName("feiChaDianNode").getChildByName("xunrenqishiFei").active = false;
this.gameInfo.FeiChaDian[this.curSceneIndex]["xunrenqishiFei"].isCanTouch = false;
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "qianbao"){
if (this.mapNode.getChildByName("dage")["xiaonvhai"]){
this.mapNode.getChildByName("dage").getComponent(sp.Skeleton).setAnimation(0,"qianxiaonvhaidaiji",true);
}
else{
this.mapNode.getChildByName("dage").getComponent(sp.Skeleton).setAnimation(0,"qiandaiji",true);
}
this.gameInfo.FeiChaDian[this.curSceneIndex]["qianbao"].isCanTouch = false;
this.isFind = true;
this.mapNode.getChildByName("qian")["startPos"] = this.mapNode.getChildByName("qian").position;
this.openTouchEvent1(this.mapNode.getChildByName("qian"));
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "laohu"){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"干什么干什么,这是我猛男的标志");
this.showSay("干什么干什么,这是我猛男的标志");
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "dage"){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"走开走开,别挡老子的路");
this.showSay("走开走开,别挡老子的路");
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "dama"){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"孩子还小,不能跟着我们一起受苦呀");
this.showSay("孩子还小,不能跟着我们一起受苦呀");
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "dahan"){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"我们大人可以将就一下,孩子不行呀");
this.showSay("我们大人可以将就一下,孩子不行呀");
this.isFind = true;
}
else if (feiChaDianChildrens[i].name == "xiaonvhai"){
Common5.playEffectCustom(this.subBundle,this.gameInfo.PrefabInfo[this.curSceneIndex].soundurl+"叔叔,帮帮我吧");
this.showSay("叔叔,帮帮我吧");
this.gameInfo.FeiChaDian[this.curSceneIndex]["xiaonvhai"].isCanTouch = false;
this.isFind = true;
}
break;
}
}
}
}
closePointerClick(){
}
clickTime = 0;
oldTaiciNode = null;
showSay(text,specal?,index?){
if (specal == true){
if (this.gameId == 1702){
let taiciNode = null;
if (index == 1){
taiciNode = this.mapNode.getChildByName("say1");
}
else if (index == 2){
taiciNode = this.mapNode.getChildByName("say2");
}
else if (index == 3){
taiciNode = this.mapNode.getChildByName("say3");
}
if (taiciNode!=null){
if (this.oldTaiciNode != null){
this.oldTaiciNode.active = false;
}
this.oldTaiciNode = taiciNode;
taiciNode.active = true;
taiciNode.getChildByName("label").getComponent(cc.Label).string = text;
this.clickTime = new Date().getTime();
this.scheduleOnce(()=>{
if (new Date().getTime() - this.clickTime > 1900){
taiciNode.active = false;
}
},3);
}
}
return;
}
this.taici.node.parent.active = true;
this.taici.string = text;
this.clickTime = new Date().getTime();
this.scheduleOnce(()=>{
if (new Date().getTime() - this.clickTime > 1900){
this.taici.node.parent.active = false;
}
},4);
}
showWord(text){
this.taici.node.parent.active = true;
let length = text.length;
this.taici.string = "";
let index = 0;
this.clickTime = new Date().getTime();
this.schedule(()=>{
// Common5.playEffectCustom(this.subBundle,"ZhaoCha_Version4/commonSound/word");
},2,length*0.2/2-1,0.5);
this.schedule(()=>{
this.taici.string = this.taici.string+text[index] + " ";
index++;
},0.2,length-1,0.5);
this.scheduleOnce(()=>{
this.taici.node.parent.active = false;
},length*0.2 + 4);
}
endGameView(touchIndex) {
Game.ins.stopTime();
if (touchIndex == 0) {
if(this.isFailShow){
return
}
this.isFailShow = true
this.scheduleOnce(() => {
Game.ins.showFail();
}, 3);
} else {
if(this.isSuccessShow){
return
}
this.isSuccessShow = true
this.scheduleOnce(() => {
Game.ins.showSuccess();
},3);
}
}
}