消消方块阵换皮表情
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.
 
 
 

89 lines
3.1 KiB

import { _decorator, Component, Label, Node, Sprite } from 'cc';
import { ItemData } from '../../game/ConfigProjectData';
import MTools from 'db://assets/mx/tools/MTools';
import { SpriteLoad } from 'db://assets/mx/components/SpriteLoad';
import { GBundle, GPath, UIID } from '../../game/ConfigRes';
const { ccclass, property } = _decorator;
@ccclass('RewardGrid')
export class RewardGrid extends Component {
pinjiBg: Sprite;
icon: Sprite
num: Label
suipianNode: Node;
onLoad() {
this.pinjiBg = this.node.getChildByName('品级框')?.getComponent(Sprite);
this.icon = this.node.getChildByName('icon')?.getComponent(Sprite);
this.num = this.node.getChildByName('numLab')?.getComponent(Label);
this.suipianNode = this.node.getChildByName('碎片');
//获取
}
Data: ItemData = null;
setData(data) {
this.Data = data;
this.updateUI();
}
updateUI() {
if (this.Data.isFragment) {
//武器id需要通过转换为碎片id获取配置信息
this.suipianNode.active = false
let conf = gg.data.project.getWeaponData(this.Data.id);
let suipianId = conf.scrapId
let itemData = gg.data.table.getItemData(suipianId)
if (suipianId == 0) {
console.log('武器id不存在碎片id', this.Data.id)
return
}
this.icon.getComponent(SpriteLoad).setSprite(GPath.Item(itemData.icon), GBundle.Items);
//是否有武器
let isHaveWeapon = gg.data.project.isWeaponUnlocked(this.Data.id);
if (isHaveWeapon) {
//有武器转为碎片数量
this.suipianNode.active = true
this.num.string = 'x' + MTools.formatChineseUnit({ num: this.Data.num * itemData.transition });
} else {
//没有武器正常数量
this.suipianNode.active = false
this.num.string = 'x' + MTools.formatChineseUnit({ num: this.Data.num });
}
this.pinjiBg.getComponent(SpriteLoad).setSprite(GPath.PingjiKuang('品质' + itemData.quality), GBundle.Comm2);
} else {
let itemData = gg.data.table.getItemData(this.Data.id)
//item物品
this.num.string = 'x' + MTools.formatChineseUnit({ num: this.Data.num });
this.icon.getComponent(SpriteLoad).setSprite(GPath.Item(itemData.icon), GBundle.Items);
//更加id获取type 碎片id换武器
if (this.suipianNode) {
this.suipianNode.active = itemData.type == 10;
}
this.pinjiBg.getComponent(SpriteLoad).setSprite(GPath.PingjiKuang('品质' + itemData.quality), GBundle.Comm2);
}
}
openDetailBtnClick() {
gg.audio.playEffect({ name: "点击音效" });
if (!this.Data) {
return
}
if (this.Data.id == 1) {
return
}
//打开界面 UIID.ItemDetailBox
gg.ui.openPanel(UIID.ItemDetailBox, {
data: this.Data
})
}
}