123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- 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, Node, Vec3, tween, director, PoolManager, Game, uiMgr, Constants, Bullet1, GunBase, audioMgr, _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3, _crd, ccclass, property, Gun1;
- 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 _reportPossibleCrUseOfPoolManager(extras) {
- _reporterNs.report("PoolManager", "../../core/manager/PoolManager", _context.meta, extras);
- }
- function _reportPossibleCrUseOfGame(extras) {
- _reporterNs.report("Game", "../../game/Game", _context.meta, extras);
- }
- function _reportPossibleCrUseOfuiMgr(extras) {
- _reporterNs.report("uiMgr", "../../core/manager/UIManager", _context.meta, extras);
- }
- function _reportPossibleCrUseOfConstants(extras) {
- _reporterNs.report("Constants", "../../data/Constants", _context.meta, extras);
- }
- function _reportPossibleCrUseOfGunfightShootUI(extras) {
- _reporterNs.report("GunfightShootUI", "../../ui/GunfightShootUI", _context.meta, extras);
- }
- function _reportPossibleCrUseOfBullet(extras) {
- _reporterNs.report("Bullet1", "./Bullet1", _context.meta, extras);
- }
- function _reportPossibleCrUseOfGunBase(extras) {
- _reporterNs.report("GunBase", "../base/GunBase", _context.meta, extras);
- }
- function _reportPossibleCrUseOfEnemy(extras) {
- _reporterNs.report("Enemy", "../../game/Enemy", _context.meta, extras);
- }
- function _reportPossibleCrUseOfPlayer(extras) {
- _reporterNs.report("Player", "../../game/Player", _context.meta, extras);
- }
- function _reportPossibleCrUseOfaudioMgr(extras) {
- _reporterNs.report("audioMgr", "../../core/manager/AudioManager", _context.meta, extras);
- }
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- Node = _cc.Node;
- Vec3 = _cc.Vec3;
- tween = _cc.tween;
- director = _cc.director;
- }, function (_unresolved_2) {
- PoolManager = _unresolved_2.PoolManager;
- }, function (_unresolved_3) {
- Game = _unresolved_3.Game;
- }, function (_unresolved_4) {
- uiMgr = _unresolved_4.uiMgr;
- }, function (_unresolved_5) {
- Constants = _unresolved_5.Constants;
- }, function (_unresolved_6) {
- Bullet1 = _unresolved_6.Bullet1;
- }, function (_unresolved_7) {
- GunBase = _unresolved_7.GunBase;
- }, function (_unresolved_8) {
- audioMgr = _unresolved_8.audioMgr;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "6984845eWhGy4N9LVXaCypl", "Gun1", undefined);
- __checkObsolete__(['_decorator', 'Node', 'Vec3', 'tween', 'director']);
- ({
- ccclass,
- property
- } = _decorator); //玩家所使用的枪 重狙枪 开一枪然后回缩镜头 (98K M24 AWM)
- _export("Gun1", Gun1 = (_dec = ccclass('Gun1'), _dec2 = property({
- type: Node,
- tooltip: "子弹节点"
- }), _dec3 = property({
- type: Node,
- tooltip: "烟雾特效"
- }), _dec4 = property({
- type: Node,
- tooltip: "开火特效节点"
- }), _dec(_class = (_class2 = class Gun1 extends (_crd && GunBase === void 0 ? (_reportPossibleCrUseOfGunBase({
- error: Error()
- }), GunBase) : GunBase) {
- constructor() {
- super(...arguments);
- _initializerDefineProperty(this, "bulletNode", _descriptor, this);
- _initializerDefineProperty(this, "impact", _descriptor2, this);
- _initializerDefineProperty(this, "fireEffect", _descriptor3, this);
- //枪的拥有者
- this.holder = null;
- //开枪结束回调
- this.endCb = null;
- //换弹匣的回调
- this.ammoCb = null;
- //触发间隔时间统计
- this.curTime = 0;
- //是否是第一次开火
- this.isFristShot = false;
- //所有的烟雾
- this.smokes = [];
- }
- onLoad() {
- this.bulletNode.active = false;
- this.impact.active = false;
- this.muzzleNode.active = false;
- }
- /**
- * 设置枪的数据
- * @param data 枪的数据
- * @param endCB 结束回调
- * @param ammoCb 换弹匣回调
- */
- init(data, holder, endCb, ammoCb) {
- this.data = data;
- this.shotBullets = 0;
- this.isFire = false;
- this.isFristShot = true;
- this.holder = holder;
- this.endCb = endCb;
- this.ammoCb = ammoCb;
- } //开火
- fire() {
- this.isFire = true;
- this.createBullet();
- this.playParticle(this.fireEffect);
- } //结束开火
- endFire() {
- var _this$endCb;
- this.isFire = false;
- (_this$endCb = this.endCb) == null || _this$endCb.call(this, this.data);
- this.recycle();
- }
- /**
- * 直接开抢射杀敌人
- */
- killEnemy(e) {
- if (e.isDead || (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.isPause) {
- return;
- }
- var destPos = e.node.worldPosition.clone();
- var bullet = this.getBulleNode();
- bullet.init(this, true);
- tween(bullet.node).to(0.3, {
- worldPosition: destPos
- }).call(() => {
- bullet.isDead = true;
- (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
- error: Error()
- }), PoolManager) : PoolManager).putNode(bullet.node); //直接打死 最大血量乘以2倍
- e.subHP(e.data.hp * 2, this.data);
- }).start();
- }
- /**
- * 展示子弹
- */
- createBullet() {
- if (!this.holder || this.holder.isDead || !this.isFire || (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.isPause || (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.isGameOver) {
- return;
- }
- (_crd && audioMgr === void 0 ? (_reportPossibleCrUseOfaudioMgr({
- error: Error()
- }), audioMgr) : audioMgr).playOneShot(this.data.gun_sound);
- this.getBulleNode();
- this.shotBullets++; //换弹夹的操作
- if (this.shotBullets >= this.data.magazine) {
- var _this$ammoCb;
- this.shotBullets = 0;
- (_this$ammoCb = this.ammoCb) == null || _this$ammoCb.call(this, this.data);
- }
- this.endFire();
- }
- /**
- * 初始化一个子弹
- * @param isGuaranteedHit 子弹是否必中(必中的时候targetNode不能为空)
- * @param targetNode 射击的目标对象
- * @returns 返回一颗子弹
- */
- getBulleNode(isGuaranteedHit, targetNode) {
- if (isGuaranteedHit === void 0) {
- isGuaranteedHit = true;
- }
- if (targetNode === void 0) {
- targetNode = null;
- }
- //从对象池获取子弹节点
- var bulletNode = (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
- error: Error()
- }), PoolManager) : PoolManager).getNode(this.bulletNode, director.getScene());
- var bullet = bulletNode.getComponent(_crd && Bullet1 === void 0 ? (_reportPossibleCrUseOfBullet({
- error: Error()
- }), Bullet1) : Bullet1);
- bullet.init(this);
- bulletNode.worldPosition = this.muzzleNode.worldPosition.clone(); //计算基准方向(瞄准目标或准星位置)
- var shootUI = (_crd && uiMgr === void 0 ? (_reportPossibleCrUseOfuiMgr({
- error: Error()
- }), uiMgr) : uiMgr).getPageComponent((_crd && Constants === void 0 ? (_reportPossibleCrUseOfConstants({
- error: Error()
- }), Constants) : Constants).popUIs.gunfightShootUI);
- var targetPos = targetNode ? targetNode.worldPosition : shootUI.getCrossHairPos();
- var baseDirection = Vec3.subtract(new Vec3(), targetPos, this.muzzleNode.worldPosition).normalize(); //最终弹道方向
- var finalDirection;
- if (isGuaranteedHit) {
- //100%必中(无偏移)
- finalDirection = baseDirection;
- } else {
- //非必中:在基准方向上添加小范围随机偏移
- var maxOffsetAngle = 5;
- var offsetX = (Math.random() - 0.5) * maxOffsetAngle * Math.PI / 180;
- var offsetY = (Math.random() - 0.5) * maxOffsetAngle * Math.PI / 180; //应用偏移(保持Z轴主要方向)
- finalDirection = new Vec3(baseDirection.x + offsetX, baseDirection.y + offsetY, baseDirection.z // 保持主要前进方向
- ).normalize();
- } //设置子弹方向
- bulletNode.forward = finalDirection;
- bullet.setBulletVector(finalDirection);
- return bullet;
- }
- /**
- * 回收烟雾
- */
- recycle() {
- this.smokes.forEach(e => {
- if (e && e.parent) {
- (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
- error: Error()
- }), PoolManager) : PoolManager).putNode(e);
- }
- });
- this.smokes = [];
- }
- }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "bulletNode", [_dec2], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return null;
- }
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "impact", [_dec3], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return null;
- }
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "fireEffect", [_dec4], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return null;
- }
- })), _class2)) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=cc865b0cad626cd4d72e49dc8528e7e6d444b5f5.js.map
|