Kziwws пре 1 недеља
родитељ
комит
fad9cc77a3

+ 101 - 101
assets/prefabs/map/map1.prefab

@@ -46287,10 +46287,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.6680484311697188,
-      "y": -0.2317569710098867,
-      "z": -0.23175697100988665,
-      "w": 0.6680484311697189
+      "x": 0,
+      "y": 1,
+      "z": 0,
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -46302,8 +46302,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90,
-      "y": -38.265,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -46383,10 +46383,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -46398,7 +46398,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -48509,10 +48509,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911909,
-      "y": 0,
+      "x": 0,
+      "y": 1,
       "z": 0,
-      "w": 0.7071067215818991
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -48524,8 +48524,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90.00000965934633,
-      "y": 0,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -48605,10 +48605,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -48620,7 +48620,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -50731,10 +50731,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911909,
-      "y": 0,
+      "x": 0,
+      "y": 1,
       "z": 0,
-      "w": 0.7071067215818991
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -50746,8 +50746,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90.00000965934633,
-      "y": 0,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -50827,10 +50827,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -50842,7 +50842,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -52953,10 +52953,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911909,
-      "y": 0,
+      "x": 0,
+      "y": 1,
       "z": 0,
-      "w": 0.7071067215818991
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -52968,8 +52968,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90.00000965934633,
-      "y": 0,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -53049,10 +53049,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -53064,7 +53064,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -55175,10 +55175,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911909,
-      "y": 0,
+      "x": 0,
+      "y": 1,
       "z": 0,
-      "w": 0.7071067215818991
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -55190,8 +55190,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90.00000965934633,
-      "y": 0,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -55271,10 +55271,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -55286,7 +55286,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -57397,10 +57397,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.5,
-      "y": -0.5,
-      "z": -0.4999999999999999,
-      "w": 0.5000000000000001
+      "x": 0,
+      "y": 1,
+      "z": 0,
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -57412,8 +57412,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90,
-      "y": -90,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -57493,10 +57493,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -57508,7 +57508,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -59619,10 +59619,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.5,
-      "y": -0.5,
-      "z": -0.4999999999999999,
-      "w": 0.5000000000000001
+      "x": 0,
+      "y": 1,
+      "z": 0,
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -59634,8 +59634,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90,
-      "y": -90,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -59715,10 +59715,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -59730,7 +59730,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -61841,10 +61841,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.5,
-      "y": -0.5,
-      "z": -0.4999999999999999,
-      "w": 0.5000000000000001
+      "x": 0,
+      "y": 1,
+      "z": 0,
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -61856,8 +61856,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90,
-      "y": -90,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -61937,10 +61937,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -61952,7 +61952,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -64063,10 +64063,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911909,
-      "y": 0,
+      "x": 0,
+      "y": 1,
       "z": 0,
-      "w": 0.7071067215818991
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -64078,8 +64078,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90.00000965934633,
-      "y": 0,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -64159,10 +64159,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -64174,7 +64174,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -66285,10 +66285,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911909,
-      "y": 0,
+      "x": 0,
+      "y": 1,
       "z": 0,
-      "w": 0.7071067215818991
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -66300,8 +66300,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90.00000965934633,
-      "y": 0,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -66381,10 +66381,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -66396,7 +66396,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -68507,10 +68507,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911909,
-      "y": 0,
+      "x": 0,
+      "y": 1,
       "z": 0,
-      "w": 0.7071067215818991
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -68522,8 +68522,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90.00000965934633,
-      "y": 0,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -68603,10 +68603,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -68618,7 +68618,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },
@@ -70729,10 +70729,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.6680484311697188,
-      "y": -0.2317569710098867,
-      "z": -0.23175697100988665,
-      "w": 0.6680484311697189
+      "x": 0,
+      "y": 1,
+      "z": 0,
+      "w": 6.123233995736766e-17
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -70744,8 +70744,8 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": -90,
-      "y": -38.265,
+      "x": 0,
+      "y": 180,
       "z": 0
     },
     "_id": ""
@@ -70825,10 +70825,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0,
+      "x": -0.7071067811865475,
       "y": 0,
       "z": 0,
-      "w": 1
+      "w": 0.7071067811865476
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -70840,7 +70840,7 @@
     "_layer": 8388608,
     "_euler": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -90,
       "y": 0,
       "z": 0
     },

