a52c19e6cc4bd6966959cb229e7a378f3924b5da.js 7.1 KB

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