a038c291e67008cfb5431f862bc951b95d2f25c0.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Node, Sprite, SpriteFrame, PoolManager, Game, Constants, BaseExp, _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _crd, ccclass, property, BulletMagazine;
  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 _reportPossibleCrUseOfPoolManager(extras) {
  8. _reporterNs.report("PoolManager", "../core/manager/PoolManager", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfGame(extras) {
  11. _reporterNs.report("Game", "./Game", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfConstants(extras) {
  14. _reporterNs.report("Constants", "../data/Constants", _context.meta, extras);
  15. }
  16. function _reportPossibleCrUseOfBaseExp(extras) {
  17. _reporterNs.report("BaseExp", "../core/base/BaseExp", _context.meta, extras);
  18. }
  19. return {
  20. setters: [function (_unresolved_) {
  21. _reporterNs = _unresolved_;
  22. }, function (_cc) {
  23. _cclegacy = _cc.cclegacy;
  24. __checkObsolete__ = _cc.__checkObsolete__;
  25. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  26. _decorator = _cc._decorator;
  27. Node = _cc.Node;
  28. Sprite = _cc.Sprite;
  29. SpriteFrame = _cc.SpriteFrame;
  30. }, function (_unresolved_2) {
  31. PoolManager = _unresolved_2.PoolManager;
  32. }, function (_unresolved_3) {
  33. Game = _unresolved_3.Game;
  34. }, function (_unresolved_4) {
  35. Constants = _unresolved_4.Constants;
  36. }, function (_unresolved_5) {
  37. BaseExp = _unresolved_5.BaseExp;
  38. }],
  39. execute: function () {
  40. _crd = true;
  41. _cclegacy._RF.push({}, "83c6ckag1RAjY4TUul1spSN", "BulletMagazine", undefined);
  42. __checkObsolete__(['_decorator', 'Node', 'Sprite', 'SpriteFrame']);
  43. ({
  44. ccclass,
  45. property
  46. } = _decorator);
  47. _export("BulletMagazine", BulletMagazine = (_dec = ccclass('BulletMagazine'), _dec2 = property({
  48. type: Node,
  49. tooltip: "滚动内容"
  50. }), _dec3 = property({
  51. type: Node,
  52. tooltip: "子弹预制体"
  53. }), _dec4 = property({
  54. type: SpriteFrame,
  55. tooltip: "用过的子弹图片"
  56. }), _dec5 = property({
  57. type: SpriteFrame,
  58. tooltip: "正常的子弹图片"
  59. }), _dec(_class = (_class2 = class BulletMagazine extends (_crd && BaseExp === void 0 ? (_reportPossibleCrUseOfBaseExp({
  60. error: Error()
  61. }), BaseExp) : BaseExp) {
  62. constructor() {
  63. super(...arguments);
  64. _initializerDefineProperty(this, "content", _descriptor, this);
  65. _initializerDefineProperty(this, "bullet", _descriptor2, this);
  66. _initializerDefineProperty(this, "use_sf", _descriptor3, this);
  67. _initializerDefineProperty(this, "nor_sf", _descriptor4, this);
  68. //当前子弹总数量
  69. this._magazineNum = 0;
  70. //弹夹中的子弹图片节点
  71. this.bullets = [];
  72. }
  73. set magazineNum(value) {
  74. this._magazineNum = value;
  75. this.loadMagazine();
  76. }
  77. get magazineNum() {
  78. return this._magazineNum;
  79. }
  80. start() {
  81. this.bullet.active = false; //更换弹夹
  82. this.register((_crd && Constants === void 0 ? (_reportPossibleCrUseOfConstants({
  83. error: Error()
  84. }), Constants) : Constants).eventName.magazine_num_change, this.loadMagazine.bind(this));
  85. }
  86. /**
  87. * 加载子弹 弹夹
  88. */
  89. loadMagazine() {
  90. if (!(_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  91. error: Error()
  92. }), Game) : Game).I.player.gun || (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  93. error: Error()
  94. }), Game) : Game).I.isGameOver) return;
  95. this.recycle();
  96. var gData = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  97. error: Error()
  98. }), Game) : Game).I.player.pData;
  99. var s_bullet = gData.magazine - (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  100. error: Error()
  101. }), Game) : Game).I.player.gun.shotBullets;
  102. for (var idx = 0; idx < this._magazineNum; idx++) {
  103. var n = (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
  104. error: Error()
  105. }), PoolManager) : PoolManager).getNode(this.bullet, this.content);
  106. this.bullets.push(n);
  107. n.getChildByName("kd_sp").getComponent(Sprite).spriteFrame = idx < s_bullet ? this.nor_sf : this.use_sf;
  108. }
  109. }
  110. onDisable() {
  111. this.recycle();
  112. }
  113. recycle() {
  114. this.bullets.forEach(item => {
  115. if (item.parent) {
  116. (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
  117. error: Error()
  118. }), PoolManager) : PoolManager).putNode(item);
  119. }
  120. });
  121. this.bullets = [];
  122. }
  123. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "content", [_dec2], {
  124. configurable: true,
  125. enumerable: true,
  126. writable: true,
  127. initializer: null
  128. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "bullet", [_dec3], {
  129. configurable: true,
  130. enumerable: true,
  131. writable: true,
  132. initializer: null
  133. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "use_sf", [_dec4], {
  134. configurable: true,
  135. enumerable: true,
  136. writable: true,
  137. initializer: null
  138. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "nor_sf", [_dec5], {
  139. configurable: true,
  140. enumerable: true,
  141. writable: true,
  142. initializer: null
  143. })), _class2)) || _class));
  144. _cclegacy._RF.pop();
  145. _crd = false;
  146. }
  147. };
  148. });
  149. //# sourceMappingURL=a038c291e67008cfb5431f862bc951b95d2f25c0.js.map