7a060cba1d5a032475d6578a562fb8df8171eb0b.js 6.3 KB

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