import { ryw_Event } from "../../../FrameWork/Event/EventEnum"; import EventMgr from "../../../FrameWork/Event/EventMgr"; import GameReport from "../../../FrameWork/Report/ZyZyReport"; import User, { RoomBtnIndexEnum } from "../../../FrameWork/User/User"; import AppPlatform from "../../../FrameWork/Util/AppPlatform"; import Common5 from "../../../Platform/th/Common5"; import RoomCommon from "../../GameRoomRes/RoomCommon/RoomCommon"; import JuQingManager from "../../JuQingChat/JuQingManager"; import TaskInfoView from "../../JuQingChat/TaskInfoView"; import TaskManager, { MainTaskDataInfo, MainTaskIdEnum, SubTaskIdEnum } from "../../JuQingChat/TaskManager"; import JuQingQiPao from "../../JuQingGuanQia/JuQingQiPao"; import BagManager, { BagGoodsConfig, GoodsLocalProperty } from "../../Manager/BagManager"; import InterfaceManager from "../../Manager/InterfaceManager"; import UserManager from "../../Manager/UserManager"; import TaskResult from "../../MyRoom/TaskResult"; import NewGuideScript from "../../NewGuide/NewGuideScript"; import PrefabManage, { GameType } from "../../PrefabManager/PrefabManage"; import GameBase from "../../SCommon/GameBase"; import GetAward from "../../SCommon/GetAward"; const { ccclass, property } = cc._decorator; let ChadianConfig = { // chadianLog102: [ // { // str: "活没了,家也散了,给我瓶啤的", // qiPaoPos: -1, // delay: 3.3, // effectUrl: "GameMethodRes/sound/ShouHuoji/活没了,家也散了,给我瓶啤的" // }, // { // str: "不管怎样,为了你女儿的病,也得坚持下去", // qiPaoPos: 0, // delay: 3.8, // effectUrl: "GameMethodRes/sound/ShouHuoji/不管怎样,为了你女儿的病,也得坚持下去" // }, // { // str: "唉~湘菜谱调制的膳食,只能续着命", // qiPaoPos: -1, // delay: 3.9, // effectUrl: "GameMethodRes/sound/ShouHuoji/唉~湘菜谱调制的膳食,只能续着命" // }, // { // str: "不要急,我感觉,你的贵人就要出现了", // qiPaoPos: 0, // delay: 3.7, // effectUrl: "GameMethodRes/sound/ShouHuoji/不要急,我感觉,你的贵人就要出现了" // } // ], // chadianLog205: [ // { // str: "快点快点,女儿被我弄伤了,来点外伤药", // qiPaoPos: -1, // delay: 2.5, // effectUrl: "GameMethodRes/sound/ShouHuoji/快点快点,女儿被我弄伤了,来点外伤药" // }, // { // str: "那给你女儿治病的野山参,还需要吗?", // qiPaoPos: 0, // delay: 3.3, // effectUrl: "GameMethodRes/sound/ShouHuoji/那给你女儿治病的野山参,还需要吗?" // }, // { // str: "都需要,发生了好多事,以后再说", // qiPaoPos: -1, // delay: 2.1, // effectUrl: "GameMethodRes/sound/ShouHuoji/都需要,发生了好多事,以后再说" // }, // { // str: "行,你别急,最近有人联系你了吧!", // qiPaoPos: 0, // delay: 3.8, // effectUrl: "GameMethodRes/sound/ShouHuoji/行,你别急,最近有人联系你了吧!" // } // ], // chadianLog403: [ // { // str: "你这有解毒剂卖吗?", // qiPaoPos: -1, // delay: 1.5, // effectUrl: "GameMethodRes/sound/ShouHuoji/你这有解毒剂卖吗?" // }, // { // str: "解毒剂?你要这东西做什么?", // qiPaoPos: 0, // delay: 3, // effectUrl: "GameMethodRes/sound/ShouHuoji/解毒剂?你要这东西做什么?" // }, // { // str: "馆子里有人食物中毒了", // qiPaoPos: -1, // delay: 1.5, // effectUrl: "GameMethodRes/sound/ShouHuoji/馆子里有人食物中毒了" // }, // { // str: "今日活动里刚好有这个送哦!", // qiPaoPos: 0, // delay: 2.6, // effectUrl: "GameMethodRes/sound/ShouHuoji/今日活动里刚好有这个送哦!" // } // ], // chadianLog1306: [ // { // str: "我想买辆跑车,有货吗?", // qiPaoPos: -1, // delay: 3, // effectUrl: "GameMethodRes/sound/ShouHuoji/我想买辆跑车,有货吗?" // }, // { // str: "看来还是她看人准,你都可以买跑车了,有货", // qiPaoPos: 0, // delay: 3, // effectUrl: "GameMethodRes/sound/ShouHuoji/看来还是她看人准,你都可以买跑车了,有货" // } // ] } @ccclass export default class ShouHuoji extends GameBase { @property(cc.Node) huojia: cc.Node = null @property(cc.Node) tankuang: cc.Node = null @property(cc.Node) iconNode: cc.Node = null @property(cc.Slider) numSlider: cc.Slider = null @property(cc.Node) maskNode: cc.Node = null curSelectKuaiDiIndex: number = 0 adGoodsId: number = 0 buyMoney = 0 buyGoodId = 0 jifenBili = 5 maxLeng = 6 iconNum = 1 maskGuideNode: cc.Node = null onLoad() { super.onLoad() } onDestroy(): void { if (cc.isValid(this.maskGuideNode)) { this.maskGuideNode.removeFromParent() this.maskGuideNode.destroy() } super.onDestroy() EventMgr.emitEvent_custom(ryw_Event.RefreshJuQingDuiHua); } protected start(): void { // GameBaseScript.preLoadRemoteAudio(ChadianConfig); this.refrehView(false) this.duiHuaInfo() this.refreshGoodsAd() EventMgr.onEvent_custom(ryw_Event.guideShouHuoJiExit, () => { let node = this.node.getChildByName("exitRoom"); this.guideView([node]); }, this) } duiHuaInfo() { let strArr = [ '如没您中意的物品,点击进货可刷新。', '如没您中意的物品,点击进货可刷新。' ] let str = this.node.getChildByName('qiPao').getChildByName('qiPao_0').getChildByName('str') let ren = this.node.getChildByName('bg').getChildByName('商人') let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId < MainTaskIdEnum.MainTask_1702) { str.getComponent(cc.Label).string = strArr[0] ren.getComponent(sp.Skeleton).setAnimation(0, 'animation', true) } else { str.getComponent(cc.Label).string = strArr[1] ren.getComponent(sp.Skeleton).setAnimation(0, 'animation2', true) } if (mainId == MainTaskIdEnum.MainTask_202 || mainId == MainTaskIdEnum.MainTask_205) { // this.maskNode.active = true // this.showQiPao(ChadianConfig.chadianLog102[0], () => { // this.showQiPao(ChadianConfig.chadianLog102[1], () => { // this.showQiPao(ChadianConfig.chadianLog102[2], () => { // this.showQiPao(ChadianConfig.chadianLog102[3], () => { // this.maskNode.active = false let node = this.node.getChildByName('GuideNode1'); this.guideView([node]); // }); // }); // }); // }); } //else if (mainId == MainTaskIdEnum.MainTask_205) { // // this.maskNode.active = true // // this.showQiPao(ChadianConfig.chadianLog205[0], () => { // // this.showQiPao(ChadianConfig.chadianLog205[1], () => { // // this.showQiPao(ChadianConfig.chadianLog205[2], () => { // // this.showQiPao(ChadianConfig.chadianLog205[3], () => { // this.maskNode.active = false // // }); // // }); // // }); // // }); // } else if (mainId == MainTaskIdEnum.MainTask_403) { // // this.showQiPao(ChadianConfig.chadianLog403[0], () => { // // this.showQiPao(ChadianConfig.chadianLog403[1], () => { // // this.showQiPao(ChadianConfig.chadianLog403[2], () => { // // this.showQiPao(ChadianConfig.chadianLog403[3], () => { // // }); // // }); // // }); // // }); // } else if (mainId == MainTaskIdEnum.MainTask_1306) { // // this.maskNode.active = true // // this.showQiPao(ChadianConfig.chadianLog1306[0], () => { // // this.showQiPao(ChadianConfig.chadianLog1306[1], () => { // // this.maskNode.active = false // // }); // // }); // } } guideView(nodeArray) { PrefabManage.loadPrefabByType(GameType.GuideMskNode, this.node, (prefab) => { let guideNodeArray = nodeArray this.maskGuideNode = prefab let firstNode = guideNodeArray.shift() prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray) }) } refrehView(videoAD) { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let config = TaskManager.getTaskConfigById(mainTaskInfo.Id) let list = User.getShouHuoJiiList() console.log(list, 'list++++++==') if (videoAD) { list = [] } if (list.length == 0) { list.length = 0 let fixGoodList = InterfaceManager.getMangheGoodsListByType('ShouHuoJi', this.maxLeng, videoAD) let bianhaoLength = this.maxLeng//this.huojia.children.length for (var i = 0; i < bianhaoLength; i++) { let obj = { goodId: 0, saveNum: 0 } obj.goodId = fixGoodList[i].goodId let goodPro = BagManager.getGoodsProperty(obj.goodId) obj.saveNum = goodPro.saveNum list[list.length] = obj//fixGoodList[i].goodId } } //采购单中免费的物品必出(走重新刷新逻辑) if (config && config.taskCaiGouDan && config.GMGameType == "ShouHuoJi") { let caiGouDanArr = Common5.deepClone(config.taskCaiGouDan) let filteredArray = caiGouDanArr.filter(item => !config.GMGoodIdArray.includes(item)); let tempIndexTab = [] for (let i = 0; i < list.length; i++) { tempIndexTab.push(i) } for (let i = 0; i < list.length; i++) { //剔除掉已经生成的GM物品 if (config.GMGoodIdArray.indexOf(list[i].goodId) >= 0) { tempIndexTab.splice(i, 1) break } } for (let i = 0; i < filteredArray.length; i++) { if (BagManager.getBagGoodNums(filteredArray[i]) == 0) { //背包里面没有当前任务的免费物品才添加,不然当前任务的免费物品会一直刷出来 let obj = { goodId: filteredArray[i], saveNum: 1 } list[tempIndexTab[i]] = obj } } } User.setShouHuoJiiList(list) this.initKuaiDi() } refreshGoodsAd() { return this.adGoodsId = null; this.node.getChildByName('盲盒').active = false; this.node.getChildByName('bg').getChildByName('暂无').active = false; let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo(); let config = TaskManager.getTaskConfigById(mainTaskInfo.Id); if (config && config.GMGameType == "ShouHuoJi" && config.GMGoodIdArray) { for (const goodsId of config.GMGoodIdArray) { if (BagManager.getBagGoodNums(goodsId) == 0) { this.adGoodsId = goodsId; break; } } } if (this.adGoodsId) { let goodItem = this.node.getChildByName('盲盒'); goodItem.active = true; let labName = goodItem.getChildByName('name').getComponent(cc.Label); let icon = goodItem.getChildByName('icon').getComponent(cc.Sprite); let goodData = BagManager.getGoodsProperty(this.adGoodsId); labName.string = goodData.goodName; // Common5.getSpriteFrameFromBundle("GoodIcon", "icon/" + goodData.goodId, icon); Common5.setRemoteSpriteFrame(icon, 'GoodIcon/' + goodData.goodId) } else { this.node.getChildByName('bg').getChildByName('暂无').active = true; } } //初始化快递包裹 initKuaiDi() { let bianhaoLength = this.maxLeng; this.huojia.removeAllChildren(); this.huojia.destroyAllChildren(); for (var i = 0; i < bianhaoLength; i++) { let _node = cc.instantiate(this.iconNode); _node.active = true; _node.parent = this.huojia; this.huojia.children[i].on(cc.Node.EventType.TOUCH_START, this.touchStartNode, this); } this.refreshKuaiList(); } // 刷新快递列表 refreshKuaiList() { let taskCaiGouDan = []; let taskInfo: any = TaskManager.getCurUnLockMainTaskInfo(); if (taskInfo && taskInfo.Id != MainTaskIdEnum.MainTask_None) { let config = TaskManager.getTaskConfigById(taskInfo.Id); if (config && config.taskCaiGouDan) { taskCaiGouDan = config.taskCaiGouDan; } } let fixGoodList = User.getShouHuoJiiList(); for (var i = 0; i < fixGoodList.length; i++) { let goodItem = this.huojia.children[i]; let goodData = this.getDatabyGoodId(fixGoodList[i].goodId); let icon = goodItem.getChildByName('icon').getComponent(cc.Sprite); let labName = goodItem.getChildByName('labName').getComponent(cc.Label); let jifenLab = goodItem.getChildByName('lab').getComponent(cc.Label); // Common5.getSpriteFrameFromBundle("GoodIcon", "icon/" + goodData.goodId, icon); Common5.setRemoteSpriteFrame(icon, 'GoodIcon/' + goodData.goodId) labName.string = goodData.goodName; jifenLab.string = `${Common5.getNumberChangeHanzi(goodData.priceNum)}`; this.huojia.children[i].attr({ index: i, goodDataId: goodData.goodId, goodPriceNum: goodData.priceNum }); goodItem.getChildByName('购买').active = false; goodItem.getChildByName('已售罄').active = false; if (taskCaiGouDan.indexOf(fixGoodList[i].goodId) >= 0) { if (BagManager.getBagGoodNums(fixGoodList[i].goodId) <= 0) { goodItem.getChildByName('购买').active = true; } } } } getDatabyGoodId(goodid) { let fixGoodList = InterfaceManager.getFixGoodListByIndex() for (let value of fixGoodList) { if (value.goodId == goodid) { return value } } for (let value of BagGoodsConfig) { if (value.goodId == goodid) { return value } } } touchStartNode(event) { // //引导购买葡萄糖 // if (User.getGameGuideStepIndex() == 13) { // User.setGameGuideStepIndex(14) // } this.showTanKuang(event.target, false) } getUserListValue(goodId) { let list = User.getShouHuoJiiList() let valueData = null for (let i = 0; i < list.length; i++) { if (list[i].goodId == goodId) { valueData = list[i] } } return valueData } showTanKuang(target, isQuanKai) { this.reportKey(() => { GameReport.BtnsReport('物品兑换') }) // console.log(target) this.curSelectKuaiDiIndex = target.index let goodId = target.goodDataId let priceNum = target.goodPriceNum this.buyMoney = priceNum this.buyGoodId = goodId this.tankuang.active = true this.tankuang.getChildByName("mainNode").scale = 0 this.tankuang.getChildByName("mainNode").getChildByName("btn_close").active = true this.tankuang.getChildByName("mainNode").getChildByName("btn_open").active = true this.tankuang.getChildByName("mainNode").getChildByName("btn_open").getChildByName("node").getChildByName("leftTimes").getComponent(cc.Label).string = Common5.getNumberChangeHanzi(priceNum) + '' //`开启盲盒${mangHeNum}/2` this.iconNum = 1 let shuliangLab = this.tankuang.getChildByName("mainNode").getChildByName('slider').getChildByName('Handle').getChildByName("shuliangLab").getComponent(cc.Label) shuliangLab.string = '' + this.iconNum let kuaiDiXiang = this.tankuang.getChildByName("mainNode").getChildByName("spr").getComponent(cc.Sprite) let priceLab = this.tankuang.getChildByName("mainNode").getChildByName("priceLab").getComponent(cc.Label) // Common5.getSpriteFrameFromBundle("GoodIcon", "icon/" + goodId, kuaiDiXiang); Common5.setRemoteSpriteFrame(kuaiDiXiang, 'GoodIcon/' + goodId) let goodData = BagManager.getGoodsDesc(goodId) priceLab.string = '单价:' + Common5.getNumberChangeHanzi(goodData.priceNum) + '' this.tankuang.getChildByName("mainNode").getChildByName("nameLab").getComponent(cc.Label).string = goodData.goodName this.tankuang.getChildByName("mainNode").getChildByName("descLab").getComponent(cc.Label).string = goodData.descStr // jifenLab.string = Common5.getNumberChangeHanzi(goodData.priceNum)+'' let valueData = this.getUserListValue(this.buyGoodId) console.log(valueData, 'valueData+++++++++++====') this.scheduleOnce(() => { this.numSlider.progress = this.iconNum / valueData.saveNum }, 0.1) cc.tween(this.tankuang.getChildByName("mainNode")) .to(0.3, { scale: 1 }, { easing: 'elasticOut' }) .start(); let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId == MainTaskIdEnum.MainTask_202) { let node = this.tankuang.getChildByName("GuideNode2"); this.guideView([node]); Common5.ReportDY("inLevel", "任务001-开场三2点击机关盒"); } else if (mainId == MainTaskIdEnum.MainTask_205) { let node = this.tankuang.getChildByName("GuideNode2"); this.guideView([node]); } } showRaffle() { const raffleNode = this.node.getChildByName('raffleView'); raffleNode.active = true; const click = raffleNode.getChildByName('点击'); click.active = true; } // 检测任务是否完成 checkTaskFinish() { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId == MainTaskIdEnum.MainTask_202) { let isHave3001 = (BagManager.getBagGoodNums(3001) > 0) if (isHave3001) { Common5.ReportDY("inLevel", "任务001-开场三3购买机关盒"); // TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_203) // let successFunc = () => { // this.node.removeFromParent() // this.node.destroy() // JuQingManager.openJuQingOrChat('WX') // } // PrefabManage.loadPrefabByType(GameType.TaskResult, null, (prefabNode) => { // prefabNode.getComponent(TaskResult).initView1(1, true, successFunc) // }) // this.scheduleOnce(() => { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId == MainTaskIdEnum.MainTask_202) { PrefabManage.loadPrefabByType(GameType.BeiBao) // let node = this.node.getChildByName("exitRoom"); // this.guideView([node]); } this.scheduleOnce(() => { PrefabManage.loadPrefabByType(GameType.DH_1) }, 0.5) // }, 3) } } else if (mainId == MainTaskIdEnum.MainTask_205) { // let isHave = (BagManager.getBagGoodNums(3002) > 0) && (BagManager.getBagGoodNums(3003) > 0) let isHave = (BagManager.getBagGoodNums(3002) > 0) if (isHave) { Common5.ReportDY("inLevel", "任务001-开场三9购买化妆品"); User.setRoomBtnIndex(RoomBtnIndexEnum.xuexiao) TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_205) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_206) this.node.getChildByName('蒙版').active = true let node = this.node.getChildByName('蒙版').getChildByName('按钮'); this.guideView([node]); } else { // if ((BagManager.getBagGoodNums(3002) > 0)) { // this.node.getChildByName("shuaxin").getChildByName("jieSuoQiPao").active = true // } } } else if (mainId == MainTaskIdEnum.MainTask_313) { let isHave = (BagManager.getBagGoodNums(3011) > 0) if (isHave) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_313) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_314) User.setRoomBtnIndex(2) } } else if (mainId == MainTaskIdEnum.MainTask_509) { let isHave = (BagManager.getBagGoodNums(3022) > 0) && (BagManager.getBagGoodNums(3023) > 0) if (isHave) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_509) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_510) } } else if (mainId == MainTaskIdEnum.MainTask_605) { let isHave = (BagManager.getBagGoodNums(3025) > 0) && (BagManager.getBagGoodNums(3026) > 0) && (BagManager.getBagGoodNums(3027) > 0) if (isHave) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_605) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_606) User.setRoomBtnIndex(1) } } else if (mainId == MainTaskIdEnum.MainTask_703) { let isHave = (BagManager.getBagGoodNums(3028) > 0) if (isHave) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_703) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_704) User.setRoomBtnIndex(0) } } else if (mainId == MainTaskIdEnum.MainTask_903) { let isHave = (BagManager.getBagGoodNums(3041) > 0) if (isHave) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_903) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_904) } } else if (mainId == MainTaskIdEnum.MainTask_911) { let isHave = (BagManager.getBagGoodNums(3047) > 0) if (isHave) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_911) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_912) } } else if (mainId == MainTaskIdEnum.MainTask_1504) { let isHave3084 = (BagManager.getBagGoodNums(3084) > 0) let isHave3085 = (BagManager.getBagGoodNums(3085) > 0) let isHave3086 = (BagManager.getBagGoodNums(3086) > 0) let isHave3087 = (BagManager.getBagGoodNums(3087) > 0) if (this.buyGoodId == 3084) { UserManager.addMoney(50000000, this.node.getChildByName("tankuang")) } if (this.buyGoodId == 3085) { UserManager.addMoney(100000000, this.node.getChildByName("tankuang")) } if (this.buyGoodId == 3086) { UserManager.addMoney(200000000, this.node.getChildByName("tankuang")) } if (this.buyGoodId == 3087) { UserManager.addMoney(800000000, this.node.getChildByName("tankuang")) } if (isHave3084 && isHave3085 && isHave3086 && isHave3087) { BagManager.subBagList(3084, 1) BagManager.subBagList(3085, 1) BagManager.subBagList(3086, 1) BagManager.subBagList(3087, 1) // UserManager.addMoney(4000000, this.node.getChildByName("tankuang")) TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1504) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1505) } } else if (mainId == MainTaskIdEnum.MainTask_1605) { let isHave = (BagManager.getBagGoodNums(3766) > 0) if (isHave) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1605) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1701) } } else if (mainId == MainTaskIdEnum.MainTask_3002) { let isHave = (BagManager.getBagGoodNums(3813) > 0) && (BagManager.getBagGoodNums(3814) > 0) && (BagManager.getBagGoodNums(3815) > 0) if (isHave) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_3002) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_3003) } } // else if (mainId == MainTaskIdEnum.MainTask_205) { // let isHave3002 = (BagManager.getBagGoodNums(3002) > 0) // let isHave3031 = (BagManager.getBagGoodNums(3031) > 0) // let isHave3032 = (BagManager.getBagGoodNums(3032) > 0) // let isHave3033 = (BagManager.getBagGoodNums(3033) > 0) // // let isHave3034 = (BagManager.getBagGoodNums(3034) > 0) // if (isHave3002 && isHave3031 && isHave3032 && isHave3033) { // TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_205) // JuQingManager.unLockNewJuQing('WX_202') // TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_206) // } // } else if (mainId == MainTaskIdEnum.MainTask_403) { // let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan; // let IsFinish = true; // for (const goodId of taskCaiGouDan) { // if (BagManager.getBagGoodNums(goodId) == 0) { // IsFinish = false; // break; // } // } // if (IsFinish) { // TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_403); // TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_404); // User.setRoomBtnIndex(4); // } // } else if (mainId == MainTaskIdEnum.MainTask_605) { // let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan; // let IsFinish = true; // for (const goodId of taskCaiGouDan) { // if (BagManager.getBagGoodNums(goodId) == 0) { // IsFinish = false; // break; // } // } // if (IsFinish) { // TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_605); // TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_606); // User.setRoomBtnIndex(1); // } // } else if (mainId == MainTaskIdEnum.MainTask_710) { // let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan; // let IsFinish = true; // for (const goodId of taskCaiGouDan) { // if (BagManager.getBagGoodNums(goodId) == 0) { // IsFinish = false; // break; // } // } // if (IsFinish) { // TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_710); // TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_711); // } // } else if (mainId == MainTaskIdEnum.MainTask_1408) { // let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan; // let IsFinish = true; // for (const goodId of taskCaiGouDan) { // if (BagManager.getBagGoodNums(goodId) == 0) { // IsFinish = false; // break; // } // } // if (IsFinish) { // TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1408); // TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1409); // User.setRoomBtnIndex(0); // } // } else if (mainId == MainTaskIdEnum.MainTask_1306) { // let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan; // let IsFinish = true; // for (const goodId of taskCaiGouDan) { // if (BagManager.getBagGoodNums(goodId) == 0) { // IsFinish = false; // break; // } // } // if (IsFinish) { // TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1306); // JuQingManager.unLockNewJuQing('WX_1302') // TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1307); // } // } else if (mainId == MainTaskIdEnum.MainTask_1904) { // let taskCaiGouDan = TaskManager.getTaskConfigById(mainId).taskCaiGouDan; // let IsFinish = true; // for (const goodId of taskCaiGouDan) { // if (BagManager.getBagGoodNums(goodId) == 0) { // IsFinish = false; // break; // } // } // if (IsFinish) { // TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1904); // TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1905); // User.setRoomBtnIndex(0); // } // } } //展示气泡 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 let qiPao = node.getChildByName("qiPao").getChildByName("qiPao_" + qiPaoPos_); let effect = node.getChildByName("声效").getChildByName("声效" + qiPaoPos_); qiPao.stopAllActions() this.showDialogStr(string_, qiPao.getChildByName("str")) // qiPao.getChildByName("str").getComponent(cc.Label).string = string_ qiPao.active = true qiPao.scale = 0 effect.active = true cc.tween(qiPao) .to(0.2, { scale: 1 }) .delay(curLog.delay) .call(() => { qiPao.active = false; effect.active = false; if (func) { func(); } }) .start(); } else { let qiPao = this.node.getChildByName("dh_qiPao") qiPao.getComponent(JuQingQiPao).initView(curLog, func) } } 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) } onOpenBtnClick() { // Common5.playEffect("sound/按键点击") this.reportKey(() => { GameReport.BtnsReport('兑换') }) if (UserManager.getCurMoney() - this.buyMoney * this.iconNum >= 0) { UserManager.subMoney(this.buyMoney * this.iconNum); } else { PrefabManage.showTextTips("余额不足,暂不接待!!"); return; } let list = User.getShouHuoJiiList(); for (let i = 0; i < list.length; i++) { if (list[i].goodId == this.buyGoodId) { list[i].saveNum -= this.iconNum; if (list[i].saveNum <= 0) { let fixGoodList = InterfaceManager.getMangheGoodsListByType('ShouHuoJi', 1, false); let obj = { goodId: 0, saveNum: 0 } obj.goodId = fixGoodList[0].goodId; let goodPro = BagManager.getGoodsProperty(obj.goodId); obj.saveNum = goodPro.saveNum; list[i] = obj; } } } let bagConfig: GoodsLocalProperty = { goodId: this.buyGoodId, goodNum: this.iconNum, } BagManager.addBagList(bagConfig); PrefabManage.showTextTips('购买成功!'); this.tankuang.active = false; this.refreshKuaiList(); this.checkTaskFinish(); } onCloseTanKuangBtnClick() { this.tankuang.active = false } onRaffleOpen() { this.node.getChildByName("窗口").active = true; } onRaffleClose() { this.node.getChildByName("窗口").active = false; } onFreeGetThingsClick() { let tab = { onClose: (finish) => { if (finish) { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id Common5.ReportDY("inLevel", `任务${mainId}-AD-卖货郎广告获得`); let goodArray = [{ goodId: this.adGoodsId, goodNum: 1 }]; PrefabManage.loadPrefabByType(GameType.GetAward, null, (prefabNode) => { prefabNode.getComponent(GetAward).initView(goodArray, () => { this.checkTaskFinish(); this.refreshGoodsAd(); this.showRaffle(); }); }); } else { this.reportKey(() => { GameReport.ADReport('杂货铺广告获得', 0); }); Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab); } clickBuyEvent(event, data) { let valueData = this.getUserListValue(this.buyGoodId) if (data == 0) { this.iconNum-- if (this.iconNum <= 1) { this.iconNum = 1 } } else if (data == 1) { this.iconNum++ let maxNum = valueData.saveNum if (this.iconNum >= maxNum) { this.iconNum = maxNum } } this.numSlider.progress = this.iconNum / valueData.saveNum let shuliangLab = this.tankuang.getChildByName("mainNode").getChildByName('slider').getChildByName('Handle').getChildByName("shuliangLab").getComponent(cc.Label) shuliangLab.string = '' + this.iconNum let priceNum = this.iconNum * this.buyMoney this.tankuang.getChildByName("mainNode").getChildByName("btn_open").getChildByName("node").getChildByName("leftTimes").getComponent(cc.Label).string = Common5.getNumberChangeHanzi(priceNum) + '' //`开启盲盒${mangHeNum}/2` } clickSliderEvent(event, data) { console.log('clickSliderEvent') let valueData = this.getUserListValue(this.buyGoodId) let progress = this.numSlider.progress this.iconNum = Math.ceil(valueData.saveNum * progress) if (this.iconNum <= 1) { this.iconNum = 1 this.numSlider.progress = this.iconNum / valueData.saveNum } let shuliangLab = this.tankuang.getChildByName("mainNode").getChildByName('slider').getChildByName('Handle').getChildByName("shuliangLab").getComponent(cc.Label) shuliangLab.string = '' + this.iconNum let priceNum = this.iconNum * this.buyMoney this.tankuang.getChildByName("mainNode").getChildByName("btn_open").getChildByName("node").getChildByName("leftTimes").getComponent(cc.Label).string = Common5.getNumberChangeHanzi(priceNum) + '' //`开启盲盒${mangHeNum}/2` } onCliCkRaffle(event, data) { let target = event.target; target.active = false; const raffleNode = this.node.getChildByName('raffleView'); const startNode = raffleNode.getChildByName('底'); const prizes = [0.1, 100, 1, 10000, 0.5, 1000000]; const probability = [5, 20, 1, 65, 4, 5]; const angles = [60, 120, 180, 240, 300, 360]; let prizeIndex = -1; let random = Math.random() * 100; for (let index = 0; index < probability.length; index++) { random -= probability[index]; if (random < 0) { prizeIndex = index; break; } } cc.tween(startNode) .set({ angle: 0 }) .to(3, { angle: 1080 + angles[prizeIndex] }, { easing: 'quintOut' }) .call(() => { if (prizes[prizeIndex] <= 1) { let money = UserManager.getCurMoney() * prizes[prizeIndex]; UserManager.addMoney(money, startNode); } else { UserManager.addMoney(prizes[prizeIndex], startNode); } raffleNode.active = false; }) .start(); } onTouchRefresh() { let tab = { onClose: (finish) => { if (finish) { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id this.node.getChildByName("shuaxin").getChildByName("jieSuoQiPao").active = false Common5.ReportDY("inLevel", `任务${mainId}-AD-卖货郎重新进货`); this.refrehView(true) // let goodArray = [{ goodId: this.adGoodsId, goodNum: 1 }]; // PrefabManage.loadPrefabByType(GameType.GetAward, null, (prefabNode) => { // prefabNode.getComponent(GetAward).initView(goodArray, () => { // this.checkTaskFinish(); // this.refreshGoodsAd(); // this.showRaffle(); // }); // }); } else { this.reportKey(() => { GameReport.ADReport('杂货铺广告获得', 0); }); Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab); } onTouchAnNiu() { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId == MainTaskIdEnum.MainTask_206) { this.node.removeFromParent() this.node.destroy() let prefabLayer = cc.director.getScene().getChildByName("Canvas").getChildByName('prefabLayer') if (prefabLayer.getChildByName("taskInfoNode")) { prefabLayer.getChildByName("taskInfoNode").getComponent(TaskInfoView).onClose() } EventMgr.emitEvent_custom(ryw_Event.ExitBtnEvent, ''); PrefabManage.loadPrefabByType(GameType.RoomCommon, null, (prefab) => { let parentNode = prefab.getComponent(RoomCommon).getMainNode() PrefabManage.loadPrefabByType(GameType.DH_2, parentNode) }) } } }