/** * Author:shaoyang * Date:2023/03/22 * Desc:恭喜获得通用弹框 */ import GameReport from "../../FrameWork/Report/ZyZyReport"; import AppPlatform from "../../FrameWork/Util/AppPlatform"; import Common5 from "../../Platform/th/Common5"; import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager"; import BagManager, { GoodsProperty, GoodsLocalProperty } from "../Manager/BagManager"; import InterfaceManager from "../Manager/InterfaceManager"; import UserManager from "../Manager/UserManager"; import NewGuideScript from "../NewGuide/NewGuideScript"; import PrefabManage, { GameType } from "../PrefabManager/PrefabManage"; const { ccclass, property } = cc._decorator; export enum GetAward_BtnStatus { ChuShou, BeiBao, BuYao, LingQu } @ccclass export default class GetAward extends cc.Component { @property(cc.Node) lingquNode: cc.Node = null; @property(cc.Node) iconNode: cc.Node = null; @property(cc.Node) content1: cc.Node = null; @property(cc.Label) priceNum: cc.Label = null; @property(cc.Node) layOutBtn1: cc.Node = null; btnClickCallFunc = null curUiCfg: GoodsProperty = null; goodIdData = null allGoodsPrice = 0 curentContent: cc.Node = null goodIDArray = []; goodIds = null start() { this.curentContent = this.content1 } initView(goodIds, callFunc?, specialStr?) { Common5.playEffectCustom('CommonRes', 'sound/获得奖励') this.btnClickCallFunc = callFunc this.goodIdData = goodIds console.log(goodIds, 'this.allGoodsPrice++++') this.goodIds = goodIds for (let i = 0; i < goodIds.length; i++) { let data = goodIds[i] if (data.goodId == 9999) { this.allGoodsPrice += data.goodNum } else { let goodData = BagManager.getGoodsProperty(data.goodId) // console.log('goodId==,goodData==',data.goodId,goodData) this.allGoodsPrice += (data.goodNum * goodData.priceNum) } } this.showGoodsInfos(this.goodIds) this.priceNum.string = '物品价值:' + Common5.getNumberChangeHanzi(this.allGoodsPrice) if (specialStr) { this.priceNum.string = specialStr } this.node.scale = 0.1 cc.tween(this.node) .to(1.0, { scale: 1 }, { easing: 'elasticOut' }) .start() let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId == MainTaskIdEnum.MainTask_304) { let node = this.node.getChildByName("guide"); this.guideView([node]); } } guideView(nodeArray) { PrefabManage.loadPrefabByType(GameType.GuideMskNode, this.node, (prefab) => { let guideNodeArray = nodeArray let firstNode = guideNodeArray.shift() prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray) }) } refreshIconNode(node, goodsId, goodsNum) { let iconSpr = node.getChildByName('spr') let goodsNumNode = node.getChildByName('goodsNum') goodsNumNode.getComponent(cc.Label).string = goodsNum + '' // Common5.getSpriteFrameFromBundle("GoodIcon","icon/"+ goodsId, iconSpr.getComponent(cc.Sprite)); Common5.setRemoteSpriteFrame(iconSpr.getComponent(cc.Sprite), 'GoodIcon/' + goodsId) let goodsName = node.getChildByName('goodsName').getComponent(cc.Label) let goodData = BagManager.getGoodsProperty(goodsId) goodsName.string = goodData.goodName } showGoodsInfos(goodIds) { this.goodIDArray = goodIds for (let i = 0; i < goodIds.length; i++) { let data = goodIds[i] let iconNode = cc.instantiate(this.iconNode) iconNode.setPosition(cc.v2(0, 0)) iconNode.parent = this.content1 iconNode.active = true if (data.goodNum) { let goodsNum = data.goodNum this.refreshIconNode(iconNode, data.goodId, goodsNum) } else { let goodsNum = 1 this.refreshIconNode(iconNode, data, goodsNum) } } this.lingquNode.active = true } lingquClickEvent(event) { // Common5.playEffect("sound/按键点击") this.reportKey(() => { GameReport.BtnsReport('直接领取') }) let goodIds = this.goodIds for (let i = 0; i < goodIds.length; i++) { let data = goodIds[i] if (data.goodId == 9999) { let goodNum = data.goodNum UserManager.addMoney(goodNum, event.target) } else { let goodData = BagManager.getGoodsProperty(data.goodId) let _num = data.goodNum || 1 let bagConfig: GoodsLocalProperty = { goodId: goodData.goodId, goodNum: _num, } BagManager.addBagList(bagConfig) } } PrefabManage.showTextTips('物品已放入背包') this.onCloseAward() } onCloseAward() { this.node.removeFromParent() this.btnClickCallFunc && this.btnClickCallFunc() } fenxiangClickEvent() { // Common5.playEffect("sound/按键点击") } getRewardClickEvent(event) { let target = event.target // Common5.playEffect("sound/按键点击") UserManager.addMoney(this.allGoodsPrice, target) this.onCloseAward() } getDoubleRewardClickEvent(event) { let target = event.target // Common5.playEffect("sound/按键点击") let tab = { onClose: (finish) => { if (finish) { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id Common5.ReportDY("inLevel", `任务${mainId}-AD-物品奖励双倍领取`); this.reportKey(() => { GameReport.ADReport('双倍领取', 1) }) let goodIds = this.goodIds for (let i = 0; i < goodIds.length; i++) { let data = goodIds[i] if (data.goodId == 9999) { let goodNum = data.goodNum UserManager.addMoney(goodNum * 2, event.target) } else { let goodData = BagManager.getGoodsProperty(data.goodId) let _num = data.goodNum || 1 let bagConfig: GoodsLocalProperty = { goodId: goodData.goodId, goodNum: _num * 2, } BagManager.addBagList(bagConfig) } } PrefabManage.showTextTips('物品已放入背包') this.onCloseAward() } else { this.reportKey(() => { GameReport.ADReport('双倍领取', 0) }) Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab) } maichuBtnClickEvent(event, data) { let target = event.target // Common5.playEffect("sound/按键点击") if (!data || data == 0) { let goodIds = this.goodIds let allPrice = 0 this.reportKey(() => { GameReport.BtnsReport('直接卖出') }) for (let i = 0; i < goodIds.length; i++) { let data = goodIds[i] if (data.goodId == 9999) { let goodNum = data.goodNum allPrice += goodNum } else { let goodData = BagManager.getGoodsProperty(data.goodId) if (goodData) { let priceNum = goodData.priceNum allPrice += priceNum } } } UserManager.addMoney(allPrice, target) this.onCloseAward() } else { let tab = { onClose: (finish) => { if (finish) { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id Common5.ReportDY("inLevel", `任务${mainId}-AD-物品奖励双倍卖出`); let goodIds = this.goodIds let allPrice = 0 for (let i = 0; i < goodIds.length; i++) { let data = goodIds[i] if (data.goodId == 9999) { let goodNum = data.goodNum allPrice += goodNum } else { let goodData = BagManager.getGoodsProperty(data.goodId) if (goodData) { let priceNum = goodData.priceNum allPrice += priceNum } } } UserManager.addMoney(allPrice * 2, target) this.onCloseAward() } else { this.reportKey(() => { GameReport.ADReport('双倍卖出', 0) }) Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab) } } specialSave() { let goodIDArray = this.goodIDArray // for(let i = 0; i=0){ // UserManager.setShengXiaoList(data.goodId) // }else if(jinzhuanIndex>=0){ // UserManager.addGoldNum(goodsNum) // }else if(zhongziIndex>=0){ // //UserManager.addGoldNum(goodsNum) // InterfaceManager.setXuyuanDataStateZhongzi() // } // } } protected reportKey(sendCall: Function) { GameReport.SetCurGame('恭喜获得'); sendCall() } }