Kziwws 3 dias atrás
pai
commit
70bcbb09a8

+ 2 - 2
assets/data/csv/player_guns.csv

@@ -10,5 +10,5 @@ id,name,name_lang,type,type_name,type_icon,icon,prb_name,attack,bulletSpeed,stab
 100013,巴雷特Barrett M82A1,Barrett M82A1,1,Sniper,sniper,,barrettM82A1,150,750,100,5,250,450,attack_icon,bulletSpeed_icon,stability_icon,magazine_icon,reloadingSpeed_icon,zoomingSpeed_icon,not_unlock_M82A1,unlock_M82A1,unlock_98k,not_unlock_98k,sound/Barrett M82A1
 100014,步枪M416,M416,2,Rifle,rifle,,m416,25,750,30,30,450,300,attack_icon,bulletSpeed_icon,stability_icon,magazine_icon,reloadingSpeed_icon,zoomingSpeed_icon,not_unlock_m416,unlock_m416,unlock_m416,not_unlock_m416,sound/M416
 100015,步枪AKM,AKM,2,Rifle,rifle,,akm,35,720,35,30,450,300,attack_icon,bulletSpeed_icon,stability_icon,magazine_icon,reloadingSpeed_icon,zoomingSpeed_icon,not_unlock_akm,unlock_akm,unlock_m416,not_unlock_m416,sound/AK47
-100016,连狙VSS,VSS,3,Continuous Sniping,continuous_snip,,vss,33,600,60,10,400,450,attack_icon,bulletSpeed_icon,stability_icon,magazine_icon,reloadingSpeed_icon,zoomingSpeed_icon,not_unlock_vss,unlock_vss,unlock_vss,not_unlock_vss,sound/VSS
-100017,连狙SKS,SKS,3,Continuous Sniping,continuous_snip,,sks,46,650,60,12,400,450,attack_icon,bulletSpeed_icon,stability_icon,magazine_icon,reloadingSpeed_icon,zoomingSpeed_icon,not_unlock_sks,unlock_sks,unlock_vss,not_unlock_vss,sound/SKS
+100016,连狙VSS,VSS,3,Continuous Sniping,continuous_snip,,vss,33,600,60,12,400,450,attack_icon,bulletSpeed_icon,stability_icon,magazine_icon,reloadingSpeed_icon,zoomingSpeed_icon,not_unlock_vss,unlock_vss,unlock_vss,not_unlock_vss,sound/VSS
+100017,连狙SKS,SKS,3,Continuous Sniping,continuous_snip,,sks,46,650,60,15,400,450,attack_icon,bulletSpeed_icon,stability_icon,magazine_icon,reloadingSpeed_icon,zoomingSpeed_icon,not_unlock_sks,unlock_sks,unlock_vss,not_unlock_vss,sound/SKS

+ 1 - 1
assets/scripts/data/Constants.ts

