5cc3ce28e30e8e416eb47ff816c05a8fc1f78292.js 11 KB

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