Selaa lähdekoodia

武器伤害修复

181404010226 3 kuukautta sitten
vanhempi
commit
1637aa34da

+ 24 - 12
assets/Scenes/GameLevel.scene

@@ -14196,8 +14196,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 37.369140625,
-      "height": 54.4
+      "width": 60,
+      "height": 40
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -14235,8 +14235,11 @@
     "_lineHeight": 40,
     "_overflow": 0,
     "_enableWrapText": true,
-    "_font": null,
-    "_isSystemFontUsed": true,
+    "_font": {
+      "__uuid__": "f5482737-839c-4813-9511-f36bf1223968",
+      "__expectedType__": "cc.LabelAtlas"
+    },
+    "_isSystemFontUsed": false,
     "_spacingX": 0,
     "_isItalic": false,
     "_isBold": false,
@@ -14583,8 +14586,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 99.595703125,
-      "height": 54.4
+      "width": 60,
+      "height": 40
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -14622,8 +14625,11 @@
     "_lineHeight": 40,
     "_overflow": 0,
     "_enableWrapText": true,
-    "_font": null,
-    "_isSystemFontUsed": true,
+    "_font": {
+      "__uuid__": "f5482737-839c-4813-9511-f36bf1223968",
+      "__expectedType__": "cc.LabelAtlas"
+    },
+    "_isSystemFontUsed": false,
     "_spacingX": 0,
     "_isItalic": false,
     "_isBold": false,
@@ -15010,8 +15016,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 26.24609375,
-      "height": 54.4
+      "width": 40,
+      "height": 40
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -15049,8 +15055,11 @@
     "_lineHeight": 40,
     "_overflow": 0,
     "_enableWrapText": true,
-    "_font": null,
-    "_isSystemFontUsed": true,
+    "_font": {
+      "__uuid__": "f5482737-839c-4813-9511-f36bf1223968",
+      "__expectedType__": "cc.LabelAtlas"
+    },
+    "_isSystemFontUsed": false,
     "_spacingX": 0,
     "_isItalic": false,
     "_isBold": false,
@@ -29064,6 +29073,9 @@
     "upgradeBtnNode": {
       "__id__": 866
     },
+    "currentDamageLabel": {
+      "__id__": 848
+    },
     "_id": "41R/fTDU9IyKelGgdJ0vV1"
   },
   {

+ 0 - 29
assets/resources/Animation/WeaponBurnAni/002/okra_missile.atlas

@@ -1,29 +0,0 @@
-okra_missile.png
-size:191,234
-filter:Linear,Linear
-pma:true
-tx_1_0001
-bounds:2,8,39,44
-offsets:19,24,100,100
-rotate:90
-tx_1_0002
-bounds:100,2,65,58
-offsets:14,18,100,100
-tx_1_0003
-bounds:100,62,81,78
-offsets:9,12,100,100
-rotate:90
-tx_1_0004
-bounds:2,141,91,91
-offsets:6,7,100,100
-tx_1_0005
-bounds:2,49,90,96
-offsets:9,0,100,100
-rotate:90
-tx_1_0006
-bounds:95,145,87,94
-offsets:10,3,100,100
-rotate:90
-tx_1_0007
-bounds:167,49,4,11
-offsets:58,43,100,100

+ 0 - 83
assets/resources/Animation/WeaponBurnAni/002/okra_missile.json

@@ -1,83 +0,0 @@
-{
-"skeleton": { "hash": "fCftDpvjd2c", "spine": "4.3.39-beta", "images": null, "audio": null },
-"bones": [
-	{ "name": "root" },
-	{ "name": "tx_1", "parent": "root", "length": 27.1, "rotation": -0.9, "x": -36.5, "y": 33.92 },
-	{ "name": "tx_2", "parent": "root", "length": 27.1, "rotation": -0.9, "x": -36.5, "y": 33.92 }
-],
-"slots": [
-	{ "name": "tx_1", "bone": "tx_1", "blend": "additive" },
-	{ "name": "tx_2", "bone": "tx_2", "blend": "additive" }
-],
-"skins": [
-	{
-		"name": "default",
-		"attachments": {
-			"tx_1": {
-				"tx_1_0001": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0002": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0003": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0004": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0005": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0006": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0007": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 }
-			},
-			"tx_2": {
-				"tx_1_0001": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0002": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0003": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0004": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0005": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0006": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 },
-				"tx_1_0007": { "x": 8.18, "y": 3.31, "rotation": 0.9, "width": 100, "height": 100 }
-			}
-		}
-	}
-],
-"events": {
-	"event_hit": {}
-},
-"animations": {
-	"animation": {
-		"slots": {
-			"tx_1": {
-				"attachment": [
-					{ "name": "tx_1_0001" },
-					{ "time": 0.033333335, "name": "tx_1_0002" },
-					{ "time": 0.06666667, "name": "tx_1_0003" },
-					{ "time": 0.10000001, "name": "tx_1_0004" },
-					{ "time": 0.13333334, "name": "tx_1_0005" },
-					{ "time": 0.16666667, "name": "tx_1_0006" },
-					{ "time": 0.20000002, "name": "tx_1_0007" },
-					{ "time": 0.23333335 }
-				]
-			},
-			"tx_2": {
-				"attachment": [
-					{ "time": 0.06666667, "name": "tx_1_0001" },
-					{ "time": 0.10000001, "name": "tx_1_0002" },
-					{ "time": 0.13333334, "name": "tx_1_0003" },
-					{ "time": 0.16666667, "name": "tx_1_0004" },
-					{ "time": 0.20000002, "name": "tx_1_0005" },
-					{ "time": 0.23333335, "name": "tx_1_0006" },
-					{ "time": 0.26666668, "name": "tx_1_0007" },
-					{ "time": 0.3 }
-				]
-			}
-		},
-		"bones": {
-			"tx_1": {
-				"translate": [
-					{ "x": 24.91, "y": -9.06 }
-				]
-			},
-			"tx_2": {
-				"translate": [
-					{ "time": 0.06666667, "x": 33.97, "y": 3.77 },
-					{ "time": 0.16666667, "x": 25.96994, "y": -10.230001 }
-				]
-			}
-		}
-	}
-}
-}

