//#region 文件引入 import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText } from "cc"; import BaseUIForm from "../../Mgr_UI/BaseUIForm"; import { Global } from "../../Global"; import { IData } from "../../const/GameInterface"; import { GameTotalType, PropType } from "../../const/GameEnum"; import StringUtils from "../../ExUtils/StringUtils"; import BagDataPoxy from "../../const/BagDataPoxy"; import { BagDataProxy } from "../../Mgr_LocalData/DataTypeProxy/BagDataProxy"; import { TokenDataProxy } from "../../Mgr_LocalData/DataTypeProxy/TokenDataProxy"; import UIMgr from "../../Mgr_UI/UIMgr"; import { TDAnalyticsMgr } from "../../Mgr_Ge/TDAnalyticsMgr"; import { GEData } from "../../Mgr_Ge/GeDifine"; //#endregion 文件引入 const {ccclass, property,menu} = _decorator; @ccclass("ShareUI_Proxy") export default class ShareUI_Proxy extends BaseUIForm{ //#region 节点自动生成 @property(Label) lab_share: Label = null; @property(RichText) ric_shareProgress: RichText = null; @property(Button) btn_share: Button = null; @property(Label) lab_goto: Label = null; @property(Node) n_reward_item: Node = null; @property(Sprite) spr_icon: Sprite = null; @property(Label) lab_itemname: Label = null; @property(Label) lab_item: Label = null; @property(Node) n_reward_coin: Node = null; @property(Label) lab_coin: Label = null; @property(Button) btn_get: Button = null; @property(Label) lab_get: Label = null; //#endregion 节点自动生成 private shareReward:IData[] =[{ id:18031, num:1, type:GameTotalType.ITEM },{ id:1, num:500000, type:GameTotalType.TOKEN }] protected start(): void { this.init(); } onButtonClick(button:Button){ /**点击事件触发*/ switch (button) { case this.btn_share: Global.share(()=>{ TDAnalyticsMgr.ins.TrySendtrack(GEData.GEeventName.share,"英雄令"); this.mDataMgr.Game.data.sharednum++; this.refreshBtnState(); }); break; case this.btn_get: if(BagDataProxy.Ins.haveSpace()){ BagDataProxy.Ins.addItem(this.shareReward[0].id,this.shareReward[0].num) TokenDataProxy.Ins.addToken(PropType.eGold,this.shareReward[1].num) this.mDataMgr.Game.data.shareAweardnum++; this.refreshBtnState(); UIMgr.Ins.ShowTipsUI("领取成功") } else{ UIMgr.Ins.ShowTipsUI("背包空间不足暂时无法领取奖励") } break; default: ConsoleEx.Log(button); break; } } init(){ this.refreshBtnState(); const itemcfg = Global.CsvMgr.Items_csv[this.shareReward[0].id]; if(itemcfg){ CNodeUtils.SwitchTextureByData(this.spr_icon,this.shareReward[0]); CNodeUtils.switchTextByQuality(this.lab_itemname,itemcfg.name,itemcfg.quality) CNodeUtils.switchText(this.lab_item,this.shareReward[0].num) } CNodeUtils.switchText(this.lab_coin,StringUtils.formatLargeNumber(this.shareReward[1].num)) } refreshBtnState(){ if(this.mDataMgr.Game.data.sharednum > 0){ CNodeUtils.switchRichText(this.ric_shareProgress,`(${this.mDataMgr.Game.data.sharednum}/1)`); CNodeUtils.setActive(this.btn_share, false); CNodeUtils.setActive(this.btn_get, true); if(this.mDataMgr.Game.data.shareAweardnum > 0){ CNodeUtils.switchText(this.lab_get,"已领取"); CNodeUtils.setBtnInteractable(this.btn_get,false); CNodeUtils.setChiladAllGray(this.btn_get.node,true); }else{ CNodeUtils.switchText(this.lab_get,"领取"); CNodeUtils.setBtnInteractable(this.btn_get,true); CNodeUtils.setChiladAllGray(this.btn_get.node,false); } }else{ CNodeUtils.setActive(this.btn_share, true); CNodeUtils.setActive(this.btn_get, false); CNodeUtils.switchRichText(this.ric_shareProgress,`(0/1)`); } } }