UpStar.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { _decorator, Component, Node, Sprite, Label, SpriteFrame } from "cc";
  2. import { ResourceLoader } from "../../core/resourceManager/ResourceLoader";
  3. import { BitmapFont } from "../../core/ui/BitmapFont";
  4. import { Window } from "../../core/ui/window/Window";
  5. import { MarshalSkillSystem } from "../../marshal/MarshalSkillSystem";
  6. import { UserHero } from "../UserHeroData";
  7. const { ccclass, property, requireComponent } = _decorator;
  8. /**
  9. * 升星成功提示
  10. * @author 袁浩
  11. */
  12. @ccclass('UpStar')
  13. @requireComponent(ResourceLoader)
  14. export class UpStar extends Component {
  15. @property({ tooltip: "图标-前", type: Sprite })
  16. public avatorSpritePre: Sprite;
  17. @property({ tooltip: "图标-后", type: Sprite })
  18. public avatorSpriteNow: Sprite;
  19. @property({ tooltip: "星级-前", type: BitmapFont })
  20. public starBitmapLabelPre: BitmapFont;
  21. @property({ tooltip: "星级-后", type: BitmapFont })
  22. public starBitmapLabelNow: BitmapFont;
  23. @property({ tooltip: "攻击加成文本-前", type: Label })
  24. public attackLabelPre: Label;
  25. @property({ tooltip: "攻击加成文本-后", type: Label })
  26. public attackLabelNow: Label;
  27. @property({ tooltip: "品质框-前", type: Sprite })
  28. public qualityBorderPre: Sprite;
  29. @property({ tooltip: "品质框-后", type: Sprite })
  30. public qualityBorderNow: Sprite;
  31. @property({ tooltip: "所有品质框", type: [SpriteFrame] })
  32. public qualityBorderList: SpriteFrame[] = [];
  33. private data: UserHero;
  34. private oldStar: number;
  35. private isCanClose: boolean;
  36. start() {
  37. this.initUI();
  38. }
  39. public async initUI() {
  40. let params = this.getComponent(Window).params;
  41. this.data = params[0] as UserHero;
  42. this.oldStar = params[1] as number;
  43. this.qualityBorderPre.spriteFrame = this.qualityBorderNow.spriteFrame = this.qualityBorderList[this.data.client.color - 1];
  44. let starStringPre = "";
  45. for (let i = 0; i < this.oldStar; i++) {
  46. starStringPre += "0";
  47. }
  48. let starStringNow = "";
  49. for (let i = 0; i < this.data.server.star; i++) {
  50. starStringNow += "0";
  51. }
  52. this.starBitmapLabelPre.string = starStringPre;
  53. this.starBitmapLabelNow.string = starStringNow;
  54. this.attackLabelPre.string = `${this.data.client.attack + (this.data.server.lv - 1) * parseInt(this.data.client.upRatio.split(",")[this.oldStar - 1])}`;
  55. this.attackLabelNow.string = `${this.data.client.attack + (this.data.server.lv - 1) * parseInt(this.data.client.upRatio.split(",")[this.data.server.star - 1])}`;
  56. let avatorSpriteFrame = await this.getComponent(ResourceLoader).load<SpriteFrame>(`images/general/texture/head_img/${this.data.client.hero_res}/spriteFrame`, SpriteFrame);
  57. this.avatorSpritePre.spriteFrame = this.avatorSpriteNow.spriteFrame = avatorSpriteFrame;
  58. }
  59. private onClose(forceClose: () => void) {
  60. if (this.isCanClose) {
  61. forceClose();
  62. MarshalSkillSystem.updateMarshalSkillInfo(this.data.client.id);
  63. }
  64. }
  65. private aniCallback() {
  66. this.isCanClose = true;
  67. }
  68. }