7a060cba1d5a032475d6578a562fb8df8171eb0b.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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, GameUILayers, gui, ui_base, ModuleDef, NotifyInfo, UINotify, _crd;
  4. function _reportPossibleCrUseOfLayout_UI_Notify(extras) {
  5. _reporterNs.report("Layout_UI_Notify", "./Layout_UI_Notify", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfGameUILayers(extras) {
  8. _reporterNs.report("GameUILayers", "../../core/ui/ui", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfgui(extras) {
  11. _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfui_base(extras) {
  14. _reporterNs.report("ui_base", "../../core/ui/ui", _context.meta, extras);
  15. }
  16. function _reportPossibleCrUseOfModuleDef(extras) {
  17. _reporterNs.report("ModuleDef", "../../Scripts/ModuleDef", _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. GameUILayers = _unresolved_3.GameUILayers;
  34. gui = _unresolved_3.gui;
  35. ui_base = _unresolved_3.ui_base;
  36. }, function (_unresolved_4) {
  37. ModuleDef = _unresolved_4.ModuleDef;
  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) {// this.node.setPosition(this.node.position.x, this.node.position.y + NotifyInfo.move_speed * dt, this.node.position.z);
  71. } else {
  72. if (this.state === 0) {
  73. this._state_time += dt;
  74. let ratio = this._state_time / NotifyInfo.sc_state0_time;
  75. if (ratio >= 1) {
  76. this.state = 1;
  77. this._state_time = 0;
  78. this.node.setScale(NotifyInfo.sc_state1, NotifyInfo.sc_state1, NotifyInfo.sc_state1);
  79. } else {
  80. let sc = math.lerp(NotifyInfo.sc_state0, NotifyInfo.sc_state1, ratio);
  81. this.node.setScale(sc, sc, sc);
  82. }
  83. } else if (this.state === 1) {
  84. this._state_time += dt;
  85. let ratio = this._state_time / NotifyInfo.sc_state1_time;
  86. if (ratio >= 1) {
  87. this.state = 2;
  88. this._state_time = 0;
  89. this.node.setScale(NotifyInfo.sc_state2, NotifyInfo.sc_state2, NotifyInfo.sc_state2);
  90. } else {
  91. let sc = math.lerp(NotifyInfo.sc_state1, NotifyInfo.sc_state2, ratio);
  92. this.node.setScale(sc, sc, sc);
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. };
  99. NotifyInfo.time = 2;
  100. NotifyInfo.init_y = 120;
  101. NotifyInfo.up_y = 80;
  102. //上升一格
  103. NotifyInfo.move_speed = 880;
  104. //向上移动速度
  105. NotifyInfo.sc_state0 = 0.8;
  106. //变小大小
  107. NotifyInfo.sc_state0_time = 0.22;
  108. NotifyInfo.sc_state1 = 1.2;
  109. //变大大小
  110. NotifyInfo.sc_state1_time = 0.41;
  111. NotifyInfo.sc_state2 = 1;
  112. _export("UINotify", UINotify = class UINotify extends (_crd && ui_base === void 0 ? (_reportPossibleCrUseOfui_base({
  113. error: Error()
  114. }), ui_base) : ui_base) {
  115. constructor() {
  116. super((_crd && ModuleDef === void 0 ? (_reportPossibleCrUseOfModuleDef({
  117. error: Error()
  118. }), ModuleDef) : ModuleDef).BASIC, 'ui_notify/UI_Notify', (_crd && GameUILayers === void 0 ? (_reportPossibleCrUseOfGameUILayers({
  119. error: Error()
  120. }), GameUILayers) : GameUILayers).NOTICE, _crd && Layout_UI_Notify === void 0 ? (_reportPossibleCrUseOfLayout_UI_Notify({
  121. error: Error()
  122. }), Layout_UI_Notify) : Layout_UI_Notify);
  123. this._info_prefab = void 0;
  124. this.notifys = [];
  125. }
  126. static async show(msg) {
  127. let ui = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  128. error: Error()
  129. }), gui) : gui).get(UINotify);
  130. if (!ui) ui = await (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  131. error: Error()
  132. }), gui) : gui).show(UINotify);
  133. ui.newNotify(msg);
  134. }
  135. onCreated() {
  136. let layout = this.getLayout();
  137. this._info_prefab = layout.info_prefab;
  138. }
  139. newNotify(txt) {
  140. let info = new NotifyInfo(instantiate(this._info_prefab), this.node, txt);
  141. for (var i = this.notifys.length - 1; i >= 0; i--) this.notifys[i].up();
  142. this.notifys.push(info);
  143. }
  144. onUpdate(dt) {
  145. for (var i = this.notifys.length - 1; i >= 0; i--) if (this.notifys[i].run(dt)) this.notifys.splice(i, 1);
  146. }
  147. dispose() {
  148. this._info_prefab = null;
  149. }
  150. });
  151. _cclegacy._RF.pop();
  152. _crd = false;
  153. }
  154. };
  155. });
  156. //# sourceMappingURL=7a060cba1d5a032475d6578a562fb8df8171eb0b.js.map