181404010226 3 сар өмнө
parent
commit
7e91e905bf

+ 20 - 20
assets/resources/data/weapons.json

@@ -1029,7 +1029,7 @@
           0
         ],
         [
-          0,
+          1,
           0,
           0,
           0
@@ -1062,8 +1062,8 @@
           0
         ],
         [
-          0,
-          0,
+          1,
+          1,
           0,
           0
         ],
@@ -1089,14 +1089,14 @@
       "name": "倒T形",
       "shape": [
         [
-          0,
           1,
-          0,
+          1,
+          1,
           0
         ],
         [
           0,
-          0,
+          1,
           0,
           0
         ],
@@ -1122,21 +1122,21 @@
       "name": "L2形",
       "shape": [
         [
-          1,
+          0,
           1,
           0,
           0
         ],
         [
           0,
-          0,
+          1,
           0,
           0
         ],
         [
           0,
-          0,
-          0,
+          1,
+          1,
           0
         ],
         [
@@ -1155,15 +1155,15 @@
       "name": "L3形",
       "shape": [
         [
-          1,
           0,
           0,
+          1,
           0
         ],
         [
-          0,
-          0,
-          0,
+          1,
+          1,
+          1,
           0
         ],
         [
@@ -1188,20 +1188,20 @@
       "name": "L4形",
       "shape": [
         [
-          0,
+          1,
           1,
           0,
           0
         ],
         [
           0,
-          0,
+          1,
           0,
           0
         ],
         [
           0,
-          0,
+          1,
           0,
           0
         ],
@@ -1228,8 +1228,8 @@
         ],
         [
           0,
-          0,
-          0,
+          1,
+          1,
           0
         ],
         [
@@ -1261,7 +1261,7 @@
         ],
         [
           0,
-          0,
+          1,
           0,
           0
         ],

+ 13 - 7
assets/scripts/CombatSystem/BlockManager.ts

@@ -892,20 +892,22 @@ export class BlockManager extends Component {
         // 检查根节点是否有B1子节点,如果有,则B1是实际的形状根节点
         const b1Node = block.getChildByName('B1');
         if (b1Node) {
-            // B1节点作为(0,0)位置
+            // B1节点作为形状的根节点和坐标原点(0,0)
+            // 将B1节点本身添加为第一个部分
             parts.push({ node: b1Node, x: 0, y: 0 });
-            this.findBlockParts(b1Node, parts, 0, 0);
+            // 然后递归查找B1的子节点,但要避免重复添加B1本身
+            this.findBlockParts(b1Node, parts, 0, 0, true);
         } else {
-            // 没有B1节点,使用根节点
+            // 没有B1节点,使用根节点作为形状根节点
             parts.push({ node: block, x: 0, y: 0 });
-            this.findBlockParts(block, parts, 0, 0);
+            this.findBlockParts(block, parts, 0, 0, false);
         }
         
         return parts;
     }
     
     // 递归查找方块的所有部分
-    findBlockParts(node: Node, result: { node: Node, x: number, y: number }[], parentX: number, parentY: number) {
+    findBlockParts(node: Node, result: { node: Node, x: number, y: number }[], parentX: number, parentY: number, skipRoot: boolean = false) {
         for (let i = 0; i < node.children.length; i++) {
             const child = node.children[i];
             
@@ -928,10 +930,14 @@ export class BlockManager extends Component {
                 x = parentX + relativeX;
                 y = parentY + relativeY;
                 
-                result.push({ node: child, x, y });
+                // 避免重复添加已经在result中的节点
+                const existingPart = result.find(part => part.node === child);
+                if (!existingPart) {
+                    result.push({ node: child, x, y });
+                }
             }
             
-            this.findBlockParts(child, result, x, y);
+            this.findBlockParts(child, result, x, y, false);
         }
     }