+ 89 - 61
assets/scripts/data/UserData.ts

@@ -1,4 +1,4 @@
-import { _decorator, sys, utils} from "cc";
+import { _decorator, game, sys, utils} from "cc";
 import { Singleton } from "../core/manager/Singleton";
 import { Constants } from "./Constants";
 import { Utils } from "../utils/Utils";
@@ -6,11 +6,28 @@ import { csvMgr } from "../core/csv/CsvManager";
 import { stateMgr } from "../core/manager/StateManager";
 const { ccclass, property } = _decorator;
 
+/* 
+@description 枪的属性值
+ */
+export enum GunAttribute {
+    /**伤害攻击*/
+    attack = "attack",
+    /**子弹速度*/
+    bulletSpeed = "bulletSpeed",
+    /**稳定性*/
+    stability = "stability",
+    /**弹夹容量*/
+    magazine = "magazine",
+    /**换弹速度*/
+    reloadingSpeed = "reloadingSpeed",
+    /**镜头缩放速度*/
+    zoomingSpeed = "zoomingSpeed"
+}
+
 @ccclass("UserData")
 class UserData extends Singleton {
     //枪的属性列表
-    public gunAttrKeys:string[] = ["attack","bulletSpeed","stability","magazine",
-                               "reloadingSpeed","zoomingSpeed"];
+    public gunAttrKeys:string[] = Object.values(GunAttribute);
     //玩家是否连续通关 如果连续通关 这个值会大于1
     public passNum: number = 0;
     //玩家数据
@@ -152,7 +169,7 @@ class UserData extends Singleton {
                 guns: [],//玩家拥有的枪
                 useIdx: 0,
             };
-            this.getGunData(configData.defaultWeapon,true);
+            this.getGunData(configData.defaultWeapon,true,'');
         }
     }
 
