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 AppPlatform from "../../../FrameWork/Util/AppPlatform"; import Common from "../../../FrameWork/Util/Common"; import Common5 from "../../../Platform/th/Common5"; import Game from "../../../Scripts/Game"; import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript"; import DaoJiShiHProgress from "../../../WordGame/guizeGame/comScript/DaoJiShiHProgress"; // import YujiajiaolianConfig from "./YujiajiaolianConfig"; const { ccclass, property } = cc._decorator; enum GoodsIdIndex { None, YuJiaQiu, NvShengXiZao, // KaiGuiZi, MaoJinCaGan, NvShengChuanYi, ChuMen, YuJiaDian, } @ccclass export default class Yujiajiaolian extends WordGameBaseComponent { @property(cc.Node) daoJiShiProgress: cc.Node = null; //当前层级下标 curLayerIndex = 0; //当前进度 curSchedule: number = 0; //文本配置 titleArrayConfig: string[] = []; duihuaArrayConfig: any[] = []; roleFormListConfig: any[] = []; //初始化节点 girlSpineNode1: cc.Node = null touchArea1: cc.Node = null girlSpineNode2: cc.Node = null yuShiMenGuan: cc.Node = null yuShiMenKai: cc.Node = null shuiLiu: cc.Node = null yuJiaQiu: cc.Node = null yuJiaQiu2: cc.Node = null yuJiaQiu3: cc.Node = null nvShengQunZi: cc.Node = null guiZiGuan: cc.Node = null maoJin: cc.Node = null guiZiKai: cc.Node = null girlChuanYiHouSpine: cc.Node = null nanShengBeiXin: cc.Node = null nanShengSpine: cc.Node = null yaLing: cc.Node = null yuJiaDianKai: cc.Node = null yuJiaDianGuan: cc.Node = null chouTiGuan: cc.Node = null chouTiKai: cc.Node = null gangLing: cc.Node = null jiaoDai: cc.Node = null tiaoSheng: cc.Node = null tiaoSheng2: cc.Node = null yaLing2: cc.Node = null gangLing2: cc.Node = null qiXieTouchArea: cc.Node = null huaSa: cc.Node = null hongYiGirlSpineNode: cc.Node = null men: cc.Node = null yuJiaDianGuan2: cc.Node = null menTouchArea: cc.Node = null curFinishNum: number = 0 curZIndex: number = 100; protected stepIndex: number = GoodsIdIndex.YuJiaQiu//下一个步骤 shouJi: cc.Node = null kouDai: cc.Node = null start() { super.start(); DaDianScript.userEnterDaDian(); Common5.stopMusic() // this.initParameters(); // this.initComponent(); Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/YujiajiaolianConfig',(assest)=>{ //this.jsonData = JSON.stringify(assest.json) this.jsonData =assest.json this.initParameters(); this.initComponent(); } ) this.scheduleOnce(() => { this.daoJiShiProgress.getComponent(DaoJiShiHProgress).setIsStartTimer(true, { target: this, callFunc: this.hongYiNvEnterRoom }); }, 0) EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => { this.normalTouchEndCheckCallback(data_.targetNode); }, this); } //初始化参数 initParameters() { this.curSchedule = 0; // this.fireNodeInfoArray = []; this.titleArrayConfig = this.jsonData.titleArray//YujiajiaolianConfig.getInstance().getGameConfig('titleArray') as string[]; this.duihuaArrayConfig = this.jsonData.duihuaArray//YujiajiaolianConfig.getInstance().getGameConfig('duihuaArray') as any[]; this.roleFormListConfig = this.jsonData.roleFormList//YujiajiaolianConfig.getInstance().getGameConfig('roleFormList') as any[]; Common.Type = 0; Common.subLevel = 0; Common.GameSubTipConfigs = this.jsonData.tipsArray//YujiajiaolianConfig.getInstance().getGameConfig('tipsArray'); Common.GameSubAnswerConfigs = this.jsonData.answersArray//YujiajiaolianConfig.getInstance().getGameConfig('answersArray'); // EventMgr.onEvent_custom(ryw_Event.roleNodeTouchCheck, (data_) => { // this.roleNodeTouchCheckCallback(data_.targetNode); // }, this); this.girlSpineNode1 = this.node.getChildByName("mainNode").getChildByName("girlSpineNode1") this.girlSpineNode1.zIndex = 100 this.touchArea1 = this.girlSpineNode1.getChildByName("touchArea1") this.initTouchEvent(this.touchArea1, GoodsIdIndex.None, false, null, null, null); this.yuJiaQiu = this.node.getChildByName("mainNode").getChildByName("yuJiaQiu") this.yuJiaQiu2 = this.node.getChildByName("mainNode").getChildByName("yuJiaQiu2") this.yuJiaQiu3 = this.node.getChildByName("mainNode").getChildByName("yuJiaQiu3") this.initTouchEvent(this.yuJiaQiu, GoodsIdIndex.YuJiaQiu, true, this.girlSpineNode1, null, null); this.yuShiMenGuan = this.node.getChildByName("mainNode").getChildByName("yuShiMenGuan") this.yuShiMenKai = this.node.getChildByName("mainNode").getChildByName("yuShiMenKai") this.girlSpineNode2 = this.node.getChildByName("mainNode").getChildByName("girlSpineNode2") this.girlSpineNode2.zIndex = 100 this.initTouchEvent(this.girlSpineNode2, GoodsIdIndex.NvShengXiZao, true, this.yuShiMenGuan.getChildByName("touchArea4"), null, null); this.shuiLiu = this.node.getChildByName("mainNode").getChildByName("shuiLiu") this.nvShengQunZi = this.node.getChildByName("mainNode").getChildByName("nvShengQunZi") this.initTouchEvent(this.nvShengQunZi, GoodsIdIndex.NvShengChuanYi, true, this.girlSpineNode1, null, null); this.guiZiGuan = this.node.getChildByName("mainNode").getChildByName("guiZiGuan") this.maoJin = this.node.getChildByName("mainNode").getChildByName("maoJin") this.guiZiKai = this.node.getChildByName("mainNode").getChildByName("guiZiKai") this.initTouchEvent(this.guiZiGuan, GoodsIdIndex.None, false, null, null, null); this.initTouchEvent(this.maoJin, GoodsIdIndex.MaoJinCaGan, true, this.girlSpineNode1, null, null); this.girlChuanYiHouSpine = this.node.getChildByName("mainNode").getChildByName("girlChuanYiHouSpine") this.girlChuanYiHouSpine.zIndex = 100 this.nanShengBeiXin = this.node.getChildByName("mainNode").getChildByName("nanShengBeiXin") this.nanShengSpine = this.node.getChildByName("mainNode").getChildByName("nanShengSpine") this.nanShengSpine.zIndex = 100 this.initTouchEvent(this.nanShengBeiXin, GoodsIdIndex.None, true, this.nanShengSpine, null, null); this.qiXieTouchArea = this.node.getChildByName("mainNode").getChildByName("qiXieTouchArea") this.yaLing = this.node.getChildByName("mainNode").getChildByName("yaLing") this.yuJiaDianKai = this.node.getChildByName("mainNode").getChildByName("yuJiaDianKai") this.yuJiaDianGuan = this.node.getChildByName("mainNode").getChildByName("yuJiaDianGuan") this.chouTiGuan = this.node.getChildByName("mainNode").getChildByName("chouTiGuan") this.chouTiKai = this.node.getChildByName("mainNode").getChildByName("chouTiKai") this.gangLing = this.node.getChildByName("mainNode").getChildByName("gangLing") this.jiaoDai = this.node.getChildByName("mainNode").getChildByName("jiaoDai") this.tiaoSheng = this.node.getChildByName("mainNode").getChildByName("tiaoSheng") this.tiaoSheng2 = this.node.getChildByName("mainNode").getChildByName("tiaoSheng2") this.yaLing2 = this.node.getChildByName("mainNode").getChildByName("yaLing2") this.gangLing2 = this.node.getChildByName("mainNode").getChildByName("gangLing2") this.yuJiaDianGuan2 = this.node.getChildByName("mainNode").getChildByName("yuJiaDianGuan2") this.initTouchEvent(this.yuJiaDianKai, GoodsIdIndex.YuJiaDian, false, null, null, this.yuJiaDianGuan); this.initTouchEvent(this.yuJiaDianGuan, GoodsIdIndex.YuJiaDian, true, this.guiZiKai, null, this.yuJiaDianGuan2); this.initTouchEvent(this.chouTiGuan, GoodsIdIndex.None, false, null, null, null); this.initTouchEvent(this.tiaoSheng, GoodsIdIndex.None, true, this.qiXieTouchArea, null, this.tiaoSheng2); this.initTouchEvent(this.yaLing, GoodsIdIndex.None, true, this.qiXieTouchArea, null, this.yaLing2); this.initTouchEvent(this.gangLing, GoodsIdIndex.None, true, this.qiXieTouchArea, null, this.gangLing2); this.initTouchEvent(this.jiaoDai, GoodsIdIndex.None, true, this.chouTiKai, null, null); this.initTouchEvent(this.yuJiaQiu2, GoodsIdIndex.None, true, this.qiXieTouchArea, null, this.yuJiaQiu3); this.huaSa = this.node.getChildByName("mainNode").getChildByName("huaSa") this.initTouchEvent(this.huaSa, GoodsIdIndex.None, false, null, null, null); this.hongYiGirlSpineNode = this.node.getChildByName("mainNode").getChildByName("hongYiNvMaskNode").getChildByName("hongYiGirlSpineNode") this.hongYiGirlSpineNode.zIndex = 100 this.men = this.node.getChildByName("mainNode").getChildByName("men") this.initTouchEvent(this.yuJiaQiu2, GoodsIdIndex.None, true, this.qiXieTouchArea, null, this.yuJiaQiu3); this.menTouchArea = this.node.getChildByName("mainNode").getChildByName("menTouchArea") this.initTouchEvent(this.girlChuanYiHouSpine, GoodsIdIndex.ChuMen, true, this.menTouchArea, null, null); this.shouJi = this.node.getChildByName("mainNode").getChildByName("shouJi") this.shouJi.zIndex = 101 this.kouDai = this.node.getChildByName("mainNode").getChildByName("kouDai") this.kouDai.zIndex = 101 } //初始化组件 initComponent() { let lab = this.node.getChildByName("标题").getChildByName("lab"); lab.getComponent(cc.Label).string = this.titleArrayConfig[0]; // this.touchRoleNode.active = false; // this.refreshSchedule(); let title = this.titleArrayConfig[0]; Game.ins.setGameTitle(title) let addtimeNode = this.node.getChildByName("tipsBtn").getChildByName("addtimeNode"); let scr = this.daoJiShiProgress.getComponent(DaoJiShiHProgress); Common5.btnRegister_custom(addtimeNode, () => { EventMgr.emitEvent_custom(ryw_Event.showAddTimeAd); scr.setIsStartTimer(false); let tab = { onClose: (finish) => { if (finish) { scr.addTimer(60); } else { Common5.showTips_custom("广告未观看完"); } scr.setIsStartTimer(true); }, onFailed: () => { scr.setIsStartTimer(true); } } AppPlatform.playVideo_custom(tab); }) this.showQiPao(this.duihuaArrayConfig[0]) } showQiPao(curLog, func?) { console.log("curLog==", curLog); if (curLog.effectUrl) { Common5.playEffectCustom("yujiajiaolian", curLog.effectUrl); } let string_ = curLog.str let qiPaoPos_ = curLog.qiPaoPos if (qiPaoPos_ != -1) { let qiPao = this.node.getChildByName("qiPao").getChildByName("qiPao_" + qiPaoPos_); qiPao.stopAllActions() qiPao.getChildByName("str").getComponent(cc.Label).string = string_ qiPao.active = true qiPao.scale = 0 cc.tween(qiPao) .to(0.2, { scale: 1 }) .delay(3) .call(() => { qiPao.active = false if (func) { func(); } }) .start(); } else { let logPrefab = this.node.getChildByName('logPrefab') let script_: logPrefabScript = logPrefab.getComponent('logPrefabScript') script_.setDailogShow(string_) this.scheduleOnce(() => { if (func) { func(); } }, 3); } } endGameView(touchIndex) { Game.ins.stopTime(); this.scheduleOnce(() => { // this.node.getChildByName("mask").active = true; if (touchIndex == 0) { Game.ins.showFail();; } else { Game.ins.showSuccess();; } }, 3) } /** **初始化节点触摸事件 @param node 触摸对象 @param idIndex 物品id @param isCanMove 是否可以移动 @param touchArea 目标触摸区域 @param fixedArea 目标固定区域 @param changeNode //变装后 */ initTouchEvent(node: cc.Node, idIndex: number, isCanMove: boolean, touchArea: cc.Node, fixedArea: cc.Node, changeNode: cc.Node) { var attrs = { idIndex: idIndex, startPos: node.getPosition(),//初始位置 touchArea: touchArea, fixedArea: fixedArea, changeNode: changeNode, isTouch: false, isCanMove: isCanMove }; node.attr(attrs); this.openTouchEvent(node) } openTouchEvent(node) { node.on(cc.Node.EventType.TOUCH_START, this.touchStartNode, this) node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveNode, this) node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this) node.on(cc.Node.EventType.TOUCH_END, this.touchEndNode, this) } closeTouchEvent(node: cc.Node) { node.off(cc.Node.EventType.TOUCH_START, this.touchStartNode, this) node.off(cc.Node.EventType.TOUCH_MOVE, this.touchMoveNode, this) node.off(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this) node.off(cc.Node.EventType.TOUCH_END, this.touchEndNode, this) } touchStartNode(event) { Common5.playEffect("点击音效"); let target = event.target; if (event.target.name == "touchArea1") { this.showQiPao(this.duihuaArrayConfig[0]) } } touchMoveNode(event) { if (!event.target.active || !event.target.isCanMove) { return } event.target.zIndex = 200 let nodeLoc = event.getLocation() let nodePos = event.target.parent.convertToNodeSpaceAR(nodeLoc) event.target.setPosition(nodePos) } touchEndNode(event) { event.target.zIndex = 0 let target = event.target; //瑜伽球拖到美女身上 if (this.stepIndex == GoodsIdIndex.YuJiaQiu && event.target.name == "yuJiaQiu" && Common5.checkIntersectsBox(event.target, event.target.touchArea)) { Common5.playEffectCustom("yujiajiaolian", "sound/弹"); event.target.active = false this.girlSpineNode1.active = false this.girlSpineNode2.active = true this.touchArea1.active = false this.stepIndex = GoodsIdIndex.NvShengXiZao this.curFinishNum += 1 //美女去浴室洗澡 } else if (this.stepIndex == GoodsIdIndex.NvShengXiZao && event.target.name == "girlSpineNode2" && Common5.checkContainsNode(event.target.touchArea, event.target.getChildByName("touchArea2"))) { event.target.active = false this.yuShiMenGuan.active = true this.yuShiMenKai.active = false Common5.playEffectCustom("yujiajiaolian", "sound/洗澡"); cc.tween(this.node) .delay(0.8) .call(() => { event.target.zIndex = 100 this.yuJiaQiu2.active = true this.girlSpineNode1.active = true this.girlSpineNode1.getComponent(sp.Skeleton).animation = 'huxi' this.yuShiMenGuan.active = false this.yuShiMenKai.active = true this.shuiLiu.active = true this.stepIndex = GoodsIdIndex.MaoJinCaGan this.curFinishNum += 1 }) .start() //裙子拖给女生 } else if (event.target.name == "nvShengQunZi" && Common5.checkIntersectsBox(event.target, event.target.touchArea)) { if (this.stepIndex == GoodsIdIndex.MaoJinCaGan) { this.showQiPao(this.duihuaArrayConfig[1]) } else if (this.stepIndex == GoodsIdIndex.NvShengChuanYi) { this.girlChuanYiHouSpine.active = true this.girlSpineNode1.active = false event.target.active = false this.stepIndex = GoodsIdIndex.ChuMen this.curFinishNum += 1 } //点击柜子 } else if (event.target.name == "guiZiGuan") { this.closeTouchEvent(this.guiZiGuan) this.guiZiGuan.active = false this.guiZiKai.active = true this.maoJin.active = true // this.stepIndex = GoodsIdIndex.MaoJinCaGan //点击抽屉 } else if (event.target.name == "chouTiGuan" && this.jiaoDai.active) { this.chouTiGuan.active = false this.chouTiKai.active = true //毛巾擦干 } else if (this.stepIndex == GoodsIdIndex.MaoJinCaGan && event.target.name == "maoJin" && Common5.checkIntersectsBox(event.target, event.target.touchArea)) { event.target.active = false this.girlSpineNode1.getComponent(sp.Skeleton).animation = 'wushuizihuxi' this.stepIndex = GoodsIdIndex.NvShengChuanYi this.curFinishNum += 1 //男生穿衣 } else if (event.target.name == "nanShengBeiXin" && Common5.checkIntersectsBox(event.target, event.target.touchArea)) { this.nanShengSpine.getComponent(sp.Skeleton).animation = 'daiji2' event.target.active = false this.curFinishNum += 1 //器械 } else if ((event.target.name == "tiaoSheng" || event.target.name == "yaLing" || event.target.name == "gangLing" || event.target.name == "yuJiaQiu2") && Common5.checkIntersectsBox(event.target, event.target.touchArea)) { event.target.changeNode.active = true event.target.active = false this.curFinishNum += 1 //胶带 } else if (event.target.name == "jiaoDai" && this.chouTiKai.active && Common5.checkIntersectsBox(event.target, event.target.touchArea)) { event.target.active = false this.chouTiKai.active = false this.chouTiGuan.active = true this.curFinishNum += 1 //关水 } else if (event.target.name == "huaSa" && this.shuiLiu.active) { this.shuiLiu.active = false this.curFinishNum += 1 //瑜伽垫开 } else if (this.stepIndex == GoodsIdIndex.YuJiaDian && event.target.name == "yuJiaDianKai") { this.yuJiaDianKai.active = false this.yuJiaDianGuan.active = true //瑜伽垫关 } else if (this.stepIndex == GoodsIdIndex.YuJiaDian && event.target.name == "yuJiaDianGuan" && this.guiZiKai.active && Common5.checkIntersectsBox(event.target, event.target.touchArea)) { event.target.changeNode.active = false event.target.active = false this.curFinishNum += 1 this.guiZiGuan.active = true this.guiZiKai.active = false //出门 } else if (this.stepIndex == GoodsIdIndex.ChuMen && event.target.name == "girlChuanYiHouSpine" && Common5.checkIntersectsBox(event.target.getChildByName("touchArea3"), event.target.touchArea)) { event.target.active = false this.stepIndex = GoodsIdIndex.YuJiaDian this.curFinishNum += 1 this.showQiPao(this.duihuaArrayConfig[5]) } event.target.setPosition(event.target.startPos) } normalTouchEndCheckCallback(targetNode: any) { if (targetNode.name == "关闭手机") { console.log("关闭手机") this.curFinishNum += 1 } } hongYiNvEnterRoom() { Common5.playEffectCustom("yujiajiaolian", "sound/开门"); this.men.active = false cc.tween(this.hongYiGirlSpineNode) .to(0.8, { x: 50 }) .call(() => { this.men.active = true console.log("this.curFinishNum==", this.curFinishNum) if (this.curFinishNum >= 14) { this.showQiPao(this.duihuaArrayConfig[2]) this.endGameView(1) } else { if (this.girlChuanYiHouSpine.active) { this.showQiPao(this.duihuaArrayConfig[3]) } else { this.showQiPao(this.duihuaArrayConfig[4]) } this.endGameView(0) } }) .start() } onClick(event) { let target = event.target; console.log("+++++++++++++++++++>" + target.name); Common5.playEffect("点击音效"); switch (target.name) { case "button": target.active = false; // this.endGameAnima(); let scr = this.daoJiShiProgress.getComponent(DaoJiShiHProgress); scr.setIsStartTimer(false); this.node.getChildByName("mask").active = true; this.hongYiNvEnterRoom() break; default: break; } } }