| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { _decorator, Component, SpriteFrame, Sprite, Label, Node, ImageAsset, Texture2D } from 'cc';
- import { DataSystem } from '../core/data/DataSystem';
- import { ResourceLoader } from '../core/resourceManager/ResourceLoader';
- import { BitmapFont } from '../core/ui/BitmapFont';
- import { ConfigData } from '../data/ConfigData';
- import { ISJSB } from '../data/jsb/platform';
- import { PVPCardData } from './PVP';
- const { ccclass, property } = _decorator;
- @ccclass('PVPCardItem')
- export class PVPCardItem extends Component {
- @property({ type: ResourceLoader, tooltip: "资源加载器" }) res: ResourceLoader;
- @property({ tooltip: "名字", type: Label })
- public nameLabel: Label;
- @property({ tooltip: "名字背景", type: Sprite })
- public nameBg: Sprite;
- @property({ tooltip: "所有名字背景", type: [SpriteFrame] })
- public nameBgList: SpriteFrame[] = [];
- @property({ tooltip: "品质背景", type: Sprite })
- public campBg: Sprite;
- @property({ tooltip: "所有品质背景", type: [SpriteFrame] })
- public campBgList: SpriteFrame[] = [];
- @property({ tooltip: "阵营图标", type: Sprite })
- public campIcon: Sprite;
- @property({ tooltip: "所有阵营图标", type: [SpriteFrame] })
- public campIconList: SpriteFrame[] = [];
- @property({ tooltip: "品质框", type: Sprite })
- public qualityBorder: Sprite;
- @property({ tooltip: "所有品质框", type: [SpriteFrame] })
- public qualityBorderList: SpriteFrame[] = [];
- @property({ tooltip: "武将原画", type: Sprite })
- public body: Sprite;
- @property({ tooltip: "星级", type: BitmapFont })
- public starBitmapLabel: BitmapFont;
- @property({ type: Node, tooltip: "头像组" }) headGroup: Node;
- @property({ tooltip: "头像", type: Sprite }) head: Sprite;
- private generalConfig: any;
- public async setData(data: PVPCardData) {
- this.generalConfig = DataSystem.getData(ConfigData)["general"];
- let c = this.generalConfig[data.id];
- this.nameLabel.string = c.name;
- this.nameBg.spriteFrame = this.nameBgList[parseInt(c.color) - 1];
- this.campBg.spriteFrame = this.campBgList[parseInt(c.color) - 1];
- this.campIcon.spriteFrame = this.campIconList[parseInt(c.camp) - 1];
- this.qualityBorder.spriteFrame = this.qualityBorderList[parseInt(c.color) - 1];
- this.body.spriteFrame = await this.getComponent(ResourceLoader).load(`images/general/texture/hero_img/${c.hero_res}/spriteFrame`, SpriteFrame);
- let starString = "";
- for (let i = 0; i < data.star; i++) {
- starString += "0";
- }
- this.starBitmapLabel.string = starString;
- if (!!this.headGroup && !!data.url && ISJSB()) {
- let img = await this.res.loadRemote<ImageAsset>(data.url, { ext: ".png" });
- this.headGroup.active = true;
- const spriteFrame = new SpriteFrame();
- const texture = new Texture2D();
- texture.image = img;
- spriteFrame.texture = texture;
- this.head.spriteFrame = spriteFrame;
- }
- }
- }
|