a3c9f8fcbdada375322cac7fcfc94be54c60338f.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Enum, RigidBody, SkeletalAnimation, Vec3, BaseExp, PoolManager, userIns, autoBind, Logger, ResUtil, Game, _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _crd, ccclass, property, ObstacleType, Sundries;
  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 _reportPossibleCrUseOfBaseExp(extras) {
  10. _reporterNs.report("BaseExp", "../core/base/BaseExp", _context.meta, extras);
  11. }
  12. function _reportPossibleCrUseOfPoolManager(extras) {
  13. _reporterNs.report("PoolManager", "../core/manager/PoolManager", _context.meta, extras);
  14. }
  15. function _reportPossibleCrUseOfuserIns(extras) {
  16. _reporterNs.report("userIns", "../data/UserData", _context.meta, extras);
  17. }
  18. function _reportPossibleCrUseOfautoBind(extras) {
  19. _reporterNs.report("autoBind", "../extend/AutoBind", _context.meta, extras);
  20. }
  21. function _reportPossibleCrUseOfLogger(extras) {
  22. _reporterNs.report("Logger", "../extend/Logger", _context.meta, extras);
  23. }
  24. function _reportPossibleCrUseOfResUtil(extras) {
  25. _reporterNs.report("ResUtil", "../utils/ResUtil", _context.meta, extras);
  26. }
  27. function _reportPossibleCrUseOfGame(extras) {
  28. _reporterNs.report("Game", "./Game", _context.meta, extras);
  29. }
  30. return {
  31. setters: [function (_unresolved_) {
  32. _reporterNs = _unresolved_;
  33. }, function (_cc) {
  34. _cclegacy = _cc.cclegacy;
  35. __checkObsolete__ = _cc.__checkObsolete__;
  36. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  37. _decorator = _cc._decorator;
  38. Enum = _cc.Enum;
  39. RigidBody = _cc.RigidBody;
  40. SkeletalAnimation = _cc.SkeletalAnimation;
  41. Vec3 = _cc.Vec3;
  42. }, function (_unresolved_2) {
  43. BaseExp = _unresolved_2.BaseExp;
  44. }, function (_unresolved_3) {
  45. PoolManager = _unresolved_3.PoolManager;
  46. }, function (_unresolved_4) {
  47. userIns = _unresolved_4.userIns;
  48. }, function (_unresolved_5) {
  49. autoBind = _unresolved_5.autoBind;
  50. }, function (_unresolved_6) {
  51. Logger = _unresolved_6.Logger;
  52. }, function (_unresolved_7) {
  53. ResUtil = _unresolved_7.ResUtil;
  54. }, function (_unresolved_8) {
  55. Game = _unresolved_8.Game;
  56. }],
  57. execute: function () {
  58. _crd = true;
  59. _cclegacy._RF.push({}, "abb32hZG5dFn4XzGqMrwcK7", "Sundries", undefined);
  60. __checkObsolete__(['_decorator', 'Enum', 'Node', 'RigidBody', 'SkeletalAnimation', 'Vec3']);
  61. ({
  62. ccclass,
  63. property
  64. } = _decorator);
  65. /**
  66. * 战场障碍物类型
  67. */
  68. _export("ObstacleType", ObstacleType = /*#__PURE__*/function (ObstacleType) {
  69. ObstacleType["SANDBAG_PILE"] = "\u6C99\u888B\u5806";
  70. ObstacleType["OIL_BARREL"] = "\u6CB9\u6876";
  71. ObstacleType["MILITARY_TRUCK"] = "\u519B\u8F66";
  72. ObstacleType["SMALL_SANDBAG"] = "\u5C0F\u6C99\u888B";
  73. return ObstacleType;
  74. }({}));
  75. /**
  76. * 杂物建筑物类
  77. */
  78. _export("Sundries", Sundries = (_dec = ccclass('Sundries'), _dec2 = property({
  79. type: Enum(ObstacleType),
  80. tooltip: "SANDBAG_PILE: 沙袋堆 OIL_BARREL: 油桶 MILITARY_TRUCK: 军车 SMALL_SANDBAG: 小沙袋 ",
  81. displayName: "障碍物类型"
  82. }), _dec3 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  83. error: Error()
  84. }), autoBind) : autoBind)({
  85. type: SkeletalAnimation,
  86. tooltip: "杂物动画节点"
  87. }), _dec(_class = (_class2 = class Sundries extends (_crd && BaseExp === void 0 ? (_reportPossibleCrUseOfBaseExp({
  88. error: Error()
  89. }), BaseExp) : BaseExp) {
  90. constructor() {
  91. super(...arguments);
  92. _initializerDefineProperty(this, "obstacleType", _descriptor, this);
  93. _initializerDefineProperty(this, "skeletal", _descriptor2, this);
  94. //杂物信息数据
  95. this.data = null;
  96. //杂物是否被打报废
  97. this.isDead = false;
  98. //杂物当前的总血量
  99. this.totalHp = 0;
  100. }
  101. start() {
  102. //根据障碍物类型设置总血量
  103. var sundrie_id = -1;
  104. switch (this.obstacleType) {
  105. case ObstacleType.SANDBAG_PILE:
  106. sundrie_id = 11001;
  107. break;
  108. case ObstacleType.OIL_BARREL:
  109. sundrie_id = 11002;
  110. break;
  111. case ObstacleType.MILITARY_TRUCK:
  112. sundrie_id = 11003;
  113. break;
  114. case ObstacleType.SMALL_SANDBAG:
  115. sundrie_id = 11004;
  116. break;
  117. }
  118. if (sundrie_id !== -1) {
  119. var data = (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
  120. error: Error()
  121. }), userIns) : userIns).sundriesTable.find(e => e.id == sundrie_id);
  122. this.data = data;
  123. this.totalHp = data.hp;
  124. } else {
  125. (_crd && Logger === void 0 ? (_reportPossibleCrUseOfLogger({
  126. error: Error()
  127. }), Logger) : Logger).log('未找到对应的杂物信息');
  128. }
  129. }
  130. /**
  131. * 杂物被打掉血
  132. * @param hp 血
  133. * @param pData 玩家数据
  134. */
  135. subHP(hp, pData) {
  136. if ((_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  137. error: Error()
  138. }), Game) : Game).I.isPause || this.isDead || hp == null || this.totalHp <= 0) {
  139. return;
  140. }
  141. this.totalHp -= hp; //杂物打打死报废
  142. if (this.totalHp <= 0 && !this.isDead) {
  143. this.scrap(); //audioMgr.playDieAudios();
  144. }
  145. }
  146. /**
  147. * 杂物被打报废
  148. */
  149. scrap() {
  150. var _this = this;
  151. return _asyncToGenerator(function* () {
  152. switch (_this.obstacleType) {
  153. case ObstacleType.SANDBAG_PILE:
  154. {
  155. //沙袋堆
  156. if (_this.skeletal) return; //沙袋掀开的动画
  157. _this.skeletal.play('take');
  158. _this.scheduleOnce(_this.recycle.bind(_this), 1.5);
  159. }
  160. break;
  161. case ObstacleType.OIL_BARREL:
  162. {
  163. //油桶
  164. if (_this.skeletal) return; //油漆桶爆炸动画
  165. _this.skeletal.play('blast');
  166. _this.scheduleOnce(_this.recycle.bind(_this), 3); //爆炸后生成爆炸特效
  167. }
  168. break;
  169. case ObstacleType.MILITARY_TRUCK:
  170. {
  171. //军车
  172. //加载报废的军车
  173. var military = yield (_crd && ResUtil === void 0 ? (_reportPossibleCrUseOfResUtil({
  174. error: Error()
  175. }), ResUtil) : ResUtil).loadEnemyRes('military_scrap', _this.node.parent);
  176. military.worldPosition = _this.node.worldPosition.clone(); //回收原有的军车
  177. _this.recycle(); //播放爆炸动画
  178. if (military) {
  179. var skeletal = military.getComponent(SkeletalAnimation);
  180. if (skeletal) {//skeletal.play('explosion');
  181. }
  182. }
  183. }
  184. break;
  185. case ObstacleType.SMALL_SANDBAG:
  186. {
  187. //小沙袋
  188. //获取刚体组件
  189. var rigidBody = _this.node.getComponent(RigidBody);
  190. if (!rigidBody) return; //计算抛射方向
  191. var startPos = _this.node.worldPosition.clone();
  192. var playerPos = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  193. error: Error()
  194. }), Game) : Game).I.player.node.worldPosition.clone();
  195. var direction = startPos.subtract(playerPos).normalize(); //随机抛射参数 水平力1500-2500N
  196. var horizontalForce = 1500 + Math.random() * 1000; //垂直力800-1500N
  197. var verticalForce = 800 + Math.random() * 700; //旋转扭矩50-150
  198. var torqueForce = 50 + Math.random() * 100; //施加作用力
  199. rigidBody.applyForce(new Vec3(direction.x * horizontalForce, verticalForce, direction.z * horizontalForce)); //施加旋转扭矩
  200. rigidBody.applyTorque(new Vec3(0, torqueForce, 0));
  201. }
  202. break;
  203. }
  204. })();
  205. }
  206. /**
  207. * 杂物回收
  208. */
  209. recycle() {
  210. if (this.node.parent) {
  211. this.isDead = true;
  212. (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
  213. error: Error()
  214. }), PoolManager) : PoolManager).putNode(this.node);
  215. }
  216. }
  217. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "obstacleType", [_dec2], {
  218. configurable: true,
  219. enumerable: true,
  220. writable: true,
  221. initializer: function initializer() {
  222. return ObstacleType.SANDBAG_PILE;
  223. }
  224. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "skeletal", [_dec3], {
  225. configurable: true,
  226. enumerable: true,
  227. writable: true,
  228. initializer: function initializer() {
  229. return null;
  230. }
  231. })), _class2)) || _class));
  232. _cclegacy._RF.pop();
  233. _crd = false;
  234. }
  235. };
  236. });
  237. //# sourceMappingURL=a3c9f8fcbdada375322cac7fcfc94be54c60338f.js.map