f7fbf5f4a52d289ff3c42149934c58d9a34154ea.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 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 _reportPossibleCrUseOfGameUILayers(extras) {
  10. _reporterNs.report("GameUILayers", "../../core/ui/ui", _context.meta, extras);
  11. }
  12. function _reportPossibleCrUseOfgui(extras) {
  13. _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras);
  14. }
  15. function _reportPossibleCrUseOfui_base(extras) {
  16. _reporterNs.report("ui_base", "../../core/ui/ui", _context.meta, extras);
  17. }
  18. function _reportPossibleCrUseOfModuleDef(extras) {
  19. _reporterNs.report("ModuleDef", "../../Scripts/ModuleDef", _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. GameUILayers = _unresolved_3.GameUILayers;
  36. gui = _unresolved_3.gui;
  37. ui_base = _unresolved_3.ui_base;
  38. }, function (_unresolved_4) {
  39. ModuleDef = _unresolved_4.ModuleDef;
  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() {// this.node.setPosition(this.node.position.x, this.node.position.y + NotifyInfo.up_y, this.node.position.z);
  64. }
  65. run(dt) {
  66. this.time -= dt;
  67. if (this.time <= 0) {
  68. this.node.destroy();
  69. this.node = null;
  70. return true;
  71. } 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);
  72. } else {
  73. if (this.state === 0) {
  74. this._state_time += dt;
  75. var 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. var 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. var _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. var _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 show(msg) {
  128. return _asyncToGenerator(function* () {
  129. var ui = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  130. error: Error()
  131. }), gui) : gui).get(UINotify);
  132. if (!ui) ui = yield (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  133. error: Error()
  134. }), gui) : gui).show(UINotify);
  135. ui.newNotify(msg);
  136. })();
  137. }
  138. onCreated() {
  139. var layout = this.getLayout();
  140. this._info_prefab = layout.info_prefab;
  141. }
  142. newNotify(txt) {
  143. var info = new NotifyInfo(instantiate(this._info_prefab), this.node, txt);
  144. for (var i = this.notifys.length - 1; i >= 0; i--) this.notifys[i].up();
  145. this.notifys.push(info);
  146. }
  147. onUpdate(dt) {
  148. for (var i = this.notifys.length - 1; i >= 0; i--) if (this.notifys[i].run(dt)) this.notifys.splice(i, 1);
  149. }
  150. dispose() {
  151. this._info_prefab = null;
  152. }
  153. });
  154. _cclegacy._RF.pop();
  155. _crd = false;
  156. }
  157. };
  158. });
  159. //# sourceMappingURL=f7fbf5f4a52d289ff3c42149934c58d9a34154ea.js.map