BIN
assets/resources/Animation/WeaponBurnAni/002/okra_missile.png


+ 1 - 1
assets/resources/Animation/WeaponBurnAni/002.meta → assets/resources/Animation/WeaponBurnAni/shengji.meta

@@ -2,7 +2,7 @@
   "ver": "1.2.0",
   "importer": "directory",
   "imported": true,
-  "uuid": "00f7f692-3cab-4608-b9f9-625ce4bc67db",
+  "uuid": "b0e86c48-167a-46e9-b3d0-c16ef8f34ded",
   "files": [],
   "subMetas": {},
   "userData": {}

+ 104 - 0
assets/resources/Animation/WeaponBurnAni/shengji/skeleton.atlas

@@ -0,0 +1,104 @@
+
+skeleton.png
+size: 622,64
+format: RGBA8888
+filter: Linear,Linear
+repeat: none
+eff_deayan2_0005
+  rotate: false
+  xy: 339, 6
+  size: 53, 56
+  orig: 79, 94
+  offset: 17, 1
+  index: -1
+eff_deayan2_0007
+  rotate: true
+  xy: 229, 6
+  size: 56, 55
+  orig: 79, 94
+  offset: 15, 4
+  index: -1
+eff_deayan2_0009
+  rotate: true
+  xy: 116, 4
+  size: 58, 56
+  orig: 79, 94
+  offset: 13, 6
+  index: -1
+eff_deayan2_0011
+  rotate: true
+  xy: 2, 2
+  size: 60, 55
+  orig: 79, 94
+  offset: 12, 8
+  index: -1
+eff_deayan2_0013
+  rotate: true
+  xy: 59, 2
+  size: 60, 55
+  orig: 79, 94
+  offset: 12, 9
+  index: -1
+eff_deayan2_0015
+  rotate: true
+  xy: 174, 3
+  size: 59, 53
+  orig: 79, 94
+  offset: 12, 12
+  index: -1
+eff_deayan2_0017
+  rotate: true
+  xy: 286, 2
+  size: 60, 51
+  orig: 79, 94
+  offset: 11, 14
+  index: -1
+eff_deayan2_0019
+  rotate: true
+  xy: 394, 10
+  size: 52, 48
+  orig: 79, 94
+  offset: 12, 17
+  index: -1
+eff_deayan2_0021
+  rotate: true
+  xy: 444, 10
+  size: 52, 46
+  orig: 79, 94
+  offset: 12, 19
+  index: -1
+eff_deayan2_0023
+  rotate: true
+  xy: 492, 11
+  size: 51, 43
+  orig: 79, 94
+  offset: 12, 22
+  index: -1
+eff_deayan2_0025
+  rotate: true
+  xy: 537, 12
+  size: 50, 32
+  orig: 79, 94
+  offset: 13, 22
+  index: -1
+eff_deayan2_0027
+  rotate: false
+  xy: 571, 34
+  size: 37, 28
+  orig: 79, 94
+  offset: 15, 24
+  index: -1
+eff_deayan2_0029
+  rotate: true
+  xy: 601, 6
+  size: 26, 19
+  orig: 79, 94
+  offset: 20, 29
+  index: -1
+xx
+  rotate: false
+  xy: 571, 4
+  size: 28, 28
+  orig: 30, 30
+  offset: 1, 1
+  index: -1

+ 1 - 1
assets/resources/Animation/WeaponBurnAni/002/okra_missile.atlas.meta → assets/resources/Animation/WeaponBurnAni/shengji/skeleton.atlas.meta

@@ -2,7 +2,7 @@
   "ver": "1.0.0",
   "importer": "*",
   "imported": true,
-  "uuid": "1cd12667-d50a-4933-ad9c-29559ed450ae",
+  "uuid": "9365727d-4deb-4ba8-989f-d887dfbb82cf",
   "files": [
     ".atlas",
     ".json"

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
assets/resources/Animation/WeaponBurnAni/shengji/skeleton.json


+ 2 - 2
assets/resources/Animation/WeaponBurnAni/002/okra_missile.json.meta → assets/resources/Animation/WeaponBurnAni/shengji/skeleton.json.meta

@@ -2,12 +2,12 @@
   "ver": "1.2.7",
   "importer": "spine-data",
   "imported": true,
-  "uuid": "624ee3ad-a3ae-4265-9ddd-522dee2a1d95",
+  "uuid": "a535ffac-80c0-46f6-96f0-8706d32484e1",
   "files": [
     ".json"
   ],
   "subMetas": {},
   "userData": {
-    "atlasUuid": "1cd12667-d50a-4933-ad9c-29559ed450ae"
+    "atlasUuid": "9365727d-4deb-4ba8-989f-d887dfbb82cf"
   }
 }

