123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
- "use strict";
- var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, geometry, PhysicsSystem, RigidBody, PoolManager, Game, BulletBase, _dec, _class, _crd, ccclass, property, Bullet10;
- function _reportPossibleCrUseOfPoolManager(extras) {
- _reporterNs.report("PoolManager", "../../core/manager/PoolManager", _context.meta, extras);
- }
- function _reportPossibleCrUseOfGame(extras) {
- _reporterNs.report("Game", "../../game/Game", _context.meta, extras);
- }
- function _reportPossibleCrUseOfBulletBase(extras) {
- _reporterNs.report("BulletBase", "../base/BulletBase", _context.meta, extras);
- }
- function _reportPossibleCrUseOfGunBase(extras) {
- _reporterNs.report("GunBase", "../base/GunBase", _context.meta, extras);
- }
- function _reportPossibleCrUseOfGun(extras) {
- _reporterNs.report("Gun10", "./Gun10", _context.meta, extras);
- }
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- geometry = _cc.geometry;
- PhysicsSystem = _cc.PhysicsSystem;
- RigidBody = _cc.RigidBody;
- }, function (_unresolved_2) {
- PoolManager = _unresolved_2.PoolManager;
- }, function (_unresolved_3) {
- Game = _unresolved_3.Game;
- }, function (_unresolved_4) {
- BulletBase = _unresolved_4.BulletBase;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "d795a460dJCIanwcZSOLmLj", "Bullet10", undefined);
- __checkObsolete__(['_decorator', 'Vec3', 'Node', 'geometry', 'PhysicsSystem', 'PhysicsRayResult', 'RigidBody']);
- ({
- ccclass,
- property
- } = _decorator); //1001敌人所使用的枪大兵手枪 OR 1007将军手枪所用的子弹
- _export("Bullet10", Bullet10 = (_dec = ccclass('Bullet10'), _dec(_class = class Bullet10 extends (_crd && BulletBase === void 0 ? (_reportPossibleCrUseOfBulletBase({
- error: Error()
- }), BulletBase) : BulletBase) {
- constructor() {
- super(...arguments);
- //是否必死 必死的子弹不会回收 要自己控制
- this.isRemoveDead = false;
- //射击方向的位置
- this.vector = null;
- }
- /**
- * 初始化一个子弹
- */
- /**
- * 初始化一个子弹
- * @param gun 属于哪把枪
- * @param isRemoveDead 是否不受控制的子弹自己管理
- */
- init(gun, isRemoveDead) {
- if (isRemoveDead === void 0) {
- isRemoveDead = false;
- }
- this.gunBase = gun;
- this.isDead = false;
- this.isRemoveDead = isRemoveDead;
- }
- /**
- * 设置子弹开始位置和射击方向
- * @param v 射向的方向
- */
- setBulletVector(v) {
- var bulletSpeed = this.gunBase.data.bulletSpeed;
- this.vector = v.clone().multiplyScalar(bulletSpeed);
- this.node.forward = v;
- this.rayPreCheck(bulletSpeed / 60);
- }
- /**
- * 射击速度发生改变
- */
- speedChange() {
- var bulletSpeed = this.gunBase.data.bulletSpeed;
- if (this.vector) {
- this.vector = this.vector.normalize().multiplyScalar(bulletSpeed);
- }
- }
- /**
- * 实时帧更新
- */
- update(deltaTime) {
- if ((_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.isGameOver || (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.isPause || this.isRemoveDead) {
- this.isDead = true;
- (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
- error: Error()
- }), PoolManager) : PoolManager).putNode(this.node);
- return;
- }
- if (this.vector) {
- var moveDelta = this.vector.clone().multiplyScalar(deltaTime);
- this.node.worldPosition = this.node.worldPosition.add(moveDelta);
- this.rayPreCheck(moveDelta.length());
- }
- }
- /**
- * 检测射击
- * @param b
- * @param len 检测
- */
- rayPreCheck(len) {
- var p = this.node.worldPosition;
- var ray = geometry.Ray.create(p.x, p.y, p.z, this.vector.x, this.vector.y, this.vector.z);
- var phy = PhysicsSystem.instance;
- var isHit = phy.raycast(ray, 0xffffff, len);
- if (isHit && phy.raycastResults.length > 0) {
- var result = phy.raycastResults[0];
- this.addImpact(result);
- if (result.collider.getComponent(RigidBody)) {
- result.collider.getComponent(RigidBody).applyForce(this.vector, result.hitPoint);
- }
- var name = result.collider.node.name;
- if (name == (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.head.name) {
- //敌人打玩家爆头
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.subHP(this.gunBase.data.attack, this.gunBase.data);
- } else if (name == (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.body.name) {
- //敌人打玩家身体
- (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I.player.subHP(this.gunBase.data.attack, this.gunBase.data);
- } //自动回收了子弹
- this.autoRecycle();
- }
- }
- /**
- * 加入射击中的效果
- * @param e 碰撞到的结果
- */
- addImpact(e) {
- var impact = (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
- error: Error()
- }), PoolManager) : PoolManager).getNode(this.gunBase.impact);
- impact.worldPosition = e.hitPoint.add(e.hitNormal.multiplyScalar(0.01));
- impact.forward = e.hitNormal.multiplyScalar(-1);
- impact.scale = this.node.scale;
- impact.setParent(e.collider.node, true);
- }
- }) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=a025321203cfe4d526aa288fae150433a1e08722.js.map
|