83 lines
2.2 KiB
TypeScript
83 lines
2.2 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('CardItem')
|
|
export class CardItem extends Component {
|
|
@property(Label)
|
|
cost: Label;
|
|
|
|
@property(Sprite)
|
|
rare: Sprite;
|
|
|
|
@property(RichText)
|
|
desc: RichText;
|
|
|
|
@property(Label)
|
|
cardName: Label;
|
|
|
|
@property(Node)
|
|
typeList: Node;
|
|
|
|
@property(Node)
|
|
starNode: Node;
|
|
|
|
|
|
@property(Node)
|
|
costBg: Node;
|
|
|
|
@property(Node)
|
|
mask: Node;
|
|
|
|
@property(Sprite)
|
|
icon: Sprite;
|
|
|
|
|
|
|
|
public setData(item: IAreanSelectCard) {
|
|
|
|
let data = areanMgr.cfgMgr.CardDatas.getData(item.id);
|
|
//this.cost.string = item.cost.toString();
|
|
|
|
|
|
|
|
let sp: SpriteFrame = resLoader.getSpriteFrame("res/Image/cardRare/rare" + data.cardRare, ModuleDef.Arean);
|
|
if (sp) this.rare.spriteFrame = sp;
|
|
|
|
sp = resLoader.getSpriteFrame("res/Image/skill/" + data.icon, ModuleDef.Arean);
|
|
if (sp) this.icon.spriteFrame = sp;
|
|
|
|
this.cardName.string = data.mainName;
|
|
this.desc.string = CommonFun.getInstance().HighlightNumbers(data.skillDescribe);
|
|
this.cost.string = item.cost.toString()
|
|
//this.cost.node.active = !item.purchase;
|
|
this.costBg.active = !item.purchase;
|
|
this.mask.active = item.purchase;
|
|
|
|
|
|
for (let i = 0; i < this.costBg.children.length; i++) {
|
|
this.costBg.children[i].active = false;
|
|
}
|
|
this.costBg.getChildByName("cost" + item.cost).active = true;
|
|
|
|
|
|
this.typeList.getChildByName("type2").active = data.Sect.length == 2;
|
|
for (let i = 0; i < data.Sect.length; i++) {
|
|
let sp: SpriteFrame = resLoader.getSpriteFrame("res/Image/sect/sect" + data.Sect[i], ModuleDef.Arean);
|
|
if (sp) this.typeList.children[i].getChildByName("icon").getComponent(Sprite).spriteFrame = sp;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|