import { ryw_Event } from "../../FrameWork/Event/EventEnum"; import EventMgr from "../../FrameWork/Event/EventMgr"; import User from "../../FrameWork/User/User"; import AppPlatform from "../../FrameWork/Util/AppPlatform"; import Common5 from "../../Platform/th/Common5"; import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager"; import UserManager from "../Manager/UserManager"; import PrefabManage from "../PrefabManager/PrefabManage"; const { ccclass, property } = cc._decorator; let ChadianConfig = { chadianLog0: [ { str: "帮我捶捶背吧。", qiPaoPos: 2, delay: 2.2, effectUrl: "ZhuiJiaTouZi/帮我捶捶背吧。" }, { str: "轻点!", qiPaoPos: 2, delay: 1.8, effectUrl: "ZhuiJiaTouZi/轻点!" }, { str: "舒服,太棒了!", qiPaoPos: 2, delay: 2.8, effectUrl: "ZhuiJiaTouZi/舒服,太棒了!" } ], chadianLog1: [ { str: "帮我递下浴袍!", qiPaoPos: 3, delay: 2.2, effectUrl: "ZhuiJiaTouZi/帮我递下浴袍!" }, { str: "不好意思,掉了。", qiPaoPos: -1, delay: 1.8, effectUrl: "ZhuiJiaTouZi/不好意思,掉了。" }, { str: "滚蛋!", qiPaoPos: 3, delay: 2.8, effectUrl: "ZhuiJiaTouZi/滚蛋!" } ], chadianLog2: [ { str: "哈哈,赢定了", qiPaoPos: -1, delay: 2.2, effectUrl: "ZhuiJiaTouZi/哈哈,赢定了" } ], chadianLog3: [ { str: "还挺可爱", qiPaoPos: -1, delay: 2, effectUrl: "ZhuiJiaTouZi/还挺可爱" } ], chadianLog4: [ { str: "你下去点,下去点,再下去点", qiPaoPos: -1, delay: 3, effectUrl: "ZhuiJiaTouZi/你下去点,下去点,再下去点" } ], } let JieSuoConfig = [ { index:0,zhangJieId: 3, qiPaoIndex: 3, desc: '留下来陪陪我,会有更多投资哦', soundpath:"ZhuiJiaTouZi/留下来陪陪我,会有更多投资哦", touZiMoney: 250000, jieSuoTaskId: MainTaskIdEnum.MainTask_306, Component: "Room3", spineStrArr: ['待机', '捶背舒服'] }, { index:1,zhangJieId: 5, qiPaoIndex: 1, desc: '还是有点醉,留下来陪我,给你追加投资。', soundpath:"ZhuiJiaTouZi/还是有点醉,留下来陪我,给你追加投资。" ,touZiMoney: 300000, jieSuoTaskId: MainTaskIdEnum.MainTask_505, Component: "Room3", spineStrArr: ['腿', '递浴衣'] }, { index:2,zhangJieId: 8, qiPaoIndex: 1, desc: '陪我们一起玩,给你追加投资哦。', soundpath:"ZhuiJiaTouZi/陪我们一起玩,给你追加投资哦。", touZiMoney: 2000000, jieSuoTaskId: MainTaskIdEnum.MainTask_805, Component: "DH_12", spineStrArr: ['第七幕开始', '第七幕'] }, { index:3,zhangJieId: 10, qiPaoIndex: 1, desc: '留下来陪我一起学习吧', soundpath:"ZhuiJiaTouZi/留下来陪我一起学习吧", touZiMoney: 5000000, jieSuoTaskId: MainTaskIdEnum.MainTask_1005, Component: "DH_16", spineStrArr: ['第十三幕2', '第十三幕'] }, { index:4,zhangJieId: 13, qiPaoIndex: 3, desc: '多陪陪我,我把私房钱给你。', soundpath:"ZhuiJiaTouZi/多陪陪我,我把私房钱给你。", touZiMoney: 40000000, jieSuoTaskId: MainTaskIdEnum.MainTask_1310, Component: "Room3", spineStrArr: ['待机', '击球'] }, ] @ccclass export default class ZhuiJiaTouZiQiPao extends cc.Component { @property(cc.Label) contentStr: cc.Label = null; @property(cc.Node) heiPingSpine: cc.Node = null; @property(cc.Node) beiJingNode: cc.Node = null; @property(cc.Node) spineNode: cc.Node = null; @property({ type: cc.Integer, displayName: "在JieSuoConfig的下标" }) curJieSuoConfigIndex: number = 0; // LIFE-CYCLE CALLBACKS: // onLoad () {} curConfig = null isCanClickBg: boolean = false clickBgIndex: number = 0 start() { this.initView() EventMgr.onEvent_custom(ryw_Event.updateMainTask, () => { this.initView() }, this) } initView() { let noShowIndex = [] //当前场景有多个追加投资,不是当前章节的不显示 console.log("ZhuiJiaTouZiQiPao",Common5.selectGameInfo.index + 1) for (let i = 0; i < JieSuoConfig.length; i++) { if (JieSuoConfig[i].zhangJieId == Common5.selectGameInfo.index + 1) { this.curConfig = JieSuoConfig[i] // break } else { noShowIndex.push(i) } } if (this.curConfig) { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId >= this.curConfig.jieSuoTaskId && !User.getIsZhuiJiaTouZiArr(this.curConfig.zhangJieId)) { // if (mainId >= this.curConfig.jieSuoTaskId) { this.node.active = true this.contentStr.string = this.curConfig.desc // if (this.curConfig.soundpath && this.curConfig.soundpath.length > 0) { // Common5.playRemoteAudioEffect(this.curConfig.soundpath); // } } else { this.node.active = false } } else { this.node.active = false } //当前场景有多个追加投资,不是当前章节的不显示 if (noShowIndex.includes(this.curJieSuoConfigIndex)) { this.node.active = false } //特定任务不显示 let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id let noShowTaskIds = [MainTaskIdEnum.MainTask_314,MainTaskIdEnum.MainTask_401,MainTaskIdEnum.MainTask_402] if (noShowTaskIds.includes(mainId)) { this.node.active = false } } finishCallFunc(delayTime) { this.scheduleOnce(()=>{ this.beiJingNode.active = false this.node.active = false },delayTime) } sendMoney(){ User.addIsZhuiJiaTouZiArr(this.curConfig.zhangJieId) UserManager.addMoney(this.curConfig.touZiMoney) EventMgr.emitEvent_custom(ryw_Event.ZhuiJiaTouZi) PrefabManage.showTextTips(`获得${Common5.getNumberChangeHanzi(this.curConfig.touZiMoney, '1', 1)}追加投资`) } onBtnClick() { let callFunc = () => { Common5.playEffectCustom('RoomCommon', 'sound/黑屏未知音效') this.heiPingSpine.active = true this.heiPingSpine.getComponent(sp.Skeleton).setAnimation(0, 'animation', false) this.scheduleOnce(() => { this.heiPingSpine.active = false this.beiJingNode.active = true // this.spineNode.getComponent(sp.Skeleton).setAnimation(0, this.curConfig.spineStrArr[0], true) if(this.curConfig.index == 0){ this.sendMoney() this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '待机', true) this.showQiPao(ChadianConfig.chadianLog0[0], () => { this.isCanClickBg = true this.clickBgIndex = 0 this.beiJingNode.getChildByName('手指箭头').active = true }); }else if(this.curConfig.index == 1){ this.sendMoney() this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '腿', true) this.showQiPao(ChadianConfig.chadianLog1[0], () => { this.isCanClickBg = true this.clickBgIndex = 0 this.beiJingNode.getChildByName('手指箭头').active = true }); }else if(this.curConfig.index == 2){ this.sendMoney() this.scheduleOnce(()=>{ this.showQiPao(ChadianConfig.chadianLog2[0], () => { this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '第七幕', false) this.finishCallFunc(6) }); },1.5) }else if(this.curConfig.index == 3){ this.sendMoney() this.scheduleOnce(()=>{ this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '第十三幕', true) this.showQiPao(ChadianConfig.chadianLog3[0], () => { this.finishCallFunc(3) }); },2) }else if(this.curConfig.index == 4){ this.sendMoney() this.scheduleOnce(()=>{ this.showQiPao(ChadianConfig.chadianLog4[0], () => { this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '击球', false) this.finishCallFunc(4) }); },2) } }, 2) } //第一次免费 if (this.curConfig.index == 0) { callFunc() return } let tab = { onClose: (finish) => { if (finish) { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id Common5.ReportDY("inLevel", `任务${mainId}-AD-追加投资${this.curConfig.index}`); callFunc() } else { Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab); } onBgClick() { if (this.isCanClickBg) { this.isCanClickBg = false if(this.curConfig.index == 0){ if (this.clickBgIndex == 0) { this.beiJingNode.getChildByName('手指箭头').active = false this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '捶背用力', true) this.scheduleOnce(()=>{ this.showQiPao(ChadianConfig.chadianLog0[1], () => { this.beiJingNode.getChildByName('手指箭头').active = true this.isCanClickBg = true this.clickBgIndex++ }); },1) }else if (this.clickBgIndex == 1) { this.beiJingNode.getChildByName('手指箭头').active = false this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '捶背舒服', true) this.scheduleOnce(()=>{ this.showQiPao(ChadianConfig.chadianLog0[2], () => { this.finishCallFunc(1) }); },1.5) } }else if(this.curConfig.index == 1){ if (this.clickBgIndex == 0) { this.beiJingNode.getChildByName('手指箭头').active = false this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '递浴衣', false) this.scheduleOnce(()=>{ this.spineNode.getComponent(sp.Skeleton).setAnimation(0, '待机', true) this.showQiPao(ChadianConfig.chadianLog1[1], () => { this.scheduleOnce(()=>{ this.showQiPao(ChadianConfig.chadianLog1[2], () => { this.finishCallFunc(0.1) }); },1) }); },1.5) } } } } // update (dt) {} //展示气泡 showQiPao(curLog, func?) { console.log("curLog==", curLog) if (!curLog) { console.log("xxxxxx") return; } let string_ = curLog.str let qiPaoPos_ = curLog.qiPaoPos if (qiPaoPos_ != -1) { if (curLog.effectUrl && curLog.effectUrl.length > 0) { Common5.playRemoteAudioEffect(curLog.effectUrl); } let node = this.node.parent let qiPao = node.getChildByName("qipao").getChildByName("qipao" + qiPaoPos_); qiPao.stopAllActions() this.showDialogStr(string_, qiPao.getChildByName("str")) // qiPao.getChildByName("str").getComponent(cc.Label).string = string_ qiPao.active = true qiPao.scale = 0 cc.tween(qiPao) .to(0.2, { scale: 1 }) .delay(curLog.delay) .call(() => { qiPao.active = false; if (func) { func(); } }) .start(); } else { let chatLog = this.node.parent.getChildByName('chatLog') chatLog.active = true chatLog.getChildByName("str").getComponent(cc.Label).string = string_ Common5.playRemoteAudioEffect(curLog.effectUrl); //this.showDialogStr(string_, chatLog.getChildByName("str")) chatLog.stopAllActions() cc.tween(chatLog) .delay(curLog.delay) .call(() => { chatLog.active = false; }) .start(); this.scheduleOnce(() => { func && func(); }, curLog.delay + 0.2); } } showDialogStr(str, dialogStr, finishFunc?) { let curStr = "" let curIndex = 0 let callFunc = () => { curStr += str[curIndex++] dialogStr.getComponent(cc.Label).string = curStr if (curIndex >= str.length) { finishFunc && finishFunc() } } this.schedule(callFunc, 0.07, str.length - 1) } }