//#region 文件引入 import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText } from "cc"; import BaseUIForm from "../../Mgr_UI/BaseUIForm"; import FrameLayout from "../../CComEx/FrameLayout"; import needItem_Proxy from "../General/needItem_Proxy"; import BuildDataPoxy from "../../const/BuildDataPoxy"; import UIMgr from "../../Mgr_UI/UIMgr"; import { EUIForms } from "../../const/UIFormCnf"; import { Global } from "../../Global"; import StringUtils from "../../ExUtils/StringUtils"; import { PropType } from "../../const/GameEnum"; import { COLOR_PARAMS } from "../../const/GGameData"; import { TDAnalyticsMgr } from "../../Mgr_Ge/TDAnalyticsMgr"; import { GEData } from "../../Mgr_Ge/GeDifine"; //#endregion 文件引入 const {ccclass, property,menu} = _decorator; @ccclass("PopBuildLvUpUI_Proxy") export default class PopBuildLvUpUI_Proxy extends BaseUIForm{ //#region 节点自动生成 @property(Label) lab_title: Label = null; @property(Label) lab_addcoin: Label = null; @property(Button) btn_lvup: Button = null; @property(Label) lab_uplvcoin: Label = null; //#endregion 节点自动生成 @property(FrameLayout) private mItemLayout: FrameLayout; // 升级材料列表 private mConfig = null; private mData:BuildDataPoxy = null; onButtonClick(button:Button){ /**点击事件触发*/ switch (button) { case this.btn_lvup: if(this.mData && this.mDataMgr.Build.upLevel(this.mData.type)){ UIMgr.Ins.ShowTipsUI(`升级${this.mConfig.name}成功`); this.param && this.param.success && this.param.success(); TDAnalyticsMgr.ins.TrySendtrack(GEData.GEeventName.Market,{marketdetails: this.mData.config.name, marketgrade: this.mData.level}); this.CloseUI(); } default: ConsoleEx.Log(button); break; } } protected start(): void { this.mData = this.param ? this.param.bData : null; if(this.mData){ this.mConfig = Global.CsvMgr.Builds_csv[this.mData.type]; CNodeUtils.switchText(this.lab_title, `升级${this.mConfig.name}`); CNodeUtils.switchText(this.lab_addcoin, `+${this.mData.add}两/秒`); const enough = this.mDataMgr.Token.checkToken(PropType.eGold, this.mData.upgradeCost); this.lab_uplvcoin.color = enough? COLOR_PARAMS.BLACK:COLOR_PARAMS.RED; CNodeUtils.switchText(this.lab_uplvcoin, `${StringUtils.formatLargeNumber(this.mData.upgradeCost)}`); this.mItemLayout.m_ItemCount = this.mData.materials.length; } } addEvent(): void { this.mItemLayout.m_ItemRendererFuntion = this.ItemRenderer.bind(this) } ItemRenderer(idx: number, tNode: Node) { const iteminfo = this.mData.upMaterList[idx]; const ClassPoxy: needItem_Proxy = tNode.getComponent(needItem_Proxy); ClassPoxy.setData(iteminfo); CNodeUtils.addBtnComponent(tNode, this.ItemClick.bind(this, iteminfo.id), this); } private ItemClick(id: number) { UIMgr.Ins.ShowUI(EUIForms.ShopInfoUI, { param: {id: id, style: "small"} }); } }