//#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 { Global } from "../../Global"; import needItem_Proxy from "./needItem_Proxy"; import { PropType } from "../../const/GameEnum"; import { COLOR_PARAMS } from "../../const/GGameData"; //#endregion 文件引入 const {ccclass, property,menu} = _decorator; @ccclass("PopBgLvUpUI_Proxy") export default class PopBgLvUpUI_Proxy extends BaseUIForm{ //#region 节点自动生成 @property(Label) lab_offline_time: Label = null; @property(Label) lab_coin: Label = null; @property(Button) btn_lvup: Button = null; //#endregion 节点自动生成 @property(FrameLayout) private mItemLayout: FrameLayout; // 升级材料列表 private mMaterials = []; onButtonClick(button:Button){ /**点击事件触发*/ switch (button) { case this.btn_lvup: this.CloseUI(); this.param && this.param.okcallback && this.param.okcallback(); break; default: ConsoleEx.Log(button); break; } } addEvent(): void { this.mItemLayout.m_ItemRendererFuntion = this.ItemRenderer.bind(this) } ItemRenderer(idx: number, tNode: Node) { const iteminfo = this.mMaterials[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) { ConsoleEx.Log("点击物品id: " + id); // const itemcfg = Global.CsvMgr.Items_csv[id]; } protected start(): void { const cost = this.mDataMgr.Bag.bagDataPoxy.uplevelcost; const success = this.mDataMgr.Token.checkToken(PropType.eGold, cost); this.lab_coin.color = success? COLOR_PARAMS.BLACK : COLOR_PARAMS.RED; CNodeUtils.switchText(this.lab_coin, cost); this.mMaterials = this.mDataMgr.Bag.bagDataPoxy.materials; this.mItemLayout.m_ItemCount = this.mMaterials.length; } }