大侠
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
2.3 KiB

//#region 文件引入
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText, SpriteFrame } from "cc";
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
import UIParse from "../../Mgr_UI/UIParse";
import { Global } from "../../Global";
import { GameTotalType } from "../../const/GameEnum";
import { IData } from "../../const/GameInterface";
//#endregion 文件引入
const {ccclass, property,menu} = _decorator;
@ccclass("needItem_Proxy")
export default class needItem_Proxy extends UIParse{
//#region 节点自动生成
@property(Sprite)
spr_bg: Sprite = null;
@property(Sprite)
spr_icon: Sprite = null;
@property(Label)
lab_name: Label = null;
@property(RichText)
ric_num: RichText = null;
@property(Label)
lab_unlock: Label = null;
//#endregion 节点自动生成
@property({type:[SpriteFrame]})
protected mBgs: SpriteFrame[] = [];
onButtonClick(button:Button){
/**点击事件触发*/
switch (button) {
default:
ConsoleEx.Log(button);
break;
}
}
setData(data: {id:number, value:number}){
const itemcfg = Global.CsvMgr.Items_csv[data.id];
if(itemcfg){
const iData:IData = {
type: GameTotalType.ITEM,
id: data.id,
num:0,
}
this.spr_bg.spriteFrame = this.mBgs[itemcfg.quality - 1];
CNodeUtils.SwitchTextureByData(this.spr_icon, iData);
CNodeUtils.switchTextByQuality(this.lab_name, itemcfg.name, itemcfg.quality);
const itemnum = this.mDataMgr.Bag.getItemCount(data.id);
const strnum = itemnum >= data.value ? `(${itemnum}/${data.value})` : `(<color=#ff0000>${itemnum}/${data.value}</color>)`;
CNodeUtils.switchRichText(this.ric_num, strnum);
const islock = itemcfg.unlock > 0 && itemcfg.unlock < 999 && this.mDataMgr.Shop.data.level < itemcfg.unlock;
CNodeUtils.switchText(this.lab_unlock, islock? `${itemcfg.unlock}级商店有售` : "");
}
}
}