123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7"], function (_export, _context) {
- "use strict";
- var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Enum, RigidBody, SkeletalAnimation, Vec3, userIns, Logger, Game, PoolManager, BaseExp, autoBind, ResUtil, _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _crd, ccclass, property, ObstacleType, Sundries;
- 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); } }
- 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); }); }; }
- 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 }); }
- 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; }
- 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.'); }
- function _reportPossibleCrUseOfuserIns(extras) {
- _reporterNs.report("userIns", "../../data/UserData", _context.meta, extras);
- }
- function _reportPossibleCrUseOfLogger(extras) {
- _reporterNs.report("Logger", "../../extend/Logger", _context.meta, extras);
- }
- function _reportPossibleCrUseOfGame(extras) {
- _reporterNs.report("Game", "../../game/Game", _context.meta, extras);
- }
- function _reportPossibleCrUseOfPoolManager(extras) {
- _reporterNs.report("PoolManager", "../../core/manager/PoolManager", _context.meta, extras);
- }
- function _reportPossibleCrUseOfBaseExp(extras) {
- _reporterNs.report("BaseExp", "../../core/base/BaseExp", _context.meta, extras);
- }
- function _reportPossibleCrUseOfautoBind(extras) {
- _reporterNs.report("autoBind", "../../extend/AutoBind", _context.meta, extras);
- }
- function _reportPossibleCrUseOfResUtil(extras) {
- _reporterNs.report("ResUtil", "../../utils/ResUtil", _context.meta, extras);
- }
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- Enum = _cc.Enum;
- RigidBody = _cc.RigidBody;
- SkeletalAnimation = _cc.SkeletalAnimation;
- Vec3 = _cc.Vec3;
- }, function (_unresolved_2) {
- userIns = _unresolved_2.userIns;
- }, function (_unresolved_3) {
- Logger = _unresolved_3.Logger;
- }, function (_unresolved_4) {
- Game = _unresolved_4.Game;
- }, function (_unresolved_5) {
- PoolManager = _unresolved_5.PoolManager;
- }, function (_unresolved_6) {
- BaseExp = _unresolved_6.BaseExp;
- }, function (_unresolved_7) {
- autoBind = _unresolved_7.autoBind;
- }, function (_unresolved_8) {
- ResUtil = _unresolved_8.ResUtil;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "abb32hZG5dFn4XzGqMrwcK7", "Sundries", undefined);
- __checkObsolete__(['_decorator', 'Enum', 'Node', 'RigidBody', 'SkeletalAnimation', 'Vec3']);
- ({
- ccclass,
- property
- } = _decorator);
- /**
- * 战场障碍物类型
- */
- _export("ObstacleType", ObstacleType = /*#__PURE__*/function (ObstacleType) {
- ObstacleType["SANDBAG_PILE"] = "\u6C99\u888B\u5806";
- ObstacleType["OIL_BARREL"] = "\u6CB9\u6876";
- ObstacleType["MILITARY_TRUCK"] = "\u519B\u8F66";
- ObstacleType["SMALL_SANDBAG"] = "\u5C0F\u6C99\u888B";
- return ObstacleType;
- }({}));
- /**
- * 杂物建筑物类
- */
- _export("Sundries", Sundries = (_dec = ccclass('Sundries'), _dec2 = property({
- type: Enum(ObstacleType),
- tooltip: "SANDBAG_PILE: 沙袋堆 OIL_BARREL: 油桶 MILITARY_TRUCK: 军车 SMALL_SANDBAG: 小沙袋 ",
- displayName: "障碍物类型"
- }), _dec3 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: SkeletalAnimation,
- tooltip: "杂物动画节点"
- }), _dec(_class = (_class2 = class Sundries extends (_crd && BaseExp === void 0 ? (_reportPossibleCrUseOfBaseExp({
- error: Error()
- }), BaseExp) : BaseExp) {
- constructor() {
- super(...arguments);
- _initializerDefineProperty(this, "obstacleType", _descriptor, this);
- _initializerDefineProperty(this, "skeletal", _descriptor2, this);
- //杂物信息数据
- this.data = null;
- //杂物是否被打报废
- this.isDead = false;
- //杂物当前的总血量
- this.totalHp = 0;
- }
- start() {
- //根据障碍物类型设置总血量
- var sundrie_id = -1;
- switch (this.obstacleType) {
- case ObstacleType.SANDBAG_PILE:
- sundrie_id = 11001;
- break;
- case ObstacleType.OIL_BARREL:
- sundrie_id = 11002;
- break;
- case ObstacleType.MILITARY_TRUCK:
- sundrie_id = 11003;
- break;
- case ObstacleType.SMALL_SANDBAG:
- sundrie_id = 11004;
- break;
- }
- if (sundrie_id !== -1) {
- var data = (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
- error: Error()
- }), userIns) : userIns).sundriesTable.find(e => e.id == sundrie_id);
- this.data = data;
- this.totalHp = data.hp;
- } else {
- (_crd && Logger === void 0 ? (_reportPossibleCrUseOfLogger({
- error: Error()
- }), Logger) : Logger).log('未找到对应的杂物信息');
- }
- }
- /**
- * 杂物被打掉血
- * @param hp 血
- * @param pData 玩家数据
- */
- subHP(hp, pData) {
- if ((_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.isPause || this.isDead || hp == null || this.totalHp <= 0) {
- return;
- }
- this.totalHp -= hp; //杂物打打死报废
- if (this.totalHp <= 0 && !this.isDead) {
- this.scrap(); //audioMgr.playDieAudios();
- }
- }
- /**
- * 杂物被打报废
- */
- scrap() {
- var _this = this;
- return _asyncToGenerator(function* () {
- switch (_this.obstacleType) {
- case ObstacleType.SANDBAG_PILE:
- {
- //沙袋堆
- if (_this.skeletal) return; //沙袋掀开的动画
- _this.skeletal.play('take');
- _this.scheduleOnce(_this.recycle.bind(_this), 1.5);
- }
- break;
- case ObstacleType.OIL_BARREL:
- {
- //油桶
- if (_this.skeletal) return; //油漆桶爆炸动画
- _this.skeletal.play('blast');
- _this.scheduleOnce(_this.recycle.bind(_this), 3); //爆炸后生成爆炸特效
- }
- break;
- case ObstacleType.MILITARY_TRUCK:
- {
- //军车
- //加载报废的军车
- var military = yield (_crd && ResUtil === void 0 ? (_reportPossibleCrUseOfResUtil({
- error: Error()
- }), ResUtil) : ResUtil).loadEnemyRes('military_scrap', _this.node.parent);
- military.worldPosition = _this.node.worldPosition.clone(); //回收原有的军车
- _this.recycle(); //播放爆炸动画
- if (military) {
- var skeletal = military.getComponent(SkeletalAnimation);
- if (skeletal) {//skeletal.play('explosion');
- }
- }
- }
- break;
- case ObstacleType.SMALL_SANDBAG:
- {
- //小沙袋
- //获取刚体组件
- var rigidBody = _this.node.getComponent(RigidBody);
- if (!rigidBody) return; //计算抛射方向
- var startPos = _this.node.worldPosition.clone();
- var playerPos = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.node.worldPosition.clone();
- var direction = startPos.subtract(playerPos).normalize(); //随机抛射参数 水平力1500-2500N
- var horizontalForce = 1500 + Math.random() * 1000; //垂直力800-1500N
- var verticalForce = 800 + Math.random() * 700; //旋转扭矩50-150
- var torqueForce = 50 + Math.random() * 100; //施加作用力
- rigidBody.applyForce(new Vec3(direction.x * horizontalForce, verticalForce, direction.z * horizontalForce)); //施加旋转扭矩
- rigidBody.applyTorque(new Vec3(0, torqueForce, 0));
- }
- break;
- }
- })();
- }
- /**
- * 杂物回收
- */
- recycle() {
- if (this.node.parent) {
- this.isDead = true;
- (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
- error: Error()
- }), PoolManager) : PoolManager).putNode(this.node);
- }
- }
- }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "obstacleType", [_dec2], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return ObstacleType.SANDBAG_PILE;
- }
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "skeletal", [_dec3], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return null;
- }
- })), _class2)) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=4250f20ed93afae4bdb6abc5bd19ff1beecab6e4.js.map
|