import { ryw_Event } from "../../../FrameWork/Event/EventEnum"; import EventMgr from "../../../FrameWork/Event/EventMgr"; import GameReport from "../../../FrameWork/Report/ZyZyReport"; import User from "../../../FrameWork/User/User"; import AppPlatform from "../../../FrameWork/Util/AppPlatform"; import Common5 from "../../../Platform/th/Common5"; import JuQingManager from "../../JuQingChat/JuQingManager"; 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() } 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_102) { // 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) { if (this.maskGuideNode == null) { PrefabManage.loadPrefabByType(GameType.GuideMskNode, this.node, (prefab) => { let guideNodeArray = nodeArray this.maskGuideNode = prefab let firstNode = guideNodeArray.shift() prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray) }) } else { this.maskGuideNode.active = true let guideNodeArray = nodeArray let firstNode = guideNodeArray.shift() this.maskGuideNode.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 (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++) { let obj = { goodId: filteredArray[i], saveNum: 1 } list[tempIndexTab[i]] = obj } } User.setShouHuoJiiList(list) this.initKuaiDi() } refreshGoodsAd() { 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('blueBtn').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(); } 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_102) { let isHave3001 = (BagManager.getBagGoodNums(3057) > 0) if (isHave3001) { TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_102) TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_103) JuQingManager.unLockNewJuQing('WX_102') let successFunc = () => { this.node.removeFromParent() this.node.destroy() JuQingManager.openJuQingOrChat('WX') } PrefabManage.loadPrefabByType(GameType.TaskResult, null, (prefabNode) => { prefabNode.getComponent(TaskResult).initView1(5, true, successFunc) }) } } 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) { Common5.ReportDY("inLevel", '杂货铺-AD-广告获得'); this.reportKey(() => { GameReport.ADReport('杂货铺广告获得', 1) }) 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(); } }