@@ -160,71 +177,82 @@ class UserData extends Singleton {
      * 查询一个枪的数据 顺带把枪的属性等级提升的部分参数带过来
      * @param id 枪的id
      * @param isSave 是否保存绑定在玩家身上
+     * @param attr_name 属性名字这儿要升级 只有当第一个的没有拥有这把枪的时候 才不传值
+     * 如果是已经 拥有了这把枪 要升级属性时,这个方法不要重复调用,因为会 加等级上的参数值 原因是这个要没把枪持久化数据保存
      * @returns 返回枪查询的枪的数据
      */
-    public getGunData(id: string,isSave: boolean = false):any{
+    private getGunData(id: string,isSave: boolean = false,attr_name: string = ''):any{
         //如果玩家已经拥有该枪 则直接返回
         let gData: any = this._data.guns.find(e=>e.id == id);
         if(!gData){
             gData = Utils.clone(this.playerGunsTable).find(e=>e.id == id);
         }
         if(!gData)return;
-        this.gunAttrKeys.forEach((arg_name:string,idx: number) => {
-            const levelKey:string = `${arg_name}Level`;
-            let attrLevel:number = 1;
-            if(gData[levelKey] != null){
-               attrLevel = gData[levelKey];
-            }
-            let fun: Function = (i,l,name)=>{
-                return this.playerGunAttsTable.find(
-                    e=>e.id == i 
-                    && e.level == l
-                    && e.attribute_name == name);
-            };
-            let glData:any = fun(id,attrLevel,arg_name);
-            if(glData){
-                let nextGLData:any = fun(id,attrLevel + 1,arg_name);
-                if(!nextGLData){nextGLData = glData};
-                //unique_id 这个字段为了识别到时候同一个属性 升级极端情况下 材料消耗相同的时候的判断
-                if(idx == 0){
-                    gData.attack += glData.value;//伤害
-                    gData.attackUniqueId = nextGLData.unique_id;//属性等级下的唯一id
-                    gData.attackLevel= glData.level;//属性等级
-                    gData.attackExpenditure = glData.expenditure;//当前等级消耗
-                    gData.nextAttackExpenditure = nextGLData ? nextGLData.expenditure : null;//伤害下一个等级升级消耗
-                }else if(idx == 1){
-                    gData.bulletSpeed += glData.value;//射速
-                    gData.bulletSpeedUniqueId = nextGLData.unique_id;//属性等级下的唯一id
-                    gData.bulletSpeedLevel= glData.level;//属性等级
-                    gData.bulletSpeedExpenditure = glData.expenditure;
-                    gData.nextBulletSpeedExpenditure = nextGLData ? nextGLData.expenditure : null;//射速下一个等级升级消耗
-                }else if(idx == 2){
-                    gData.stability	+= glData.value;//稳定性
-                    gData.stabilityUniqueId = nextGLData.unique_id;//属性等级下的唯一id
-                    gData.stabilityLevel= glData.level;//属性等级
-                    gData.stabilityExpenditure = glData.expenditure;
-                    gData.nextStabilityExpenditure = nextGLData ? nextGLData.expenditure : null;//稳定性下一个等级升级消耗
-                }else if(idx == 3){
-                    gData.magazine+= glData.value;//弹匣
-                    gData.magazineUniqueId = nextGLData.unique_id;//属性等级下的唯一id
-                    gData.magazineLevel= glData.level;//属性等级
-                    gData.magazineExpenditure = glData.expenditure;
-                    gData.nextMagazineExpenditure = nextGLData ? nextGLData.expenditure : null;//弹匣下一个等级升级消耗
-                }else if(idx == 4){
-                    gData.reloadingSpeed += glData.value;//装填速度
-                    gData.reloadingSpeedUniqueId = nextGLData.unique_id;//属性等级下的唯一id
-                    gData.reloadingSpeedLevel= glData.level;//属性等级
-                    gData.reloadingSpeedExpenditure = glData.expenditure;
-                    gData.nextReloadingSpeedExpenditure = nextGLData ? nextGLData.expenditure : null;//装填速度下一个等级升级消耗
-                }else if(idx == 5){
-                    gData.zoomingSpeed += glData.value;//缩放速度
-                    gData.zoomingSpeedUniqueId = nextGLData.unique_id;//属性等级下的唯一id
-                    gData.zoomingSpeedLevel= glData.level;//属性等级
-                    gData.zoomingSpeedExpenditure = glData.expenditure;
-                    gData.nextZoomingSpeedExpenditure = nextGLData ? nextGLData.expenditure : null;//缩放速度下一个等级升级消耗
+        //属性名字这儿要升级 只有没有拥有这把枪的时候attr_name才默认不传值
+        let attrKeys:any[] = Utils.clone(this.gunAttrKeys);
+        if(!Utils.isNull(attr_name)){
+            attrKeys = attrKeys.filter(e=>e == attr_name);
+        }
+        if(gData.hasAttrs == null
+            || !Utils.isNull(attr_name)){
+            attrKeys.forEach(name => {
+                const levelKey:string = `${name}Level`;
+                let attrLevel:number = 1;
+                if(gData[levelKey] != null){
+                attrLevel = gData[levelKey];
                 }
-            }
-        });
+                let fun: Function = (i,l,name)=>{
+                    return this.playerGunAttsTable.find(
+                        e=>e.id == i 
+                        && e.level == l
+                        && e.attribute_name == name);
+                };
+                let glData:any = fun(id,attrLevel,name);
+                if(glData){
+                    let nextGLData:any = fun(id,attrLevel + 1,name);
+                    if(!nextGLData){nextGLData = glData};
+                    //unique_id 这个字段为了识别到时候同一个属性 升级极端情况下 材料消耗相同的时候的判断
+                    if(name == GunAttribute.attack){
+                        gData.attack += glData.value;//伤害
+                        gData.attackUniqueId = nextGLData.unique_id;//属性等级下的唯一id
+                        gData.attackLevel= glData.level;//属性等级
+                        gData.attackExpenditure = glData.expenditure;//当前等级消耗
+                        gData.nextAttackExpenditure = nextGLData ? nextGLData.expenditure : null;//伤害下一个等级升级消耗
+                    }else if(name == GunAttribute.bulletSpeed){
+                        gData.bulletSpeed += glData.value;//射速
+                        gData.bulletSpeedUniqueId = nextGLData.unique_id;//属性等级下的唯一id
+                        gData.bulletSpeedLevel= glData.level;//属性等级
+                        gData.bulletSpeedExpenditure = glData.expenditure;
+                        gData.nextBulletSpeedExpenditure = nextGLData ? nextGLData.expenditure : null;//射速下一个等级升级消耗
+                    }else if(name == GunAttribute.stability){
+                        gData.stability	+= glData.value;//稳定性
+                        gData.stabilityUniqueId = nextGLData.unique_id;//属性等级下的唯一id
+                        gData.stabilityLevel= glData.level;//属性等级
+                        gData.stabilityExpenditure = glData.expenditure;
+                        gData.nextStabilityExpenditure = nextGLData ? nextGLData.expenditure : null;//稳定性下一个等级升级消耗
+                    }else if(name == GunAttribute.magazine){
+                        gData.magazine+= glData.value;//弹匣
+                        gData.magazineUniqueId = nextGLData.unique_id;//属性等级下的唯一id
+                        gData.magazineLevel= glData.level;//属性等级
+                        gData.magazineExpenditure = glData.expenditure;
+                        gData.nextMagazineExpenditure = nextGLData ? nextGLData.expenditure : null;//弹匣下一个等级升级消耗
+                    }else if(name == GunAttribute.reloadingSpeed){
+                        gData.reloadingSpeed += glData.value;//装填速度
+                        gData.reloadingSpeedUniqueId = nextGLData.unique_id;//属性等级下的唯一id
+                        gData.reloadingSpeedLevel= glData.level;//属性等级
+                        gData.reloadingSpeedExpenditure = glData.expenditure;
+                        gData.nextReloadingSpeedExpenditure = nextGLData ? nextGLData.expenditure : null;//装填速度下一个等级升级消耗
+                    }else if(name == GunAttribute.zoomingSpeed){
+                        gData.zoomingSpeed += glData.value;//缩放速度
+                        gData.zoomingSpeedUniqueId = nextGLData.unique_id;//属性等级下的唯一id
+                        gData.zoomingSpeedLevel= glData.level;//属性等级
+                        gData.zoomingSpeedExpenditure = glData.expenditure;
+                        gData.nextZoomingSpeedExpenditure = nextGLData ? nextGLData.expenditure : null;//缩放速度下一个等级升级消耗
+                    }
+                }
+            });
+        }
+        gData.hasAttrs = true;
         if(isSave){
             let indx: number = this._data.guns.findIndex(e=>e.id == gData.id);
             if(indx == -1){
@@ -276,7 +304,7 @@ class UserData extends Singleton {
         //查询属性的等级
         const attrLevelKey:string = `${attribute_name}Level`;
         hasGun[attrLevelKey]+= 1;
-        this.getGunData(gun.id,true);
+        this.getGunData(gun.id,true,attribute_name);
     }
 
     /**

+ 4 - 53
assets/scripts/game/BuildEnemys.ts

@@ -1,11 +1,10 @@
 
-import { _decorator, Component, Node, Vec3, Animation } from 'cc';
+import { _decorator, Component, Node, Vec3} from 'cc';
 import { ResUtil } from '../utils/ResUtil';
 import { Game } from './Game';
 import { Utils } from '../utils/Utils';
 import { userIns } from '../data/UserData';
 import { Enemy } from './Enemy';
-import { GMap } from './GMap';
 import { uiMgr } from '../core/manager/UIManager';
 import { Constants } from '../data/Constants';
 import { audioMgr } from '../core/manager/AudioManager';
@@ -29,18 +28,12 @@ export class BuildEnemys extends Component {
     public allEnemys: Array<Enemy> = [];
     //每连杀3个敌人的次数
     public continuekillCount: number = 0;
-     //敌人排序定时器
-    private intervalId: number = 0;
+    //是否需要打开门
+    public isOpenDoor: boolean = false;
 
     start(): void {
         //加载敌人数据
         this.allEnemys = [];
-        //敌人排序
-        /*if(this.intervalId!= null){clearInterval(this.intervalId);}
-        this.intervalId = setInterval((dt: number)=>{
-            if(Game.I.isGameOver || Game.I.isPause) return;
-            this.sortEnemyList();
-        },0.25 * 1000);*/
     }
 
     /**
@@ -50,6 +43,7 @@ export class BuildEnemys extends Component {
         if(Game.I.isGameOver 
             || Game.I.isPause)return;
         this.recycle();
+        this.isOpenDoor = false;
         this.queueEnemys = this.readLevelEnemys();
         //总共每一个敌人延迟时间统计 0.1s检测一次
         let delay: number = 0;
@@ -89,10 +83,6 @@ export class BuildEnemys extends Component {
             },interval * 1000);
             this.eTimeMaps.set(tData,time_id);
         }
-        //敌人创建完成后 播放开门动画
-        this.scheduleOnce(()=>{
-            Game.I.map.openDoor();
-        },delay);
     }
 
 
@@ -190,39 +180,6 @@ export class BuildEnemys extends Component {
         }
     }
 
-    /**
-     * 敌人节点排序
-     */
-    public sortEnemyList(){
-        if(Game.I.isPause 
-            || Game.I.isGameOver)return;
-        if(this.allEnemys.length <= 1)return;
-        return;
-        const minSortNum: number = 400;
-        let k: number = this.allEnemys.length + 20; 
-        if(this.allEnemys.length == 1){
-            if(this.allEnemys[0].node.parent){
-               this.allEnemys[0].node.setSiblingIndex(k + minSortNum);
-            }
-        }else{
-            this.allEnemys.sort(function(x,y){
-                let a: Vec3 = x.node.position;
-                let b: Vec3 = y.node.position;
-                if( a.y - b.y > 0.01 ){
-                    return -1;
-                }else if( a.y == b.y ){
-                    return 0;
-                }
-                return 1;
-            });
-            for (let i = 0; i < this.allEnemys.length; i++) {
-                if(this.allEnemys[0].node.parent){
-                   this.allEnemys[i].node.setSiblingIndex(i + k + minSortNum);
-                }
-            }
-        }
-    }
-
     /**
      * 销毁数据
      */
@@ -245,11 +202,5 @@ export class BuildEnemys extends Component {
     public getCurKillNum(): number{
         return this.queueEnemys.length - this.allEnemys.length;
     }
-
-    public onDisable () {
-        if(this.intervalId!= null){
-           clearInterval(this.intervalId);
-        }
-    }
 }
 

+ 42 - 89
assets/scripts/game/Enemy.ts

@@ -482,45 +482,56 @@ export class Enemy extends BaseExp {
             || Game.I.isPause 
             || !this.data 
             || this.isDead) return;
-        if(this.curMoveIndex >= this.pathList.length) {
-           return;
-        }
-        dt = dt / Game.I.map.multiplySpeed();
         const targetPos = this.pathList[this.curMoveIndex];
+        if(!targetPos)return;
+        //保持速度调节逻辑
+        dt = dt / Game.I.map.multiplySpeed();
         const currentPos = this.node.worldPosition.clone();
-        const moveDirection = new Vec3();
-        Vec3.subtract(moveDirection, targetPos, currentPos);
-        const distanceToTarget = moveDirection.length();
+        const toTarget = targetPos.clone().subtract(currentPos);
+        //敌人移动
+        const moveDir = new Vec3();
+        Vec3.subtract(moveDir, targetPos, currentPos);
+        let distance:number = moveDir.length();
+        //计算实际应移动距离
         const moveDistance = this.speed * dt;
-        const normalizedDir = moveDirection.normalize();
-        if(distanceToTarget > 0.1) { 
-            const newPos = currentPos.add(normalizedDir.multiplyScalar(moveDistance));
-            this.node.worldPosition = newPos;
-            //根据是否是最后一个路径点选择目标坐标
+        if(moveDistance > 0) {
+            //使用标准化方向向量 + 实际移动距离
+            const newPos = currentPos.add(toTarget.normalize().multiplyScalar(moveDistance));
+            //添加移动平滑过渡 平滑系数 10-15比较好 值越大越平滑
+            const smoothFactor = 20;
+            this.node.worldPosition = Vec3.lerp(
+                new Vec3(),
+                currentPos,
+                newPos,
+                Math.min(1, dt * smoothFactor)
+            );
+            //更新方向
             const isLastPathPoint = this.curMoveIndex == this.pathList.length - 1;
             const dirTarget = isLastPathPoint 
                 ? Game.I.player.node.worldPosition
                 : this.pathList[this.curMoveIndex + 1]; 
-            this.updateDir(dirTarget); // 仅传递目标坐标
-        }else{//到达当前路径点后切换目标
-            this.curMoveIndex++;
-            if(this.curMoveIndex < this.pathList.length) {
-                //切换路径点时修正方向(指向新的目标点)
-                const nextTarget = this.pathList[this.curMoveIndex];
-                this.updateDir(nextTarget); // 传递下一个路径点
-            }
+            this.updateDir(dirTarget);
         }
-        //到达所有路径终点处理
-        if(this.curMoveIndex >= this.pathList.length) {
-            this.beginFire();
-            if(this.isTank()){
-                this.tank_walk.active = false;
-                this.tank_shoot.active = true;
-            }else{
-                const time: number = 1 / this.data.atk_speed;
-                ResUtil.playSkeletalAnim(this.skeletalAnim,EAnimType.walk,time);
+        //到达判断增加缓冲范围
+        if(moveDistance > distance) {
+            //从出生点走到第二个点就是外门第一个点就开门 并且门没有被打开
+            if(this.curMoveIndex == 1 
+                && !Game.I.buildEnemys.isOpenDoor){
+                Game.I.map.openDoor();
+                Game.I.buildEnemys.isOpenDoor = true;
+            }
+            this.curMoveIndex++;
+            if (this.curMoveIndex >= this.pathList.length) {
+                this.beginFire();
+                if(this.isTank()){
+                    this.tank_walk.active = false;
+                    this.tank_shoot.active = true;
+                } else {
+                    const time: number = 1 / this.data.atk_speed;
+                    ResUtil.playSkeletalAnim(this.skeletalAnim, EAnimType.shoot, time);
+                }
+                this.updateDir(Game.I.player.node.worldPosition);
             }
-            this.updateDir(Game.I.player.node.worldPosition); // 终点指向玩家
         }
     }
 
@@ -545,62 +556,4 @@ export class Enemy extends BaseExp {
     public isTank():boolean{
         return this.data.id == EnemyType.Tank;
     }
-}
-
-
-/**
- * 
-    if (this.isDead 
-        || !this.player) return;
-    if (!this.isAlert) {
-        this.skeletalAnim.play(EAnimType.walk);
-        const playerPos = this.player.node.getWorldPosition();
-        const enemyPos = this.node.getWorldPosition();
-        //创建射线对象修复类型错误
-        const ray = new geometry.Ray();
-        ray.o = enemyPos;
-        ray.d = playerPos.subtract(enemyPos).normalize();
-        //修正物理检测参数
-        if (PhysicsSystem.instance.raycast(ray, 1 << 0, 2)) {
-            const randomDir = Math.random() > 0.5 ? 1 : -1;
-            //修改为正确的参数格式
-            const quat = new Quat();
-            Quat.fromAxisAngle(quat, Vec3.UP, 45 * randomDir * Math.PI / 180);
-            this.node.rotate(quat, NodeSpace.WORLD);
-        }
-        //this.skeletalAnim.play("walk");
-        //使用定时器持续移动
-        this.schedule(() => {
-            const distance: number = Vec3.distance(this.node.worldPosition,Game.I.buildEnemys.ambush.worldPosition);
-            if(distance < 10) {
-                this.isAlert = true;
-                this.walk();
-                return;
-            }
-            const moveVec = this.node.forward.negative().multiplyScalar(this.speed * 0.016);
-            this.node.position = this.node.position.add(moveVec);
-        }, 0.1);
-    } else if (!this.currentCover) {
-        const nearestCover = this.findNearestCover();
-        if (nearestCover) {
-            this.currentCover = nearestCover;
-            //生成Z轴随机偏移(-18到+18)
-            const targetPos = nearestCover.worldPosition.clone();
-            targetPos.z += Math.random() * 36 - 18;
-            //移动到掩体位置 直接使用缓动动画移动到掩体
-            tween(this.node)
-            .to(2, { worldPosition: targetPos }, {
-                easing: easing.quadOut,
-                onStart: () => {
-                    this.speed = this.defaultSpeed * 1.5; //加速移动
-                },
-                onComplete: () => {
-                    this.skeletalAnim.play(EAnimType.shoot);
-                    this.beginFire(); //到达后开始攻击
-                    this.currentCover = nearestCover;
-                }
-            })
-            .start();
-        }
-    }
- */
+}

+ 4 - 4
assets/scripts/game/GMap.ts

@@ -60,8 +60,8 @@ export class GMap extends BaseExp {
         if(left){//左门动画
             tween(left)
                 .delay(0.2)
-                .to(0.85, { eulerAngles: new Vec3(90, 0, 0) }, {
-                    easing: easing.quadIn,
+                .to(0.7, { eulerAngles: new Vec3(90, 0, 0) }, {
+                    easing: easing.elasticOut,
                     onUpdate: (target, ratio: number) => {
                         target.setRotationFromEuler(target.eulerAngles);
                     }
@@ -71,8 +71,8 @@ export class GMap extends BaseExp {
         const right: Node = this.doors.children[1];
         if(right){//右门动画
             tween(right)
-                .to(0.85, { eulerAngles: new Vec3(90, 0, 0) }, {
-                    easing: easing.quadIn,
+                .to(0.7, { eulerAngles: new Vec3(90, 0, 0) }, {
+                    easing: easing.elasticOut,
                     onUpdate: (target, ratio: number) => {
                         target.setRotationFromEuler(target.eulerAngles);
                     }

+ 5 - 9
assets/scripts/game/Sundries.ts

@@ -1,15 +1,13 @@
-import { _decorator, Collider, Enum, Node, RigidBody, Animation, Vec3 } from 'cc';
+import { _decorator, Animation, Collider, Enum, Node, RigidBody, Vec3 } from 'cc';
 import { BaseExp } from '../core/base/BaseExp';
 import { PoolManager } from '../core/manager/PoolManager';
 import { userIns } from '../data/UserData';
-import { autoBind } from '../extend/AutoBind';
 import { Logger } from '../extend/Logger';
 import { ResUtil } from '../utils/ResUtil';
 import { Game } from './Game';
 import { Enemy, EPartType } from './Enemy';
 import { audioMgr } from '../core/manager/AudioManager';
 import { Constants } from '../data/Constants';
-import MsgHints from '../utils/MsgHints';
 const { ccclass, property } = _decorator;
 
 //沙袋堆动画
@@ -108,13 +106,11 @@ export class Sundries extends BaseExp {
     public scrap(){
         switch (this.obstacleType) {
             case ObstacleType.SANDBAG_PILE:{//沙袋堆
-                    let skeletal:Animation = this.node.getComponent(Animation);
-                    if(!skeletal)return;
                     //沙袋掀开的动画
-                    skeletal.play(sandbge_take);
-                    skeletal.scheduleOnce(()=>{
-                        skeletal.pause();
-                    },0.9);
+                    let anim:Animation = this.node.getComponent(Animation);
+                    if(!anim)return;
+                    anim.getState(sandbge_take).repeatCount = 1;
+                    anim.play(sandbge_take);
                 }
                 break;
             case ObstacleType.OIL_BARREL:{//油桶

+ 5 - 0
assets/scripts/ui/ArsenalUI.ts

@@ -10,6 +10,7 @@ import { GunTypeItem } from '../items/item/GunTypeItem';
 import { uiMgr } from '../core/manager/UIManager';
 import { Constants } from '../data/Constants';
 import MsgHints from '../utils/MsgHints';
+import { Game } from '../game/Game';
 const { ccclass, property } = _decorator;
 
 @ccclass('ArsenalUI')
@@ -151,8 +152,12 @@ export class ArsenalUI extends BaseExp {
     public setGunListItemData(item: Node, idx: number) {
         let com:GunItem = item.getComponent(GunItem);
         com.init(this.gunList[idx],(gunData:any)=>{
+            if(gunData.id == this.curGunData.id)return;
             this.curGunData = gunData;
             this.loadArsenalData(this.curTypeData);
+            //给玩家把枪也切换了
+            userIns.changeGun(gunData.id);
+            Game.I?.player?.loadGunName(gunData.prb_name,true);
         }); 
     }
 

+ 2 - 2
assets/scripts/ui/StoreUI.ts

@@ -114,9 +114,9 @@ export class StoreUI extends BaseExp {
                 }else{
                     MsgHints.show(`Watch ${num - data.alreadyVideo} more times to purchase successfully!`);
                 }
-                if(data.type === 1){
+                if(data.type == 1){
                     this.coin_scrollView.updateAll();
-                }else if(data.type === 2){
+                }else if(data.type == 2){
                     this.diamond_scrollView.updateAll();
                 }
             }

+ 2 - 0
assets/scripts/utils/Utils.ts

@@ -1173,12 +1173,14 @@ export class Utils {
      * @returns 
      */
     public static numberToString(value: number | string) {
+        console.log("当前的值: " + value);
         const num = Number(value);
         if (isNaN(num)) return "0";
         //特殊处理:小于1百万显示完整数字
         if(num < 100000) {
            return Math.floor(num).toString();
         }
+         console.log("转换过后的值: " + this.formatBigNumber(num, ["", "K", "M", "B"]));
         //使用标准格式化中文单位
         return this.formatBigNumber(num, ["", "K", "M", "B"]);
     }