@@ -2,7 +2,7 @@ import { Enemy } from "../game/Enemy";
 
 const Constants = {
     //是否是测试包
-    isDebug: false,
+    isDebug: true,
     //游戏名字
     gameName: "GunfightShoot",
 

+ 69 - 0
assets/scripts/data/GameEnums.ts

@@ -0,0 +1,69 @@
+/**
+ * 游戏枚举定义中心(驼峰式命名法版本)
+ * 集中管理所有游戏枚举类型,便于维护和使用
+ */
+export class GameEnums {
+    /** 碰撞体相关枚举 部位类型(碰撞体类型)*/
+    static readonly enemyPartType = {
+        head: "headCollider",      // 头部的碰撞体
+        body: "bodyCollider",      // 身体的碰撞体
+        tank: "tankCollider",      // 坦克的碰撞体
+        shield: "shieldCollider",  // 盾的碰撞体
+        sundries: "sundriesCollider" // 杂物的碰撞体
+    } as const;
+
+    /** 动画相关枚举  敌人动作类型 */
+    static readonly enemyAnimType = {
+        idle: "idle",     // 待机状态
+        die: "die",       // 死亡状态
+        shoot: "shoot",   // 射击状态
+        walk: "walk"      // 行走状态
+    } as const;
+
+    /** 玩家动作类型 */
+    static readonly playerAnimType = {
+        idle: "idle",     // 待机状态
+        die: "die",        // 死亡状态
+        reload: "reload"   // 换弹夹状态
+    } as const;
+
+    /**敌人相关枚举 敌人类型 */
+    static readonly enemyType = {
+        soldierPistol: 10001,     // 大兵 - 普通士兵,使用手枪
+        sniperSoldier: 10002,     // 狙击兵 - 远程攻击单位,使用狙击枪
+        shieldSoldier: 10003,     // 盾牌兵 - 高生命值防御单位,使用手枪和盾牌
+        snipeCaptain: 20001,      // 狙击队长 - BOSS单位,使用强力狙击枪
+        scatterCaptain: 20002,    // 机枪队长 - BOSS单位,使用高射速机关枪
+        tank: 20003,              // 坦克 - BOSS单位,高生命值重型单位
+        generalPistol: 20004      // 将军 - BOSS单位,综合型强力敌人
+    } as const;
+
+
+    /**武器相关枚举 武器类型 */
+    static readonly enemyWeaponType = {
+        pistol: 1001,      // 大兵手枪 将军手枪
+        sniper: 1002,      // 狙击兵狙击枪 狙击队长狙击枪
+        shield: 1003,      // 盾牌兵盾牌
+        scatter: 1005,     // 机枪队长机关枪
+        tankPao: 1006      // 坦克炮
+    } as const;
+
+    /** 枪械相关枚举 武器类型 */
+    static readonly palyerWeaponType = {
+        kar98k: 100010,       // 98K狙击步枪
+        m24: 100011,          // M24狙击步枪
+        awm: 100012,          // AWM狙击步枪
+        barrett: 100013,      // Barrett M82A1反器材步枪
+        m416: 100014,         // M416突击步枪
+        akm: 100015,          // AKM突击步枪
+        vss: 100016,          // VSS特种狙击步枪
+        sks: 100017           // SKS半自动步枪
+    } as const;
+
+    /** 武器主分类 */
+    static readonly weaponCategory = {
+        sniper: 1,      // 狙击枪(单发高伤害)
+        rifle: 2,       // 步枪(全自动/半自动)
+        dmr: 3          // 连狙(精确射手步枪)
+    } as const;
+}

+ 9 - 0
assets/scripts/data/GameEnums.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.24",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "e0d37f39-cbf8-43ca-b907-f2be55455c27",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 10 - 46
assets/scripts/game/Enemy.ts

@@ -11,46 +11,10 @@ import { GunBase } from '../items/base/GunBase';
 import { PoolManager } from '../core/manager/PoolManager';
 import { audioMgr } from '../core/manager/AudioManager';
 import { Constants } from '../data/Constants';
+import { GameEnums } from '../data/GameEnums';
 const { ccclass, property } = _decorator;
 
 
-//部位类型
-export enum EPartType {
-    head = "headCollider",  //头部的碰撞体
-    body = "bodyCollider",  //身体的碰撞体
-    tank = "tankCollider", //坦克的碰撞体
-    shield = "shieldCollider", //盾的碰撞体
-    sundries = "sundriesCollider", //杂物的碰撞体
-}
-
-//敌人动作类型
-export enum EAnimType {
-    idle = "idle",  //idle 待机状态
-    die = "die",  //die 死亡状态
-    shoot = "shoot", //shoot 射击状态
-    walk = "walk", //shoot 行走状态
-}
-
-//敌人类型枚举
-export enum EnemyType {
-    SoldierPistol = 10001,    // 大兵 - 普通士兵,使用手枪
-    SniperSoldier = 10002,   // 狙击兵 - 远程攻击单位,使用狙击枪
-    ShieldSoldier = 10003,   // 盾牌兵 - 高生命值防御单位,使用手枪和盾牌
-    SnipeCaptain = 20001,    // 狙击队长 - BOSS单位,使用强力狙击枪
-    ScatterCaptain = 20002, // 机枪队长 - BOSS单位,使用高射速机关枪
-    Tank = 20003,           // 坦克 - BOSS单位,高生命值重型单位
-    GeneralPistol = 20004   // 将军 - BOSS单位,综合型强力敌人
-}
-
-//武器类型枚举
-export enum WeaponType {
-    Pistol = 1001,    // 大兵手枪 将军手枪
-    Sniper = 1002,    // 狙击兵狙击枪 狙击队长狙击枪
-    Shield = 1003,    // 盾牌兵盾牌
-    Scatter = 1005,   // 机枪队长机关枪
-    Tank_Pao = 1006, // 坦克
-}
-
 @ccclass('Enemy')
 export class Enemy extends BaseExp {
     @autoBind({type: ProgressBar,tooltip: "敌人血量"})
@@ -139,13 +103,13 @@ export class Enemy extends BaseExp {
         const isTank:boolean = this.isTank();
         this.enemyNode = this.node.getChildByName(data.prb_name);
         if(isTank){
-            this.tankCollider["args"] = [EPartType.tank,this];
+            this.tankCollider["args"] = [GameEnums.enemyPartType.tank,this];
         }else{
-            this.headCollider["args"] = [EPartType.head,this];
-            this.bodyCollider["args"] = [EPartType.body,this];
+            this.headCollider["args"] = [GameEnums.enemyPartType.head,this];
+            this.bodyCollider["args"] = [GameEnums.enemyPartType.body,this];
             this.skeletalAnim = this.enemyNode.getComponent(SkeletalAnimation);
             if(this.skeletalAnim){
-               this.skeletalAnim?.play(EAnimType.idle);
+               this.skeletalAnim?.play(GameEnums.enemyAnimType.idle);
             }
         }
         if(!this.enemyNode){
@@ -217,7 +181,7 @@ export class Enemy extends BaseExp {
             shieldNode.parent = shieldPos.parent;
             shieldNode.worldPosition = shieldPos.worldPosition.clone();
             shieldNode.eulerAngles = shieldPos.eulerAngles.clone();
-            shieldNode.children[0].getComponent(Collider)["args"] = [EPartType.shield,this];
+            shieldNode.children[0].getComponent(Collider)["args"] = [GameEnums.enemyPartType.shield,this];
             this.shieldNode = shieldNode;
             this.shieldHp = sData.shield_hp;
         }
@@ -317,7 +281,7 @@ export class Enemy extends BaseExp {
            this.tank_walk.active = true;
            this.tank_shoot.active = false;
         }else{
-            ResUtil.playSkeletalAnim(this.skeletalAnim,EAnimType.walk,time);
+            ResUtil.playSkeletalAnim(this.skeletalAnim,GameEnums.enemyAnimType.walk,time);
         }
         this.updateDir(points[0].clone());
     }
@@ -364,7 +328,7 @@ export class Enemy extends BaseExp {
         //动画和回收时间
         let recycleTime: number = 2;
         if(!this.isTank()){
-           ResUtil.playSkeletalAnim(this.skeletalAnim,EAnimType.die);
+           ResUtil.playSkeletalAnim(this.skeletalAnim,GameEnums.enemyAnimType.die);
         }else{
             //坦克爆炸后生成爆炸特效 
             ResUtil.playParticle(
@@ -591,7 +555,7 @@ export class Enemy extends BaseExp {
                     this.tank_walk.active = false;
                     this.tank_shoot.active = true;
                 } else {
-                    ResUtil.playSkeletalAnim(this.skeletalAnim, EAnimType.shoot, this.data.atk_speed);
+                    ResUtil.playSkeletalAnim(this.skeletalAnim, GameEnums.enemyAnimType.shoot, this.data.atk_speed);
                 }
                 this.updateDir(Game.I.player.node.worldPosition);
             }
@@ -617,6 +581,6 @@ export class Enemy extends BaseExp {
      * 是否是坦克
      */
     public isTank():boolean{
-        return this.data.id == EnemyType.Tank;
+        return this.data.id == GameEnums.enemyType.tank;
     }
 }

+ 1 - 5
assets/scripts/game/Game.ts

@@ -47,9 +47,7 @@ export class Game extends BaseExp {
         this.canvas.active = true;
         this.map_pos.active = true;
         //加载map
-        this.loadMap(()=>{
-            audioMgr.play(Constants.audios.BGM,true);
-        });
+        this.loadMap();
     }
 
     /**
@@ -57,7 +55,6 @@ export class Game extends BaseExp {
      */
     public nextLevel(){
         userIns.data.level += 1;
-        //加载新的map
         this.loadMap(()=>{
             this.isGameOver = this.isPause = false;
             //刷新新的任务
@@ -71,7 +68,6 @@ export class Game extends BaseExp {
      * 重玩
      */
     public restart(){
-        //重新加载map
         this.loadMap(()=>{
             //创建玩家拥有的枪
             this.player.restart();

+ 11 - 2
assets/scripts/game/Main.ts

@@ -66,6 +66,7 @@ export class Main extends BaseExp {
         if(!Constants.isDebug){
            this.editBox.node.active = false;
         }
+        this.playBGM();
     }
 
     /**
@@ -132,12 +133,19 @@ export class Main extends BaseExp {
     public playOrStopBGM(isPlay: boolean){
         if(!this.audio_BGM)return;
         if(isPlay){
-            audioMgr.play(this.audio_BGM,true);
+            audioMgr.play(this.audio_BGM,true,2);
         }else{
-            audioMgr.stop(this.audio_BGM);
+            audioMgr.stop(this.audio_BGM,2);
         }
     }
 
+    /**
+     * 播放背景音乐
+     */
+    public playBGM(){
+        audioMgr.play(Constants.audios.BGM,true,2);
+    }
+
     /**
      * 开始游戏
      */
@@ -146,6 +154,7 @@ export class Main extends BaseExp {
            Game.I.loadMap();
         }
         userIns.data.cutNum -= 1;
+        audioMgr.stop(Constants.audios.BGM);
         //播放关卡背景音乐
         let bgms:string[] = [Constants.audios.bgm_1,Constants.audios.bgm_2,Constants.audios.bgm_3];
         this.audio_BGM = Utils.randomArray(bgms)[0];

+ 6 - 12
assets/scripts/game/Player.ts

@@ -13,15 +13,9 @@ import MsgHints from '../utils/MsgHints';
 import { PlayerCamera } from './PlayerCamera';
 import { audioMgr } from '../core/manager/AudioManager';
 import { Utils } from '../utils/Utils';
+import { GameEnums } from '../data/GameEnums';
 const { ccclass, property } = _decorator;
 
-//玩家动作类型
-export enum PAnimType {
-    idle = "idle",//idle 待机状态
-    die = "die",//die 死亡状态
-    reload = "reload",//reload 换弹夹状态
-}
-
 @ccclass('Player')
 export class Player extends BaseExp {
     @autoBind({type: Node,tooltip: "创建枪的位置"})
@@ -91,7 +85,7 @@ export class Player extends BaseExp {
     public loadGunName(name: string = this.pData.prb_name,isCut: boolean = false){
         if(Utils.isNull(name))return;
         //玩家待机状态
-        this.player_skeletal.play(PAnimType.idle);
+        this.player_skeletal.play(GameEnums.playerAnimType.idle);
         this.pData = userIns.getCurUseGun();
         this.curHP = this.pData.hp;
         if(!isCut && this.gun)return;
@@ -129,11 +123,11 @@ export class Player extends BaseExp {
         //时间 = (基准速度 / 当前速度) * 基准时间
         let time: number = (baseSpeed / data.reloadingSpeed) * baseTime;
         //换弹匣动画
-        ResUtil.playSkeletalAnim(this.player_skeletal,PAnimType.reload,time);
+        ResUtil.playSkeletalAnim(this.player_skeletal,GameEnums.playerAnimType.reload,time);
         this.shootUI.reloadMagazineing(time,()=>{
             this.isReloadMagazine = false;
             this.shootUI.gunDataUI();
-            this.player_skeletal?.play(PAnimType.idle);
+            this.player_skeletal?.play(GameEnums.playerAnimType.idle);
         });
     }
 
@@ -154,7 +148,7 @@ export class Player extends BaseExp {
         this.player_skeletal.unscheduleAllCallbacks();
         this.player_skeletal.stop();
         this.player_skeletal.node.active = true;
-        this.player_skeletal.play(PAnimType.idle);
+        this.player_skeletal.play(GameEnums.playerAnimType.idle);
     }
 
     /**
@@ -224,7 +218,7 @@ export class Player extends BaseExp {
             }]);
             this.isDead = true;
             this.recycle();
-            ResUtil.playSkeletalAnim(this.player_skeletal,PAnimType.die,1.5,()=>{
+            ResUtil.playSkeletalAnim(this.player_skeletal,GameEnums.playerAnimType.die,1.5,()=>{
                 this.player_skeletal.stop();
                 this.player_skeletal.node.active = false;
             });

+ 5 - 4
assets/scripts/items/player/Bullet1.ts

@@ -2,9 +2,10 @@ import { _decorator, Vec3,Node, geometry, PhysicsSystem, PhysicsRayResult} from
 import { Game } from '../../game/Game';
 import { GunBase } from '../base/GunBase';
 import { BulletBase } from '../base/BulletBase';
-import { Enemy, EPartType } from '../../game/Enemy';
 import { PoolManager } from '../../core/manager/PoolManager';
 import { Sundries } from '../../game/Sundries';
+import { Enemy } from '../../game/Enemy';
+import { GameEnums } from '../../data/GameEnums';
 const { ccclass, property } = _decorator;
 
 //玩家所用子弹 98k m24 awm BarrettM82A1 重狙子弹
@@ -107,13 +108,13 @@ export class Bullet1 extends BulletBase {
                     const e: Enemy = cls as Enemy;
                     //爆头击杀
                     let isHeadShot:boolean = false;
-                    if(type == EPartType.head){
+                    if(type == GameEnums.enemyPartType.head){
                         Game.I.player.headShotNum += 1;
                         attack = Game.I.player.pData.headshotDmgMul * attack;
                         isHeadShot = true;
                     }
                     //打到了盾兵上的盾
-                    if(type == EPartType.shield 
+                    if(type == GameEnums.enemyPartType.shield 
                         && e.shieldHp > 0){
                         e.shieldHp -= attack;
                         return;
@@ -121,7 +122,7 @@ export class Bullet1 extends BulletBase {
                     e.isShotHead = isHeadShot;
                     //坦克是单独的碰撞体
                     if(e.isTank()){
-                        if(type == EPartType.tank){
+                        if(type == GameEnums.enemyPartType.tank){
                            e.subHP(attack,this.gunBase.data);
                         }
                     }else{

+ 5 - 5
assets/scripts/items/player/Bullet2.ts

@@ -1,11 +1,11 @@
 import { _decorator, Vec3,Node, geometry, PhysicsSystem, PhysicsRayResult } from 'cc';
 import { PoolManager } from '../../core/manager/PoolManager';
 import { Game } from '../../game/Game';
-import { Enemy, EPartType } from '../../game/Enemy';
-import { Gun2 } from './Gun2';
 import { BulletBase } from '../base/BulletBase';
 import { GunBase } from '../base/GunBase';
 import { Sundries } from '../../game/Sundries';
+import { GameEnums } from '../../data/GameEnums';
+import { Enemy } from '../../game/Enemy';
 const { ccclass, property } = _decorator;
 
 //玩家所用子弹 步枪子弹
@@ -106,13 +106,13 @@ export class Bullet2 extends BulletBase {
                     const e: Enemy = cls as Enemy;
                     //爆头击杀
                     let isHeadShot:boolean = false;
-                    if(type == EPartType.head){
+                    if(type == GameEnums.enemyPartType.head){
                         Game.I.player.headShotNum += 1;
                         attack = Game.I.player.pData.headshotDmgMul * attack;
                         isHeadShot = true;
                     }
                     //打到了盾兵上的盾
-                    if(type == EPartType.shield 
+                    if(type == GameEnums.enemyPartType.shield 
                         && e.shieldHp > 0){
                         e.shieldHp -= attack;
                         return;
@@ -120,7 +120,7 @@ export class Bullet2 extends BulletBase {
                     e.isShotHead = isHeadShot;
                     //坦克是单独的碰撞体
                     if(e.isTank()){
-                        if(type == EPartType.tank){
+                        if(type == GameEnums.enemyPartType.tank){
                            e.subHP(attack,this.gunBase.data);
                         }
                     }else{

+ 5 - 4
assets/scripts/items/player/Bullet3.ts

@@ -1,10 +1,11 @@
 import { _decorator, Vec3,Node, geometry, PhysicsSystem, PhysicsRayResult} from 'cc';
 import { PoolManager } from '../../core/manager/PoolManager';
 import { Game } from '../../game/Game';
-import { Enemy, EPartType } from '../../game/Enemy';
 import { BulletBase } from '../base/BulletBase';
 import { GunBase } from '../base/GunBase';
 import { Sundries } from '../../game/Sundries';
+import { Enemy } from '../../game/Enemy';
+import { GameEnums } from '../../data/GameEnums';
 const { ccclass, property } = _decorator;
 
 //玩家所用子弹 连狙子弹
@@ -104,13 +105,13 @@ export class Bullet3 extends BulletBase {
                     const e: Enemy = cls as Enemy;
                     //爆头击杀
                     let isHeadShot:boolean = false;
-                    if(type == EPartType.head){
+                    if(type == GameEnums.enemyPartType.head){
                         Game.I.player.headShotNum += 1;
                         attack = Game.I.player.pData.headshotDmgMul * attack;
                         isHeadShot = true;
                     }
                     //打到了盾兵上的盾
-                    if(type == EPartType.shield 
+                    if(type == GameEnums.enemyPartType.shield 
                         && e.shieldHp > 0){
                         e.shieldHp -= attack;
                         return;
@@ -118,7 +119,7 @@ export class Bullet3 extends BulletBase {
                     e.isShotHead = isHeadShot;
                     //坦克是单独的碰撞体
                     if(e.isTank()){
-                        if(type == EPartType.tank){
+                        if(type == GameEnums.enemyPartType.tank){
                            e.subHP(attack,this.gunBase.data);
                         }
                     }else{

+ 30 - 3
assets/scripts/items/player/Gun3.ts

@@ -32,7 +32,9 @@ export class Gun3 extends GunBase {
     private isFristShot: boolean = false;
     //所有的烟雾
     public smokes: Array<Node> = []!
-    
+    //连发枪单次连发颗数
+    private burstFireCount = 3;
+
     onLoad() {
         this.bulletNode.active = false;
         this.muzzleNode.active = false;
@@ -56,7 +58,6 @@ export class Gun3 extends GunBase {
     //开火
     public fire() {
         this.isFire = true;
-        this.createBullet();
         this.playParticle(this.fireEffect);
     }
 
@@ -108,7 +109,6 @@ export class Gun3 extends GunBase {
             this.shotBullets = 0;
             this.ammoCb?.(this.data);
         }
-        this.endFire();
     }
 
     /**
@@ -148,6 +148,33 @@ export class Gun3 extends GunBase {
         return bullet;
     }
 
+    //激活调用 持续开火
+    protected update(dt: number): void {
+        let player: Player = Game.I.player;
+        if(!player
+            ||player.isDead
+            ||!this.isFire
+            ||Game.I.isPause
+            ||Game.I.isGameOver){
+            return;
+        }
+        if(Game.I.player.isReloadMagazine){
+            return;
+        }
+        //每0.4秒攻击一次 发射一颗子弹
+        this.curTime += dt;
+        if(this.curTime >= 0.22) {
+            this.burstFireCount --;
+            this.createBullet();
+            this.curTime = 0;
+            if(this.burstFireCount <= 0){
+                this.burstFireCount = 3;
+                this.endFire();
+                Game.I.player.shootUI.isScopeOpen = false;
+            }
+        }
+    }
+
     /**
      * 回收烟雾
     */

+ 62 - 42
assets/scripts/ui/GunfightShootUI.ts

@@ -1,4 +1,4 @@
-import { _decorator, EventTouch, Node, Quat, math, Camera, sys, Vec3, Label, geometry, ProgressBar, tween, easing, Tween, UIOpacity, game, PhysicsSystem, PhysicsRayResult } from 'cc';
+import { _decorator, EventTouch, Node, Quat, math, Camera, sys, Vec3, Label, geometry, ProgressBar, tween, easing, Tween, UIOpacity} from 'cc';
 import { Game } from '../game/Game';
 import { BaseExp } from '../core/base/BaseExp';
 import { autoBind } from '../extend/AutoBind';
@@ -12,6 +12,7 @@ import { BulletMagazine } from '../game/BulletMagazine';
 import { settingData } from '../data/SettingData';
 import i18n from '../core/i18n/runtime-scripts/LanguageData';
 import PlatformSystem from '../platform/PlatformSystem';
+import { GameEnums } from '../data/GameEnums';
 const { ccclass, property } = _decorator;
 const { clamp, toRadian } = math;
 
@@ -208,7 +209,8 @@ export class GunfightShootUI extends BaseExp {
         }
         this.crossHair.active = true;//准心
         //步枪没有开镜贴图
-        this.scopeOverlay.active = !this.isRifleGun();
+        const isRifle: boolean = this.weaponCategoryGun() == GameEnums.weaponCategory.rifle;
+        this.scopeOverlay.active = !isRifle;
         this.gun_name_label.string = gData.name_lang;
         const isSnipeGun: boolean = gData.type == 1;
         //换弹夹进度条
@@ -343,19 +345,25 @@ export class GunfightShootUI extends BaseExp {
      * 恢复原始视野
      */
      private onWheelRelease() {
+        if(Game.I.player.isReloadMagazine)return;
         if(!this.zoomValid){
             this.isScopeOpen = false;
             return
         }
-        //是步枪直接连续开火
-        if(!this.isRifleGun()){
-           Game.I.player.shoot();
-           this.scheduleOnce(()=>{
-                //检查是否在秒内完成放大 已经在update里开镜完成时调用 Game.I.player.shoot();
+        const type:number = this.weaponCategoryGun();
+        switch(type){
+            case GameEnums.weaponCategory.sniper://狙击枪
+                Game.I.player.shoot();
+                this.scheduleOnce(()=>{
+                    this.isScopeOpen = false;
+                },0.6)
+                break
+            case GameEnums.weaponCategory.dmr://连狙
+                Game.I.player.shoot();
+                break
+            case GameEnums.weaponCategory.rifle://步枪
                 this.isScopeOpen = false;
-            },0.6)
-        }else{
-            this.isScopeOpen = false;
+                break
         }
     }
 
@@ -363,16 +371,24 @@ export class GunfightShootUI extends BaseExp {
      * 开始开镜
      */
     private openScope() {
-        //从枪械数据获取参数
         const gData = Game.I.player.pData;
         if(!gData)return;
-        const isRifle: boolean = this.isRifleGun();
-        //是步枪直接连续开火
-        if(isRifle){
-           Game.I.player.shoot();
+        if(Game.I.player.isReloadMagazine)return;
+        const isRifle: boolean = this.weaponCategoryGun() == GameEnums.weaponCategory.rifle;
+        const type:number = this.weaponCategoryGun();
+        switch(type){
+            case GameEnums.weaponCategory.sniper://狙击枪
+                //这儿已经在onWheelRelease处理过了
+                break
+            case GameEnums.weaponCategory.dmr://连狙
+                //这儿已经在onWheelRelease处理过了
+                break
+            case GameEnums.weaponCategory.rifle://步枪 是步枪直接连续开火
+                Game.I.player.shoot();
+                break
         }
         this.isZoomingIn = true;
-        //将 zoomingSpeed 转换为持续时间(450对应1.2秒)
+        //将zoomingSpeed 转换为持续时间(450对应1.2秒)
         this.zoomDuration = 72 / gData.zoomingSpeed;
         //使用枪械类型决定视口倍数 步枪使用 rifleZoom 狙击枪使用 scopeZoom
         const zoomMultiplier = isRifle ? 
@@ -397,21 +413,20 @@ export class GunfightShootUI extends BaseExp {
     }
 
     /**
-     * 是否是步
+     * 判断是否属于某一种
      */
-    public isRifleGun(){
+    public weaponCategoryGun():number{
         const gData:any = Game.I.player.pData;
-        if(!gData)return false;
-        return gData.id == '100016' || gData.id == '100015';
-    }
-
-    /**
-     * 是否连发狙枪
-     */
-    public isRapidSnipeGun(){
-        const gData:any = Game.I.player.pData;
-        if(!gData)return false;
-        return gData.id == '100014' || gData.id == '100015';
+        if(!gData)return GameEnums.weaponCategory.sniper;
+        if(gData.id == GameEnums.palyerWeaponType.akm
+          ||gData.id == GameEnums.palyerWeaponType.m416){
+           return  GameEnums.weaponCategory.rifle;
+        }else if(gData.id == GameEnums.palyerWeaponType.vss 
+          ||gData.id == GameEnums.palyerWeaponType.sks){
+            return  GameEnums.weaponCategory.dmr;
+        }else {
+            return  GameEnums.weaponCategory.sniper;
+        }
     }
 
     /**
@@ -494,15 +509,21 @@ export class GunfightShootUI extends BaseExp {
         if (btnName === 'pause_btn') { // 暂停页面
             uiMgr.show(Constants.popUIs.pauseUI);
         }else if (btnName === 'shot_btn') {//射击
-            if(this.isRifleGun){
-                //模拟按下射击
-                this._isScopeOpen = true;
-                Game.I.player.shoot();
-                this.scheduleOnce(()=>{
-                    this._isScopeOpen = false;
-                },1.5)
-            }else{
-                Game.I.player.shoot();
+            let type:number = this.weaponCategoryGun();
+            switch(type){
+                case GameEnums.weaponCategory.sniper://狙击枪
+                    Game.I.player.shoot();
+                    break
+                case GameEnums.weaponCategory.rifle://步枪
+                    this._isScopeOpen = true;
+                    Game.I.player.shoot();
+                    this.scheduleOnce(()=>{
+                        this._isScopeOpen = false;
+                    },1.5)
+                    break
+                case GameEnums.weaponCategory.dmr://连狙
+                    Game.I.player.shoot();
+                    break
             }
         }else if (btnName === 'cut_gun_btn') {//切枪
             if(userIns.data.guns.length <= 1)return;
@@ -539,20 +560,19 @@ export class GunfightShootUI extends BaseExp {
      * @param deltaTime - 上一帧到当前帧的时间间隔
      */
     update(deltaTime: number) {
-        if (this.isZoomingIn) {
+        if(this.isZoomingIn) {
             const currentFov = Game.I.camera.fov;
             if (currentFov > this.targetFov) {
                 const newFov = currentFov - this.zoomSpeed * deltaTime;
                 Game.I.camera.fov = Math.max(newFov, this.targetFov);
-            } else {
-                //检查是否在2秒内完成放大
+            }else {//检查是否在2秒内完成放大
                 const elapsedTime = (sys.now() - this.zoomStartTime) / 1000;
                 if (elapsedTime <= 1.5) {
                     this.zoomValid = true;
                 }
                 this.isZoomingIn = false;
             }
-        } else if (this.isZoomingOut) {
+        }else if(this.isZoomingOut) {
             const currentFov = Game.I.camera.fov;
             if (currentFov < this.originalFov) {
                 const newFov = currentFov + this.zoomSpeed * deltaTime;

+ 1 - 0
assets/scripts/ui/PauseUI.ts

@@ -27,6 +27,7 @@ export class PauseUI extends BaseExp {
         if(btnName === 'back_main_btn'){//返回首页
             Game.I.isGameOver = true;
             uiMgr.pop(Constants.mainUIs.main);
+            uiMgr.getPageComponent(Constants.mainUIs.main)?.playBGM();
         }else if(btnName === 'continue_btn'){
             uiMgr.hide(Constants.popUIs.pauseUI,()=>{
                 Game.I.isPause = false;

+ 1 - 1
profiles/v2/packages/reference-image.json

@@ -3,6 +3,6 @@
   "config": {
     "images": [],
     "sceneUUID": {},
-    "scene": "6fdfa45a-54d2-427e-9510-d0cbbbc63997"
+    "scene": "10795865-5525-41fc-8bf7-0e8d6983b214"
   }
 }