a52c19e6cc4bd6966959cb229e7a378f3924b5da.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Label, instantiate, math, Layout_UI_Notify, ModuleDef, GameUILayers, gui, ui_base, NotifyInfo, UINotify, _crd;
  4. function _reportPossibleCrUseOfLayout_UI_Notify(extras) {
  5. _reporterNs.report("Layout_UI_Notify", "./Layout_UI_Notify", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfModuleDef(extras) {
  8. _reporterNs.report("ModuleDef", "../../scripts/ModuleDef", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfGameUILayers(extras) {
  11. _reporterNs.report("GameUILayers", "../../core/ui/ui", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfgui(extras) {
  14. _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras);
  15. }
  16. function _reportPossibleCrUseOfui_base(extras) {
  17. _reporterNs.report("ui_base", "../../core/ui/ui", _context.meta, extras);
  18. }
  19. _export("UINotify", void 0);
  20. return {
  21. setters: [function (_unresolved_) {
  22. _reporterNs = _unresolved_;
  23. }, function (_cc) {
  24. _cclegacy = _cc.cclegacy;
  25. __checkObsolete__ = _cc.__checkObsolete__;
  26. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  27. Label = _cc.Label;
  28. instantiate = _cc.instantiate;
  29. math = _cc.math;
  30. }, function (_unresolved_2) {
  31. Layout_UI_Notify = _unresolved_2.Layout_UI_Notify;
  32. }, function (_unresolved_3) {
  33. ModuleDef = _unresolved_3.ModuleDef;
  34. }, function (_unresolved_4) {
  35. GameUILayers = _unresolved_4.GameUILayers;
  36. gui = _unresolved_4.gui;
  37. ui_base = _unresolved_4.ui_base;
  38. }],
  39. execute: function () {
  40. _crd = true;
  41. _cclegacy._RF.push({}, "2e622idLyVJBYf//0497gj2", "UINotify", undefined);
  42. __checkObsolete__(['Label', 'Prefab', 'instantiate', 'Node', 'math']);
  43. NotifyInfo = class NotifyInfo {
  44. constructor(node, parent, txt) {
  45. //正常大小
  46. this.time = void 0;
  47. this.node = void 0;
  48. this.state = void 0;
  49. this._state_time = 0;
  50. this.time = NotifyInfo.time;
  51. this.node = node;
  52. this.state = 0;
  53. this._state_time = 0;
  54. let label = node.getComponentInChildren(Label);
  55. label.string = txt;
  56. node.parent = parent;
  57. node.setPosition(0, NotifyInfo.init_y, 0);
  58. node.setScale(NotifyInfo.sc_state0, NotifyInfo.sc_state0, NotifyInfo.sc_state0);
  59. node.active = true;
  60. }
  61. up() {
  62. this.node.setPosition(this.node.position.x, this.node.position.y + NotifyInfo.up_y, this.node.position.z);
  63. }
  64. run(dt) {
  65. this.time -= dt;
  66. if (this.time <= 0) {
  67. this.node.destroy();
  68. this.node = null;
  69. return true;
  70. } else if (this.time < 0.5) {
  71. this.node.setPosition(this.node.position.x, this.node.position.y + NotifyInfo.move_speed * dt, this.node.position.z);
  72. } else {
  73. if (this.state === 0) {
  74. this._state_time += dt;
  75. let ratio = this._state_time / NotifyInfo.sc_state0_time;
  76. if (ratio >= 1) {
  77. this.state = 1;
  78. this._state_time = 0;
  79. this.node.setScale(NotifyInfo.sc_state1, NotifyInfo.sc_state1, NotifyInfo.sc_state1);
  80. } else {
  81. let sc = math.lerp(NotifyInfo.sc_state0, NotifyInfo.sc_state1, ratio);
  82. this.node.setScale(sc, sc, sc);
  83. }
  84. } else if (this.state === 1) {
  85. this._state_time += dt;
  86. let ratio = this._state_time / NotifyInfo.sc_state1_time;
  87. if (ratio >= 1) {
  88. this.state = 2;
  89. this._state_time = 0;
  90. this.node.setScale(NotifyInfo.sc_state2, NotifyInfo.sc_state2, NotifyInfo.sc_state2);
  91. } else {
  92. let sc = math.lerp(NotifyInfo.sc_state1, NotifyInfo.sc_state2, ratio);
  93. this.node.setScale(sc, sc, sc);
  94. }
  95. }
  96. }
  97. return false;
  98. }
  99. };
  100. NotifyInfo.time = 2;
  101. NotifyInfo.init_y = 120;
  102. NotifyInfo.up_y = 80;
  103. //上升一格
  104. NotifyInfo.move_speed = 880;
  105. //向上移动速度
  106. NotifyInfo.sc_state0 = 0.8;
  107. //变小大小
  108. NotifyInfo.sc_state0_time = 0.22;
  109. NotifyInfo.sc_state1 = 1.2;
  110. //变大大小
  111. NotifyInfo.sc_state1_time = 0.41;
  112. NotifyInfo.sc_state2 = 1;
  113. _export("UINotify", UINotify = class UINotify extends (_crd && ui_base === void 0 ? (_reportPossibleCrUseOfui_base({
  114. error: Error()
  115. }), ui_base) : ui_base) {
  116. constructor() {
  117. super((_crd && ModuleDef === void 0 ? (_reportPossibleCrUseOfModuleDef({
  118. error: Error()
  119. }), ModuleDef) : ModuleDef).BASIC, 'ui_notify/UI_Notify', (_crd && GameUILayers === void 0 ? (_reportPossibleCrUseOfGameUILayers({
  120. error: Error()
  121. }), GameUILayers) : GameUILayers).NOTICE, _crd && Layout_UI_Notify === void 0 ? (_reportPossibleCrUseOfLayout_UI_Notify({
  122. error: Error()
  123. }), Layout_UI_Notify) : Layout_UI_Notify);
  124. this._info_prefab = void 0;
  125. this.notifys = [];
  126. }
  127. static async show(msg) {
  128. let ui = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  129. error: Error()
  130. }), gui) : gui).get(UINotify);
  131. if (!ui) ui = await (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  132. error: Error()
  133. }), gui) : gui).show(UINotify);
  134. ui.newNotify(msg);
  135. }
  136. onCreated() {
  137. let layout = this.getLayout();
  138. this._info_prefab = layout.info_prefab;
  139. }
  140. newNotify(txt) {
  141. let info = new NotifyInfo(instantiate(this._info_prefab), this.node, txt);
  142. for (var i = this.notifys.length - 1; i >= 0; i--) this.notifys[i].up();
  143. this.notifys.push(info);
  144. }
  145. onUpdate(dt) {
  146. for (var i = this.notifys.length - 1; i >= 0; i--) if (this.notifys[i].run(dt)) this.notifys.splice(i, 1);
  147. }
  148. dispose() {
  149. this._info_prefab = null;
  150. }
  151. });
  152. _cclegacy._RF.pop();
  153. _crd = false;
  154. }
  155. };
  156. });
  157. //# sourceMappingURL=a52c19e6cc4bd6966959cb229e7a378f3924b5da.js.map