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.
61 lines
2.0 KiB
61 lines
2.0 KiB
|
1 week ago
|
import { _decorator, Component, Label, Node, sp, Sprite } from 'cc';
|
||
|
|
import { ItemData } from '../game/ConfigProjectData';
|
||
|
|
import { SpriteLoad } from '../../mx/components/SpriteLoad';
|
||
|
|
import { GBundle, GPath, UIID } from '../game/ConfigRes';
|
||
|
|
const { ccclass, property } = _decorator;
|
||
|
|
|
||
|
|
@ccclass('ItemGrid')
|
||
|
|
export class ItemGrid extends Component {
|
||
|
|
|
||
|
|
bgquality: Sprite = null;
|
||
|
|
icon: Sprite = null;
|
||
|
|
scrap: Sprite = null;
|
||
|
|
lbNum: Label = null;
|
||
|
|
eff: sp.Skeleton = null;
|
||
|
|
|
||
|
|
protected onLoad(): void {
|
||
|
|
this.bgquality = this.node.find("bgquality").getComponent(Sprite);
|
||
|
|
this.icon = this.node.find("icon").getComponent(Sprite);
|
||
|
|
this.scrap = this.node.find("scrap").getComponent(Sprite);
|
||
|
|
this.lbNum = this.node.find("lbNum").getComponent(Label);
|
||
|
|
this.eff = this.node.find("eff").getComponent(sp.Skeleton);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected onEnable(): void {
|
||
|
|
this.node.on(Node.EventType.TOUCH_END, this.onClick, this);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected onDisable(): void {
|
||
|
|
this.node.off(Node.EventType.TOUCH_END, this.onClick, this);
|
||
|
|
}
|
||
|
|
|
||
|
|
Data: ItemData = null;
|
||
|
|
|
||
|
|
setData(item: ItemData) {
|
||
|
|
this.Data = item;
|
||
|
|
this.updateUI();
|
||
|
|
}
|
||
|
|
|
||
|
|
updateUI() {
|
||
|
|
this.bgquality.node.getOrAddComponent(SpriteLoad).setSprite(GPath.PingjiKuang('品质' + this.Data.staticData.quality), GBundle.Comm2);
|
||
|
|
this.icon.node.getOrAddComponent(SpriteLoad).setSprite(GPath.Item(this.Data.staticData.icon), GBundle.Items);
|
||
|
|
this.lbNum.string = this.Data.num + "";
|
||
|
|
this.eff.node.active = this.Data.staticData.quality > 2;
|
||
|
|
this.scrap.node.active = [4, 11, 13].includes(this.Data.staticData.type);
|
||
|
|
if (this.eff.node.active) {
|
||
|
|
let effName = "";
|
||
|
|
if (this.Data.staticData.quality == 3) effName = "1紫色框";
|
||
|
|
if (this.Data.staticData.quality == 4) effName = "2橙色框";
|
||
|
|
this.eff.setAnimation(0, effName, true);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
onClick() {
|
||
|
|
gg.ui.openPanel(UIID.ItemDetailBox, {
|
||
|
|
data: this.Data
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|