MarshalSkillNoticeUI.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { _decorator, Component, Node, Sprite, Label, SpriteFrame } from 'cc';
  2. import { DataSystem } from '../../core/data/DataSystem';
  3. import { ResourceLoader } from '../../core/resourceManager/ResourceLoader';
  4. import { Window } from '../../core/ui/window/Window';
  5. import { WindowOpenMode } from '../../core/ui/window/WindowOpenMode';
  6. import { WindowSystem } from '../../core/ui/window/WindowSystem';
  7. import { MarshalData } from '../MarshalData';
  8. const { ccclass, property } = _decorator;
  9. /**
  10. * 统帅技能解锁和升级小弹窗
  11. * @author 郑聂华
  12. */
  13. @ccclass('MarshalSkillNotice')
  14. export class MarshalSkillNoticeUI extends Component {
  15. @property({ type: ResourceLoader, displayName: "资源加载组件", tooltip: "资源加载组件" }) res: ResourceLoader = null;
  16. @property({ type: Node, displayName: "技能解锁节点" }) nodeSkillUnlock: Node = null;
  17. @property({ type: Node, displayName: "技能升级节点" }) nodeSkillLvUp: Node = null;
  18. @property({ type: Sprite, displayName: "技能头像" }) imgSkill: Sprite = null;
  19. @property({ type: Label, displayName: "文本_解锁后技能等级" }) txtLvUnlock: Label = null;
  20. @property({ type: Label, displayName: "文本_升级前技能等级" }) txtLvUpLast: Label = null;
  21. @property({ type: Label, displayName: "文本_升级后技能等级" }) txtLvUpCur: Label = null;
  22. @property({ type: Label, displayName: "文本_技能名" }) txtSkillName: Label = null;
  23. @property({ type: Label, displayName: "计时器" }) txtTime: Label = null;
  24. private timer: number = 10;
  25. /**
  26. * 打开页面初始化
  27. * @param param 参数
  28. * {
  29. * type:1, 1 解锁 2 升级
  30. id:110001, 技能id
  31. lv:2, 技能等级
  32. lastLv:1 技能上一级
  33. * }
  34. */
  35. async init(param: { type: number, id: number, lv: number, lastLv: number }) {
  36. this.nodeSkillUnlock.active = param.type == 1;
  37. this.nodeSkillLvUp.active = param.type == 2;
  38. let marshalData = DataSystem.getData(MarshalData);
  39. let skillData = marshalData.skillData[param.id];
  40. this.txtSkillName.string = skillData.name;
  41. this.txtLvUnlock.string = "Lv." + param.lv;
  42. this.txtLvUpLast.string = "Lv." + param.lastLv;
  43. this.txtLvUpCur.string = "Lv." + param.lv;
  44. this.imgSkill.spriteFrame = await this.res.load<SpriteFrame>("images/skill/" + skillData.icon + "/spriteFrame", SpriteFrame);
  45. this.schedule(this.closeSchedule, 1);
  46. }
  47. private closeSchedule() {
  48. this.timer -= 1;
  49. if (this.timer < 0) {
  50. this.unschedule(this.closeSchedule);
  51. this.getComponent(Window).close();
  52. }
  53. this.txtTime.string = this.timer + "秒后自动关闭";
  54. }
  55. onDestroy() {
  56. let marshalData = DataSystem.getData(MarshalData);
  57. marshalData.skillNoticeQueue.splice(0, 1);
  58. let lenAfter = marshalData.skillNoticeQueue.length;
  59. if (lenAfter > 0) {
  60. let param = marshalData.skillNoticeQueue[0];
  61. WindowSystem.open("prefabs/ui/marshalStage/marshalSkillNotice", WindowOpenMode.NotCloseAndCover, [param]);
  62. }
  63. }
  64. }