BIN
assets/resources/Animation/WeaponBurnAni/shengji/skeleton.png


+ 36 - 36
assets/resources/Animation/WeaponBurnAni/002/okra_missile.png.meta → assets/resources/Animation/WeaponBurnAni/shengji/skeleton.png.meta

@@ -2,7 +2,7 @@
   "ver": "1.0.27",
   "importer": "image",
   "imported": true,
-  "uuid": "6c52b1b6-878f-47a8-8cbb-6f93ea19a881",
+  "uuid": "630f5c44-cbb7-44bf-9a7f-27e2732b63a9",
   "files": [
     ".json",
     ".png"
@@ -10,14 +10,14 @@
   "subMetas": {
     "6c48a": {
       "importer": "texture",
-      "uuid": "6c52b1b6-878f-47a8-8cbb-6f93ea19a881@6c48a",
-      "displayName": "okra_missile",
+      "uuid": "630f5c44-cbb7-44bf-9a7f-27e2732b63a9@6c48a",
+      "displayName": "skeleton",
       "id": "6c48a",
       "name": "texture",
       "userData": {
         "wrapModeS": "clamp-to-edge",
         "wrapModeT": "clamp-to-edge",
-        "imageUuidOrDatabaseUri": "6c52b1b6-878f-47a8-8cbb-6f93ea19a881",
+        "imageUuidOrDatabaseUri": "630f5c44-cbb7-44bf-9a7f-27e2732b63a9",
         "isUuid": true,
         "visible": false,
         "minfilter": "linear",
@@ -34,8 +34,8 @@
     },
     "f9941": {
       "importer": "sprite-frame",
-      "uuid": "6c52b1b6-878f-47a8-8cbb-6f93ea19a881@f9941",
-      "displayName": "okra_missile",
+      "uuid": "630f5c44-cbb7-44bf-9a7f-27e2732b63a9@f9941",
+      "displayName": "skeleton",
       "id": "f9941",
       "name": "spriteFrame",
       "userData": {
@@ -45,10 +45,10 @@
         "offsetY": 0,
         "trimX": 2,
         "trimY": 2,
-        "width": 187,
-        "height": 230,
-        "rawWidth": 191,
-        "rawHeight": 234,
+        "width": 618,
+        "height": 60,
+        "rawWidth": 622,
+        "rawHeight": 64,
         "borderTop": 0,
         "borderBottom": 0,
         "borderLeft": 0,
@@ -60,17 +60,17 @@
         "meshType": 0,
         "vertices": {
           "rawPosition": [
-            -93.5,
-            -115,
+            -309,
+            -30,
             0,
-            93.5,
-            -115,
+            309,
+            -30,
             0,
-            -93.5,
-            115,
+            -309,
+            30,
             0,
-            93.5,
-            115,
+            309,
+            30,
             0
           ],
           "indexes": [
@@ -83,37 +83,37 @@
           ],
           "uv": [
             2,
-            232,
-            189,
-            232,
+            62,
+            620,
+            62,
             2,
             2,
-            189,
+            620,
             2
           ],
           "nuv": [
-            0.010471204188481676,
-            0.008547008547008548,
-            0.9895287958115183,
-            0.008547008547008548,
-            0.010471204188481676,
-            0.9914529914529915,
-            0.9895287958115183,
-            0.9914529914529915
+            0.003215434083601286,
+            0.03125,
+            0.9967845659163987,
+            0.03125,
+            0.003215434083601286,
+            0.96875,
+            0.9967845659163987,
+            0.96875
           ],
           "minPos": [
-            -93.5,
-            -115,
+            -309,
+            -30,
             0
           ],
           "maxPos": [
-            93.5,
-            115,
+            309,
+            30,
             0
           ]
         },
         "isUuid": true,
-        "imageUuidOrDatabaseUri": "6c52b1b6-878f-47a8-8cbb-6f93ea19a881@6c48a",
+        "imageUuidOrDatabaseUri": "630f5c44-cbb7-44bf-9a7f-27e2732b63a9@6c48a",
         "atlasUuid": "",
         "trimType": "auto"
       },
@@ -129,6 +129,6 @@
     "type": "sprite-frame",
     "hasAlpha": true,
     "fixAlphaTransparencyArtifacts": false,
-    "redirect": "6c52b1b6-878f-47a8-8cbb-6f93ea19a881@6c48a"
+    "redirect": "630f5c44-cbb7-44bf-9a7f-27e2732b63a9@6c48a"
   }
 }

+ 1 - 1
assets/resources/data/ballController.json

@@ -15,7 +15,7 @@
   "friction": 0,
   "restitution": 1,
   "safeDistance": 20,
-  "edgeOffset": 20,
+  "edgeOffset": 50,
   "sensor": false,
   "maxAttempts": 50
 }

+ 32 - 1
assets/scripts/CombatSystem/BallController.ts

@@ -7,6 +7,7 @@ import { PersistentSkillManager } from '../FourUI/SkillSystem/PersistentSkillMan
 import { BallAni } from '../Animations/BallAni';
 import { BallControllerConfig } from '../Core/ConfigManager';
 import { WeaponInfo } from './BlockSelection/WeaponInfo';
+import { BlockInfo } from './BlockSelection/BlockInfo';
 const { ccclass, property } = _decorator;
 
 @ccclass('BallController')
@@ -1234,13 +1235,43 @@ export class BallController extends Component {
                 weaponInfoComponent = weaponNode.getComponent(WeaponInfo);
             }
             
+            // 获取BlockInfo组件(如果有的话)
+            // BlockInfo组件位于方块的Node子节点上,而不是Weapon子节点上
+            let blockInfoComponent: BlockInfo | null = null;
+            if (weaponNode && weaponNode.isValid && weaponNode.parent) {
+                // 从weaponNode的父节点(方块根节点)查找Node子节点
+                const blockRootNode = weaponNode.parent;
+                const nodeChild = blockRootNode.getChildByName('Node');
+                if (nodeChild) {
+                    blockInfoComponent = nodeChild.getComponent(BlockInfo);
+                    if (blockInfoComponent) {
+                        console.log(`[BallController] 找到BlockInfo组件,稀有度等级: ${blockInfoComponent.rarity}, 稀有度名称: ${blockInfoComponent.getRarityName()}`);
+                    } else {
+                        console.log(`[BallController] Node子节点上未找到BlockInfo组件`);
+                    }
+                } else {
+                    console.log(`[BallController] 未找到Node子节点`);
+                }
+                
+                // 如果还是没找到,尝试直接从weaponNode上获取(兼容旧结构)
+                if (!blockInfoComponent) {
+                    blockInfoComponent = weaponNode.getComponent(BlockInfo);
+                    if (blockInfoComponent) {
+                        console.log(`[BallController] 从weaponNode上找到BlockInfo组件,稀有度等级: ${blockInfoComponent.rarity}, 稀有度名称: ${blockInfoComponent.getRarityName()}`);
+                    } else {
+                        console.log(`[BallController] 未找到BlockInfo组件,将使用JSON配置中的稀有度`);
+                    }
+                }
+            }
+            
             // 创建子弹初始化数据
             const initData: BulletInitData = {
                 weaponId: finalConfig.id,
                 firePosition: firePosition,
                 autoTarget: true,
                 weaponConfig: finalConfig,
-                weaponInfo: weaponInfoComponent
+                weaponInfo: weaponInfoComponent,
+                blockInfo: blockInfoComponent
             };
             
             // 验证初始化数据

+ 57 - 0
assets/scripts/CombatSystem/BlockManager.ts

@@ -2284,6 +2284,13 @@ export class BlockManager extends Component {
             this.hidePriceLabel(source);
             const srcDb = source['dbNode'];
             if (srcDb) srcDb.active = false;
+            
+            // 隐藏目标方块的db标签(合成后目标方块也应该隐藏db标签)
+            const targetDb = target['dbNode'];
+            if (targetDb) {
+                targetDb.active = false;
+                console.log(`[BlockManager] 隐藏目标方块db标签: ${targetDb.name}`);
+            }
 
             // 销毁被合并方块
             source.destroy();
@@ -2364,6 +2371,9 @@ export class BlockManager extends Component {
             target.getWorldPosition(worldPos);
             this.spawnMergeSmoke(worldPos);
 
+            // 播放升级特效动画
+            this.playUpgradeEffect(target);
+
             // 递归检查是否还能继续合成
             if (nextRarity) {
                 await this.tryMergeBlock(target);
@@ -2436,6 +2446,53 @@ export class BlockManager extends Component {
         });
     }
 
+    /** 播放升级特效动画 */
+    private playUpgradeEffect(target: Node) {
+        try {
+            // 获取目标方块的世界坐标
+            const worldPos = new Vec3();
+            target.getWorldPosition(worldPos);
+            
+            // 加载升级特效动画
+            const path = 'Animation/WeaponBurnAni/shengji/skeleton';
+            resources.load(path, sp.SkeletonData, (err, sData: sp.SkeletonData) => {
+                if (err || !sData) {
+                    console.warn('[BlockManager] 加载升级特效动画失败:', err);
+                    return;
+                }
+                
+                // 创建特效节点
+                const effectNode = new Node('UpgradeEffect');
+                const skeleton = effectNode.addComponent(sp.Skeleton);
+                skeleton.skeletonData = sData;
+                skeleton.premultipliedAlpha = false;
+                
+                // 播放动画
+                skeleton.setAnimation(0, 'animation', false);
+                
+                // 监听动画完成事件,播放完成后销毁节点
+                skeleton.setCompleteListener(() => {
+                    effectNode.destroy();
+                    console.log('[BlockManager] 升级特效播放完成');
+                });
+                
+                // 添加到Canvas并设置位置
+                const canvas = find('Canvas');
+                if (canvas) {
+                    canvas.addChild(effectNode);
+                    effectNode.setWorldPosition(worldPos);
+                    console.log('[BlockManager] 开始播放升级特效动画');
+                } else {
+                    console.warn('[BlockManager] 未找到Canvas节点,无法播放升级特效');
+                    effectNode.destroy();
+                }
+            });
+            
+        } catch (error) {
+            console.error('[BlockManager] 播放升级特效失败:', error);
+        }
+    }
+
     /** 在放置失败时尝试与现有方块进行合成 */
     public tryMergeOnOverlap(draggedBlock: Node): boolean {
         console.log(`[BlockManager] tryMergeOnOverlap 开始检查合成`);

+ 13 - 6
assets/scripts/CombatSystem/BlockSelection/WeaponInfo.ts

@@ -239,14 +239,21 @@ export class WeaponInfo extends Component {
             return 0;
         }
         
-        const baseDamage = this._weaponConfig.stats.damage || 0;
+        if (this._weaponLevel === 0) {
+            return 0; // 未解锁武器伤害为0
+        }
         
-        // 根据等级计算伤害加成(简单的线性增长)
-        // 每级增加10%的基础伤害
-        const levelMultiplier = 1 + (this._weaponLevel - 1) * 0.1;
-        const finalDamage = Math.floor(baseDamage * levelMultiplier);
+        // 优先从武器配置的upgradeConfig中获取伤害值
+        if (this._weaponConfig.upgradeConfig && this._weaponConfig.upgradeConfig.levels) {
+            const levelConfig = this._weaponConfig.upgradeConfig.levels[this._weaponLevel.toString()];
+            if (levelConfig && typeof levelConfig.damage === 'number') {
+                return levelConfig.damage;
+            }
+        }
         
-        return finalDamage;
+        // 如果upgradeConfig中没有伤害值,使用基础伤害 + 等级加成作为后备
+        const baseDamage = this._weaponConfig.stats.damage || 0;
+        return baseDamage + (this._weaponLevel - 1);
     }
     
     /**

+ 13 - 0
assets/scripts/CombatSystem/SkillSelection/SkillManager.ts

@@ -338,4 +338,17 @@ export class SkillManager extends Component {
     public getAllSkillsData(): SkillData[] {
         return Array.from(this._skills.values());
     }
+
+    /**
+     * 重置所有技能等级为0(关卡切换时调用)
+     */
+    public resetAllSkillLevels(): void {
+        this._skills.forEach((skill, skillId) => {
+            if (skill.currentLevel > 0) {
+                skill.currentLevel = 0;
+                this.notifySkillChanged(skillId);
+            }
+        });
+        console.log('[SkillManager] 所有技能等级已重置为0');
+    }
 }

+ 58 - 10
assets/scripts/CombatSystem/WeaponBullet.ts

@@ -10,6 +10,7 @@ import { PersistentSkillManager } from '../FourUI/SkillSystem/PersistentSkillMan
 import { SkillManager } from './SkillSelection/SkillManager';
 import { SaveDataManager } from '../LevelSystem/SaveDataManager';
 import { WeaponInfo } from './BlockSelection/WeaponInfo';
+import { BlockInfo } from './BlockSelection/BlockInfo';
 
 const { ccclass, property } = _decorator;
 
@@ -32,6 +33,7 @@ export interface BulletInitData {
     autoTarget?: boolean;       // 是否自动瞄准
     weaponConfig?: WeaponConfig; // 直接传入的武器配置(优先级更高)
     weaponInfo?: WeaponInfo;    // WeaponInfo组件实例(用于冷却管理等)
+    blockInfo?: BlockInfo;      // BlockInfo组件实例(用于获取稀有度等级)
 }
 
 @ccclass('WeaponBullet')
@@ -52,6 +54,7 @@ export class WeaponBullet extends Component {
     private weaponConfig: WeaponConfig = null;
     private weaponId: string = null; // 存储武器ID用于获取升级数据
     private weaponInfo: WeaponInfo = null; // WeaponInfo组件实例
+    private blockInfo: BlockInfo = null; // BlockInfo组件实例
     private isInitialized: boolean = false;
     
     // === 静态武器配置缓存 ===
@@ -218,9 +221,10 @@ export class WeaponBullet extends Component {
             return;
         }
         
-        // 存储武器ID和WeaponInfo
+        // 存储武器ID、WeaponInfo和BlockInfo
         this.weaponId = initData.weaponId;
         this.weaponInfo = initData.weaponInfo || null;
+        this.blockInfo = initData.blockInfo || null;
         
         // 获取武器配置
         this.weaponConfig = initData.weaponConfig || WeaponBullet.getWeaponConfig(initData.weaponId);
@@ -672,24 +676,47 @@ export class WeaponBullet extends Component {
         // 获取基础伤害
         let baseDamage = this.weaponConfig.stats.damage;
         
-        // 应用武器升级加成
+        // 应用武器升级加成 - 使用UpgradeController的伤害计算逻辑
         const saveDataManager = SaveDataManager.getInstance();
         if (saveDataManager && this.weaponId) {
             const weaponData = saveDataManager.getWeapon(this.weaponId);
             if (weaponData && weaponData.level > 0) {
-                // 应用武器升级加成:升级后伤害 = 基础伤害 + (等级 - 1)
-                baseDamage = this.weaponConfig.stats.damage + (weaponData.level - 1);
-                console.log(`[WeaponBullet] 武器升级加成应用 - 武器ID: ${this.weaponId}, 等级: ${weaponData.level}, 基础伤害: ${this.weaponConfig.stats.damage}, 升级后伤害: ${baseDamage}`);
+                // 优先从武器配置的upgradeConfig中获取伤害值
+                if (this.weaponConfig.upgradeConfig && this.weaponConfig.upgradeConfig.levels) {
+                    const levelConfig = this.weaponConfig.upgradeConfig.levels[weaponData.level.toString()];
+                    if (levelConfig && typeof levelConfig.damage === 'number') {
+                        baseDamage = levelConfig.damage;
+                        console.log(`[WeaponBullet] 从upgradeConfig获取伤害 - 武器ID: ${this.weaponId}, 等级: ${weaponData.level}, 伤害: ${baseDamage}`);
+                    } else {
+                        // 如果upgradeConfig中没有伤害值,使用基础伤害 + 等级加成作为后备
+                        baseDamage = this.weaponConfig.stats.damage + (weaponData.level - 1);
+                        console.log(`[WeaponBullet] 使用基础伤害计算 - 武器ID: ${this.weaponId}, 等级: ${weaponData.level}, 基础伤害: ${this.weaponConfig.stats.damage}, 升级后伤害: ${baseDamage}`);
+                    }
+                } else {
+                    // 如果没有upgradeConfig,使用默认公式
+                    baseDamage = this.weaponConfig.stats.damage + (weaponData.level - 1);
+                    console.log(`[WeaponBullet] 无upgradeConfig,使用默认公式 - 武器ID: ${this.weaponId}, 等级: ${weaponData.level}, 升级后伤害: ${baseDamage}`);
+                }
             }
         }
         
         // 应用稀有度伤害倍数(合成升级效果)
-        // 从武器配置中获取稀有度,如果不存在则默认为 'common'
-        const rarity = this.weaponConfig.rarity || 'common';
-        const rarityMultiplier = this.getRarityDamageMultiplier(rarity);
+        // 优先从BlockInfo中获取稀有度等级,如果不存在则从武器配置中获取
+        let rarityLevel = 0; // 默认为common(0)
+        let rarityName = 'common';
+        
+        if (this.blockInfo) {
+            rarityLevel = this.blockInfo.rarity;
+            rarityName = this.blockInfo.getRarityName();
+        } else if (this.weaponConfig && this.weaponConfig.rarity) {
+            // 兼容旧的JSON配置方式
+            rarityName = this.weaponConfig.rarity;
+        }
+        
+        const rarityMultiplier = this.getRarityDamageMultiplierByLevel(rarityLevel);
         if (rarityMultiplier > 1) {
             baseDamage = baseDamage * rarityMultiplier;
-            console.log(`[WeaponBullet] 稀有度伤害倍数应用 - 稀有度: ${rarity}, 倍数: ${rarityMultiplier}, 最终基础伤害: ${baseDamage}`);
+            console.log(`[WeaponBullet] 稀有度伤害倍数应用 - 稀有度等级: ${rarityLevel}(${rarityName}), 倍数: ${rarityMultiplier}, 最终基础伤害: ${baseDamage}`);
         }
         
         const skillManager = PersistentSkillManager.getInstance();
@@ -736,7 +763,7 @@ export class WeaponBullet extends Component {
         const inGameCritBonus = inGameSkillManager && inGameCritLevel > 0 ? 
             ((SkillManager.calculateCritChance(baseCritChance, inGameCritLevel) - baseCritChance) * 100).toFixed(1) : '0.0';
         
-        console.log(`[WeaponBullet] 完整伤害计算完成 - 武器ID: ${this.weaponId}, 原始伤害: ${this.weaponConfig.stats.damage}, 稀有度: ${rarity}, 计算后基础伤害: ${baseDamage}, 最终伤害: ${finalDamage}, 暴击伤害: ${finalCritDamage}`);
+        console.log(`[WeaponBullet] 完整伤害计算完成 - 武器ID: ${this.weaponId}, 原始伤害: ${this.weaponConfig.stats.damage}, 稀有度: ${rarityName}, 计算后基础伤害: ${baseDamage}, 最终伤害: ${finalDamage}, 暴击伤害: ${finalCritDamage}`);
         console.log(`[WeaponBullet] 暴击率详情 - 基础: ${(baseCritChance * 100).toFixed(1)}%, 局内技能等级: ${inGameCritLevel}, 局内技能加成: +${inGameCritBonus}%, 最终暴击率: ${(critChance * 100).toFixed(1)}%`);
     }
     
@@ -779,4 +806,25 @@ export class WeaponBullet extends Component {
                 return 1;
         }
     }
+
+    /**
+     * 根据稀有度等级获取伤害倍数
+     * @param rarityLevel 稀有度等级 (0: common, 1: uncommon, 2: rare, 3: epic)
+     * @returns 伤害倍数
+     */
+    private getRarityDamageMultiplierByLevel(rarityLevel: number): number {
+        switch (rarityLevel) {
+            case 0: // common
+                return 1; // 1级,无倍数
+            case 1: // uncommon
+                return 1.5; // 2级,1.5倍伤害
+            case 2: // rare
+                return 2.25; // 3级,2.25倍伤害
+            case 3: // epic
+                return 8; // 4级,8倍伤害
+
+            default:
+                return 1;
+        }
+    }
 }

+ 1 - 0
assets/scripts/Core/ConfigManager.ts

@@ -93,6 +93,7 @@ export interface WeaponConfig {
         levels: {
             [level: string]: {
                 cost: number;
+                damage?: number;
             };
         };
     };

+ 76 - 1
assets/scripts/FourUI/UpgradeSystem/UpgradeAni.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, Node, Tween, tween, Vec3, Material, Sprite, resources } from 'cc';
+import { _decorator, Component, Node, Tween, tween, Vec3, Material, Sprite, resources, Label, JsonAsset } from 'cc';
 import { Audio } from '../../AudioManager/AudioManager';
 
 const { ccclass, property } = _decorator;
