| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import { _decorator, Component, Node, Sprite, Label, SpriteFrame } from 'cc';
- import { DataSystem } from '../../core/data/DataSystem';
- import { HttpSystem } from '../../core/net/HttpSystem';
- import { ResourceLoader } from '../../core/resourceManager/ResourceLoader';
- import { platform } from '../../data/jsb/platform';
- import { UserData } from '../../data/UserData';
- import { Hero_Client, UserHeroData } from '../../hero/UserHeroData';
- import { RecruitResultData } from '../RecruitData';
- const { ccclass, property } = _decorator;
- /**
- * 招募展示项item
- * @author 郑聂华
- */
- @ccclass('RecruitResultItem')
- export class RecruitResultItem extends Component {
- @property({ type: ResourceLoader, displayName: "资源加载组件", tooltip: "资源加载组件" }) res: ResourceLoader = null;
- @property({ type: Sprite, displayName: "品质框", tooltip: "品质框" }) bgQuality: Sprite = null;
- @property({ type: Sprite, displayName: "武将头像", tooltip: "武将头像" }) imgHero: Sprite = null;
- @property({ type: [Node], displayName: "星级", tooltip: "星级" }) stars: Node[] = [];
- @property({ type: Label, displayName: "文本_名称", tooltip: "文本_名称" }) txtName: Label = null;
- @property({ type: Sprite, displayName: "阵营", tooltip: "阵营" }) imgCamp: Sprite = null;
- @property({ type: Node, displayName: "碎片", tooltip: "碎片" }) slice: Node = null;
- async Init(hero: Hero_Client, drawData: RecruitResultData) {
- this.txtName.string = hero.name + "";//碎片判断
- this.setStar(hero.initStar);
- this.slice.active = drawData.type == 2;
- if (drawData.type == 1) this.txtName.string = hero.name + (drawData.heroNum > 1 ? "x" + drawData.heroNum : "");
- else this.txtName.string = hero.name + "碎片x" + drawData.sliceNum;
- this.bgQuality.spriteFrame = await this.res.load<SpriteFrame>("images/general/texture/zy_head" + hero.color + "/spriteFrame", SpriteFrame);
- this.imgHero.spriteFrame = await this.res.load<SpriteFrame>("images/general/texture/head_img/" + hero.hero_res + "/spriteFrame", SpriteFrame);
- this.imgCamp.spriteFrame = await this.res.load<SpriteFrame>("images/general/texture/icon_camp_" + hero.camp + "/spriteFrame", SpriteFrame);
- }
- setStar(starNum: number) {
- for (let i = 0; i < this.stars.length; i++) {
- this.stars[i].active = (i + 1) <= starNum;
- }
- }
- }
|