RecruitResultItem.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { _decorator, Component, Node, Sprite, Label, SpriteFrame } from 'cc';
  2. import { DataSystem } from '../../core/data/DataSystem';
  3. import { HttpSystem } from '../../core/net/HttpSystem';
  4. import { ResourceLoader } from '../../core/resourceManager/ResourceLoader';
  5. import { platform } from '../../data/jsb/platform';
  6. import { UserData } from '../../data/UserData';
  7. import { Hero_Client, UserHeroData } from '../../hero/UserHeroData';
  8. import { RecruitResultData } from '../RecruitData';
  9. const { ccclass, property } = _decorator;
  10. /**
  11. * 招募展示项item
  12. * @author 郑聂华
  13. */
  14. @ccclass('RecruitResultItem')
  15. export class RecruitResultItem extends Component {
  16. @property({ type: ResourceLoader, displayName: "资源加载组件", tooltip: "资源加载组件" }) res: ResourceLoader = null;
  17. @property({ type: Sprite, displayName: "品质框", tooltip: "品质框" }) bgQuality: Sprite = null;
  18. @property({ type: Sprite, displayName: "武将头像", tooltip: "武将头像" }) imgHero: Sprite = null;
  19. @property({ type: [Node], displayName: "星级", tooltip: "星级" }) stars: Node[] = [];
  20. @property({ type: Label, displayName: "文本_名称", tooltip: "文本_名称" }) txtName: Label = null;
  21. @property({ type: Sprite, displayName: "阵营", tooltip: "阵营" }) imgCamp: Sprite = null;
  22. @property({ type: Node, displayName: "碎片", tooltip: "碎片" }) slice: Node = null;
  23. async Init(hero: Hero_Client, drawData: RecruitResultData) {
  24. this.txtName.string = hero.name + "";//碎片判断
  25. this.setStar(hero.initStar);
  26. this.slice.active = drawData.type == 2;
  27. if (drawData.type == 1) this.txtName.string = hero.name + (drawData.heroNum > 1 ? "x" + drawData.heroNum : "");
  28. else this.txtName.string = hero.name + "碎片x" + drawData.sliceNum;
  29. this.bgQuality.spriteFrame = await this.res.load<SpriteFrame>("images/general/texture/zy_head" + hero.color + "/spriteFrame", SpriteFrame);
  30. this.imgHero.spriteFrame = await this.res.load<SpriteFrame>("images/general/texture/head_img/" + hero.hero_res + "/spriteFrame", SpriteFrame);
  31. this.imgCamp.spriteFrame = await this.res.load<SpriteFrame>("images/general/texture/icon_camp_" + hero.camp + "/spriteFrame", SpriteFrame);
  32. }
  33. setStar(starNum: number) {
  34. for (let i = 0; i < this.stars.length; i++) {
  35. this.stars[i].active = (i + 1) <= starNum;
  36. }
  37. }
  38. }