5cc3ce28e30e8e416eb47ff816c05a8fc1f78292.js 10 KB

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