@@ -16,7 +16,11 @@ export class UpgradeAni extends Component {
     @property(Node)
     upgradeBtnNode: Node = null; // Canvas/UpgradePanel/UpgradeBtn/UP节点
     
+    @property(Label)
+    currentDamageLabel: Label = null; // Canvas/UpgradePanel/NumberBack/CurrentDamage节点
+    
     private blinkTween: Tween<Node> = null; // 闪烁动画的引用
+    private weaponsConfig: any = null; // 武器配置数据
     
     /**
      * 植物升级成功动画
@@ -243,5 +247,76 @@ export class UpgradeAni extends Component {
     public isUpgradeBtnBlinking(): boolean {
         return this.blinkTween !== null;
     }
+    
+    /**
+     * 加载武器配置数据
+     */
+    public async loadWeaponsConfig(): Promise<void> {
+        return new Promise((resolve, reject) => {
+            resources.load('data/weapons', JsonAsset, (err, weaponsData) => {
+                if (err) {
+                    console.error('[UpgradeAni] 加载武器配置失败:', err);
+                    reject(err);
+                    return;
+                }
+                
+                this.weaponsConfig = weaponsData.json || weaponsData;
+                console.log('[UpgradeAni] 武器配置加载成功');
+                resolve();
+            });
+        });
+    }
+    
+    /**
+     * 从JSON配置中获取武器在指定等级的伤害值
+     * @param weaponId 武器ID
+     * @param level 武器等级
+     * @returns 伤害值
+     */
+    public getWeaponDamageFromConfig(weaponId: string, level: number): number {
+        if (!this.weaponsConfig || !this.weaponsConfig.weapons) {
+            console.warn('[UpgradeAni] 武器配置未加载');
+            return 0;
+        }
+        
+        const weaponConfig = this.weaponsConfig.weapons.find((w: any) => w.id === weaponId);
+        if (!weaponConfig) {
+            console.warn(`[UpgradeAni] 未找到武器配置: ${weaponId}`);
+            return 0;
+        }
+        
+        if (level === 0) {
+            return 0; // 未解锁武器伤害为0
+        }
+        
+        // 优先从upgradeConfig中获取伤害值
+        if (weaponConfig.upgradeConfig && weaponConfig.upgradeConfig.levels) {
+            const levelConfig = weaponConfig.upgradeConfig.levels[level.toString()];
+            if (levelConfig && typeof levelConfig.damage === 'number') {
+                return levelConfig.damage;
+            }
+        }
+        
+        // 如果upgradeConfig中没有伤害值,使用基础伤害 + 等级加成
+        const baseDamage = weaponConfig.stats?.damage || 0;
+        return baseDamage + (level - 1);
+    }
+    
+    /**
+     * 更新当前伤害显示
+     * @param weaponId 武器ID
+     * @param level 武器等级
+     */
+    public updateCurrentDamageDisplay(weaponId: string, level: number): void {
+        if (!this.currentDamageLabel) {
+            console.warn('[UpgradeAni] currentDamageLabel未设置,请在编辑器中设置Canvas/UpgradePanel/NumberBack/CurrentDamage节点');
+            return;
+        }
+        
+        const damage = this.getWeaponDamageFromConfig(weaponId, level);
+        this.currentDamageLabel.string = damage.toString();
+        
+        console.log(`[UpgradeAni] 更新伤害显示: ${weaponId} 等级${level} 伤害${damage}`);
+    }
 
 }

