72 lines
2.7 KiB
TypeScript
72 lines
2.7 KiB
TypeScript
import { Component, Label, Sprite, Node, SpriteFrame, _decorator, RichText } from "cc";
|
|
import { areanMgr } from "../../AreanManager";
|
|
import { ModuleDef } from "../../../../scripts/ModuleDef";
|
|
import { resLoader } from "../../../../core_tgx/base/utils/ResLoader";
|
|
import { IAreanSelectCard } from "../../../../module_basic/shared/protocols/public/arean/AreanTypeDef";
|
|
import { CommonFun } from "../../CommonFun";
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('EquipmentItem')
|
|
export class EquipmentItem extends Component {
|
|
|
|
|
|
@property(RichText)
|
|
desc: RichText;
|
|
|
|
@property(Label)
|
|
cardName: Label;
|
|
|
|
|
|
@property(Sprite)
|
|
icon: Sprite;
|
|
|
|
@property(Node)
|
|
attrList: Node;
|
|
|
|
attrCount: number = 0;
|
|
|
|
public setData(id: number) {
|
|
|
|
let data = areanMgr.cfgMgr.EquipmentData.getData(id);
|
|
this.attrCount = 0;
|
|
let sp: SpriteFrame = resLoader.getSpriteFrame("res/Image/Equip/" + data.icon, ModuleDef.Arean);
|
|
if (sp) this.icon.spriteFrame = sp;
|
|
|
|
this.cardName.string = data.name;
|
|
this.desc.string = CommonFun.getInstance().HighlightNumbers(data.describe);
|
|
|
|
this.attrList.children[0].active = false;
|
|
this.attrList.children[1].active = false;
|
|
this.attrList.children[2].active = false;
|
|
|
|
if (data.attack > 0) this.setAttrList("攻击", data.attack);
|
|
if (data.defend > 0) this.setAttrList("护甲", data.defend);
|
|
if (data.hp > 0) this.setAttrList("生命", data.hp);
|
|
if (data.maxHp > 0) this.setAttrList("最大生命", data.maxHp);
|
|
if (data.mp > 0) this.setAttrList("法力", data.mp);
|
|
if (data.maxMp > 0) this.setAttrList("最大法力", data.maxMp);
|
|
if (data.hpRecover > 0) this.setAttrList("生命回复", data.hpRecover);
|
|
if (data.mpRecover > 0) this.setAttrList("法力回复", data.mpRecover);
|
|
if (data.attackSpeed > 0) this.setAttrList("攻速", data.attackSpeed);
|
|
if (data.critical > 0) this.setAttrList("暴击", data.critical);
|
|
if (data.criticalDamage > 0) this.setAttrList("暴伤", data.criticalDamage);
|
|
if (data.dodge > 0) this.setAttrList("闪避", data.dodge);
|
|
if (data.spAttack > 0) this.setAttrList("法强", data.spAttack);
|
|
if (data.spDefend > 0) this.setAttrList("魔抗", data.spDefend);
|
|
if (data.vampire > 0) this.setAttrList("吸血", data.vampire);
|
|
if (data.shields > 0) this.setAttrList("护盾", data.shields);
|
|
}
|
|
|
|
setAttrList(attrName: string, attrValue: number) {
|
|
|
|
let item = this.attrList.children[this.attrCount];
|
|
item.getComponent(Label).string = attrName + "+" + attrValue;
|
|
item.active = true;
|
|
this.attrCount++;
|
|
|
|
}
|
|
}
|
|
|
|
|