5cc3ce28e30e8e416eb47ff816c05a8fc1f78292.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Button, Component, Label, Node, Sprite, tween, v3, ch, gui, UI_Main, Hall, Toast, _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _descriptor3, _crd, ccclass, property, UI_Item;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfch(extras) {
  8. _reporterNs.report("ch", "../../../ch/ch", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfgui(extras) {
  11. _reporterNs.report("gui", "../../../core/ui/ui", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfUI_Main(extras) {
  14. _reporterNs.report("UI_Main", "../UI_Main/UI_Main", _context.meta, extras);
  15. }
  16. function _reportPossibleCrUseOfLayout_Main(extras) {
  17. _reporterNs.report("Layout_Main", "../UI_Main/Layout_Main", _context.meta, extras);
  18. }
  19. function _reportPossibleCrUseOfHall(extras) {
  20. _reporterNs.report("Hall", "../../hall/Hall", _context.meta, extras);
  21. }
  22. function _reportPossibleCrUseOfToast(extras) {
  23. _reporterNs.report("Toast", "../../../core/util_class/Toast", _context.meta, extras);
  24. }
  25. return {
  26. setters: [function (_unresolved_) {
  27. _reporterNs = _unresolved_;
  28. }, function (_cc) {
  29. _cclegacy = _cc.cclegacy;
  30. __checkObsolete__ = _cc.__checkObsolete__;
  31. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  32. _decorator = _cc._decorator;
  33. Button = _cc.Button;
  34. Component = _cc.Component;
  35. Label = _cc.Label;
  36. Node = _cc.Node;
  37. Sprite = _cc.Sprite;
  38. tween = _cc.tween;
  39. v3 = _cc.v3;
  40. }, function (_unresolved_2) {
  41. ch = _unresolved_2.ch;
  42. }, function (_unresolved_3) {
  43. gui = _unresolved_3.gui;
  44. }, function (_unresolved_4) {
  45. UI_Main = _unresolved_4.UI_Main;
  46. }, function (_unresolved_5) {
  47. Hall = _unresolved_5.Hall;
  48. }, function (_unresolved_6) {
  49. Toast = _unresolved_6.Toast;
  50. }],
  51. execute: function () {
  52. _crd = true;
  53. _cclegacy._RF.push({}, "12c662bVNFDxoVeaMUS/AvG", "UI_Item", undefined);
  54. __checkObsolete__(['_decorator', 'Button', 'Component', 'instantiate', 'Label', 'Node', 'Sprite', 'SpriteFrame', 'tween', 'v3']);
  55. ({
  56. ccclass,
  57. property
  58. } = _decorator);
  59. _export("UI_Item", UI_Item = (_dec = ccclass('UI_Item'), _dec2 = property(Sprite), _dec3 = property(Label), _dec(_class = (_class2 = class UI_Item extends Component {
  60. constructor(...args) {
  61. super(...args);
  62. _initializerDefineProperty(this, "type", _descriptor, this);
  63. _initializerDefineProperty(this, "Ad", _descriptor2, this);
  64. _initializerDefineProperty(this, "count", _descriptor3, this);
  65. this._c = 0;
  66. }
  67. start() {
  68. if (this.type == 0) return;
  69. this.show(this.type, (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  70. error: Error()
  71. }), Hall) : Hall).getInstance().player.get_item(this.type));
  72. if (this.node.getComponent(Button)) {
  73. this.node.on(Node.EventType.TOUCH_END, this.onClick, this);
  74. }
  75. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  76. error: Error()
  77. }), Hall) : Hall).getInstance().player.event.on((_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  78. error: Error()
  79. }), Hall) : Hall).getInstance().player.event.key.item_count, this.show, this);
  80. }
  81. onDestroy() {
  82. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  83. error: Error()
  84. }), Hall) : Hall).getInstance().player.event.off((_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  85. error: Error()
  86. }), Hall) : Hall).getInstance().player.event.key.item_count, this.show, this);
  87. }
  88. show(type, count) {
  89. if (type != this.type) return;
  90. if (this._c != count) {
  91. tween(this.node).to(0.05, {
  92. scale: v3(1.2, 1.2, 1)
  93. }).to(0.1, {
  94. scale: v3(1, 1, 1)
  95. }).start();
  96. if (count < this._c) {// if (type == 1) {
  97. // ch.audio.playOneShot('sounds/sfx_item1');
  98. // } else if (type == 2) {
  99. // ch.audio.playOneShot('sounds/sfx_item2');
  100. // } else {
  101. // ch.audio.playOneShot('sounds/sfx_item3');
  102. // }
  103. }
  104. }
  105. this._c = count;
  106. if (count != 0) {
  107. this.Ad.node.active = false;
  108. this.count.node.parent.active = true;
  109. this.count.string = count.toString();
  110. } else {
  111. this.Ad.node.active = true;
  112. this.count.node.parent.active = false;
  113. }
  114. if (type == 1) {// if (GameLink.getInst().lv.dir == LvDir.none) {
  115. // this.node.active = false;
  116. // } else {
  117. // this.node.active = true;
  118. // }
  119. } //this.ad.active = count <= 0;
  120. } //
  121. async onClick(evt) {
  122. if (this._c <= 0) {
  123. if (this.type == 3) {
  124. let flag = false;
  125. for (let element of (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  126. error: Error()
  127. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  128. error: Error()
  129. }), UI_Main) : UI_Main).getLayout().Container.node_isIdiom) {
  130. console.log(element);
  131. if (element == true) {
  132. flag = true;
  133. break;
  134. }
  135. }
  136. if (!flag) {
  137. (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
  138. error: Error()
  139. }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  140. error: Error()
  141. }), gui) : gui).getLayerNode(5), "槽中无可清除的方块").show();
  142. return;
  143. }
  144. }
  145. const ret = await chsdk.playRewardAd('获得道具' + this.type);
  146. if (ret) {
  147. // ch.audio.playOneShot('sounds/sfx_add_item');
  148. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  149. error: Error()
  150. }), Hall) : Hall).getInstance().player.add_item(this.type, 1);
  151. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  152. error: Error()
  153. }), Hall) : Hall).getInstance().player.set_watch_ad_num(1);
  154. (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({
  155. error: Error()
  156. }), ch) : ch).audio.resume();
  157. } // gui.show(UI_ad_get, this.type);
  158. } else {
  159. if (this.type == 3) {
  160. let flag = false;
  161. for (let element of (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  162. error: Error()
  163. }), gui) : gui).get(_crd && UI_Main === void 0 ? (_reportPossibleCrUseOfUI_Main({
  164. error: Error()
  165. }), UI_Main) : UI_Main).getLayout().Container.node_isIdiom) {
  166. console.log(element);
  167. if (element == true) {
  168. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  169. error: Error()
  170. }), Hall) : Hall).getInstance().player.use_item(this.type);
  171. flag = true;
  172. break;
  173. }
  174. }
  175. if (!flag) (_crd && Toast === void 0 ? (_reportPossibleCrUseOfToast({
  176. error: Error()
  177. }), Toast) : Toast).makeText((_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({
  178. error: Error()
  179. }), gui) : gui).getLayerNode(5), "槽中无可清除的方块").show(); //UINotify.show('槽中无可清除的方块');
  180. } else {
  181. (_crd && Hall === void 0 ? (_reportPossibleCrUseOfHall({
  182. error: Error()
  183. }), Hall) : Hall).getInstance().player.use_item(this.type);
  184. }
  185. }
  186. }
  187. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "type", [property], {
  188. configurable: true,
  189. enumerable: true,
  190. writable: true,
  191. initializer: function () {
  192. return 0;
  193. }
  194. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "Ad", [_dec2], {
  195. configurable: true,
  196. enumerable: true,
  197. writable: true,
  198. initializer: null
  199. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "count", [_dec3], {
  200. configurable: true,
  201. enumerable: true,
  202. writable: true,
  203. initializer: null
  204. })), _class2)) || _class));
  205. _cclegacy._RF.pop();
  206. _crd = false;
  207. }
  208. };
  209. });
  210. //# sourceMappingURL=5cc3ce28e30e8e416eb47ff816c05a8fc1f78292.js.map