+ 39 - 14
assets/scripts/FourUI/UpgradeSystem/UpgradeController.ts

@@ -35,6 +35,7 @@ interface WeaponConfig {
         levels: {
             [level: string]: {
                 cost: number;
+                damage?: number;
             };
         };
     };
@@ -86,6 +87,16 @@ export class UpgradeController extends Component {
         // 先加载武器配置
         await this.loadWeaponsConfig();
         
+        // 为UpgradeAni组件加载武器配置
+        if (this.weaponUpgradeAni) {
+            try {
+                await this.weaponUpgradeAni.loadWeaponsConfig();
+                console.log('[UpgradeController] UpgradeAni武器配置加载完成');
+            } catch (error) {
+                console.error('[UpgradeController] UpgradeAni武器配置加载失败:', error);
+            }
+        }
+        
         // 加载关卡配置
         await this.loadLevelConfigs();
         
@@ -581,6 +592,11 @@ export class UpgradeController extends Component {
             this.panelCurrentDamage.string = currentDamage.toString();
         }
         
+        // 同时更新UpgradeAni组件中的伤害显示
+        if (this.weaponUpgradeAni && this.weaponUpgradeAni.currentDamageLabel) {
+            this.weaponUpgradeAni.updateCurrentDamageDisplay(this.currentSelectedWeapon, weaponData.level);
+        }
+        
         // 设置升级费用 - Canvas/UpgradeUI/UpgradePanel/UpgradeBtn/CostLabel
         // 优先从武器配置的upgradeConfig字段获取升级费用
         let upgradeCost = 0;
@@ -624,26 +640,26 @@ export class UpgradeController extends Component {
     private calculateWeaponDamage(baseDamage: number, level: number, weaponId?: string): number {
         if (level === 0) return 0; // 未解锁武器伤害为0
         
-        // 从武器配置中获取伤害增加
+        // 优先从武器配置的upgradeConfig中获取伤害值
         if (weaponId && this.weaponsConfig && this.weaponsConfig.weapons) {
             const weaponConfig = this.weaponsConfig.weapons.find(w => w.id === weaponId);
-            // 由于WeaponConfig中没有upgradeConfig属性,直接使用基础伤害计算
-            if (weaponConfig && weaponConfig.stats && weaponConfig.stats.damage) {
-                let totalDamageIncrease = 0;
-                
-                // 累加从1级到当前级别的所有伤害增加
-                for (let i = 1; i < level; i++) {
-                    // 从武器配置的stats中获取每级伤害增加值
-                    if (this.levelConfigs[i] && this.levelConfigs[i].damageIncrease) {
-                        totalDamageIncrease += this.levelConfigs[i].damageIncrease;
-                    }
+            if (weaponConfig && weaponConfig.upgradeConfig && weaponConfig.upgradeConfig.levels) {
+                const levelConfig = weaponConfig.upgradeConfig.levels[level.toString()];
+                if (levelConfig && typeof levelConfig.damage === 'number') {
+                    console.log(`[UpgradeController] 从upgradeConfig获取伤害: ${weaponId} 等级${level} 伤害${levelConfig.damage}`);
+                    return levelConfig.damage;
                 }
-                
-                return baseDamage + totalDamageIncrease;
+            }
+            
+            // 如果upgradeConfig中没有伤害值,使用基础伤害 + 等级加成作为后备
+            if (weaponConfig && weaponConfig.stats && weaponConfig.stats.damage) {
+                const damage = baseDamage + (level - 1);
+                console.log(`[UpgradeController] 使用基础伤害计算: ${weaponId} 等级${level} 伤害${damage}`);
+                return damage;
             }
         }
         
-        // 如果配置不存在,使用默认公式作为后备
+        // 如果配置不存在,使用默认公式作为最后后备
         return baseDamage + (level - 1);
     }
     
@@ -758,6 +774,15 @@ export class UpgradeController extends Component {
             // 刷新升级面板
             this.refreshUpgradePanel();
             
+            // 更新UpgradeAni组件中的伤害显示
+            if (this.weaponUpgradeAni && this.weaponUpgradeAni.currentDamageLabel) {
+                const upgradedWeapon = this.saveDataManager.getWeapon(this.currentSelectedWeapon);
+                if (upgradedWeapon) {
+                    this.weaponUpgradeAni.updateCurrentDamageDisplay(this.currentSelectedWeapon, upgradedWeapon.level);
+                    console.log(`[UpgradeController] 升级后更新UpgradeAni伤害显示: ${this.currentSelectedWeapon} 等级${upgradedWeapon.level}`);
+                }
+            }
+            
             // 使用新的状态切换方法更新武器节点
             this.switchWeaponNodeState(this.currentSelectedWeapon);
             

+ 3 - 7
assets/scripts/LevelSystem/IN_game.ts

@@ -993,13 +993,9 @@ export class InGameManager extends Component {
         
         // 3. 清空技能选择数据(重置临时技能状态)
         console.log('[InGameManager] 清空技能选择数据');
-        if (SkillManager.getInstance()) {
-            // 重置技能管理器中的临时技能状态
-            const skillManager = SkillManager.getInstance();
-            const allSkills = skillManager.getAllSkillsData();
-            allSkills.forEach(skill => {
-                skillManager.setSkillLevel(skill.id, 0); // 重置所有技能等级为0
-            });
+        const skillManager = SkillManager.getInstance();
+        if (skillManager) {
+            skillManager.resetAllSkillLevels();
         }
         
         // 4. 重置关卡数据和游戏状态

+ 8 - 0
assets/scripts/LevelSystem/StartGame.ts

@@ -3,6 +3,7 @@ import { LevelSessionManager } from '../Core/LevelSessionManager';
 import { SaveDataManager } from './SaveDataManager';
 import EventBus, { GameEvents } from '../Core/EventBus';
 import { GameManager } from './GameManager';
+import { SkillManager } from '../CombatSystem/SkillSelection/SkillManager';
 const { ccclass } = _decorator;
 
 /**
@@ -159,6 +160,13 @@ export class StartGame extends Component {
         eventBus.emit(GameEvents.RESET_ENERGY_SYSTEM);
         console.log('[StartGame] 发送能量重置事件');
         
+        // 重置技能选择数据(清空三选一技能等级)
+        const skillManager = SkillManager.getInstance();
+        if (skillManager) {
+            skillManager.resetAllSkillLevels();
+            console.log('[StartGame] 技能选择数据已重置');
+        }
+        
         // 延迟加载关卡配置,确保能量重置先执行
         setTimeout(async () => {
             // 获取GameManager实例并加载关卡配置

+ 27 - 0
package-lock.json

@@ -0,0 +1,27 @@
+{
+  "name": "Pong",
+  "lockfileVersion": 3,
+  "requires": true,
+  "packages": {
+    "": {
+      "name": "Pong",
+      "devDependencies": {
+        "typescript": "^5.9.2"
+      }
+    },
+    "node_modules/typescript": {
+      "version": "5.9.2",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
+      "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
+      "dev": true,
+      "license": "Apache-2.0",
+      "bin": {
+        "tsc": "bin/tsc",
+        "tsserver": "bin/tsserver"
+      },
+      "engines": {
+        "node": ">=14.17"
+      }
+    }
+  }
+}

+ 3 - 0
package.json

@@ -3,5 +3,8 @@
   "uuid": "6af093b6-823f-490b-8067-6e67acf2b173",
   "creator": {
     "version": "3.8.6"
+  },
+  "devDependencies": {
+    "typescript": "^5.9.2"
   }
 }

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä