Sfoglia il codice sorgente

修改消除逻辑

mojunshou 8 mesi fa
parent
commit
2c686930ea

+ 6 - 7
assets/bundle/gui/eliminate/eliminate.prefab

@@ -2274,12 +2274,12 @@
       "height": 40
     },
     "_startAxis": 0,
-    "_paddingLeft": 10,
-    "_paddingRight": 10,
-    "_paddingTop": 10,
-    "_paddingBottom": 10,
-    "_spacingX": -5,
-    "_spacingY": -8,
+    "_paddingLeft": 0,
+    "_paddingRight": 0,
+    "_paddingTop": 0,
+    "_paddingBottom": 0,
+    "_spacingX": 0,
+    "_spacingY": 0,
     "_verticalDirection": 1,
     "_horizontalDirection": 0,
     "_constraint": 0,
@@ -6563,7 +6563,6 @@
       "__uuid__": "e7074ca1-499a-49b0-827b-15bfeb5af0eb",
       "__expectedType__": "cc.Prefab"
     },
-    "hammerPrefab": null,
     "_id": ""
   },
   {

+ 19 - 19
assets/script/game/eliminate/view/EliminateViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-11 18:05:45
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-18 14:39:01
+ * @LastEditTime: 2025-03-26 15:02:48
  * @Description: 
  */
 import { _decorator, Color, EventTouch, instantiate, JsonAsset, Node, Prefab, Sprite, UITransform, Vec3, Widget, tween } from "cc";
@@ -82,7 +82,7 @@ export class EliminateViewComp extends CCComp {
     max_row: number = 0;
     max_col: number = 0;
     itemSize: number = 0;
-    itemSpacing: number = 0;   //方块间距
+    // itemSpacing: number = 0;   //方块间距
     brickNum: number = 0;
     //没使用颜色
     notUseColor = new Color(255, 255, 255, 255)
@@ -198,7 +198,7 @@ export class EliminateViewComp extends CCComp {
         this.max_row = GameConfig.MaxRow;
         this.max_col = GameConfig.MaxCol;
         this.itemSize = GameConfig.ItemSize;
-        this.itemSpacing = GameConfig.Spacing;
+        // this.itemSpacing = GameConfig.Spacing;
         this.brickNum = GameConfig.BlockNum;
         this.rotateFlag = false;
         this.rotateBrickData = null;
@@ -321,8 +321,8 @@ export class EliminateViewComp extends CCComp {
      */
     private setupGridsContainer(): void {
         const containerSize = {
-            width: this.itemSize * this.max_col + this.itemSpacing * 2,
-            height: this.itemSize * this.max_row + this.itemSpacing * 2
+            width: this.itemSize * this.max_col,
+            height: this.itemSize * this.max_row
         };
         if (this.gridsNode) {
             const uiTransform = this.gridsNode.getComponent(UITransform);
@@ -405,7 +405,7 @@ export class EliminateViewComp extends CCComp {
         // 设置网格大小
         gridNode.addComponent(UITransform).setContentSize(this.itemSize, this.itemSize);
         // 设置网格位置约束
-        this.setupGridWidget(gridNode, gridData.row, gridData.column);
+        // this.setupGridWidget(gridNode, gridData.row, gridData.column);
     }
 
     /**
@@ -415,13 +415,13 @@ export class EliminateViewComp extends CCComp {
      * @param {number} column
      * @return {*}
      */
-    private setupGridWidget(gridNode: Node, row: number, column: number): void {
-        const gridWidget = gridNode.addComponent(Widget);
-        gridWidget.isAlignLeft = true;
-        gridWidget.left = this.itemSize * column + this.itemSpacing;
-        gridWidget.isAlignBottom = true;
-        gridWidget.bottom = this.itemSize * row + this.itemSpacing;
-    }
+    // private setupGridWidget(gridNode: Node, row: number, column: number): void {
+    //     const gridWidget = gridNode.addComponent(Widget);
+    //     gridWidget.isAlignLeft = true;
+    //     gridWidget.left = this.itemSize * column;
+    //     gridWidget.isAlignBottom = true;
+    //     gridWidget.bottom = this.itemSize * row;
+    // }
 
 
 
@@ -507,8 +507,8 @@ export class EliminateViewComp extends CCComp {
         const transform = node.getComponent(UITransform);
         if (transform) {
             transform.setContentSize(
-                this.itemSize - this.itemSpacing * 2,
-                this.itemSize - this.itemSpacing * 2
+                this.itemSize,
+                this.itemSize
             );
         }
         // 设置位置
@@ -637,7 +637,7 @@ export class EliminateViewComp extends CCComp {
                         const nowGridData = this.gridList[rowIndex][columnIndex];
                         if (nowGridData && nowGridData.gridNode) {
                             const gridPos = nowGridData.gridNode.getWorldPosition()
-                            if (Vec3.distance(gridPos, brickGridPos) <= (this.itemSize / 2 - this.itemSpacing)) {
+                            if (Vec3.distance(gridPos, brickGridPos) <= (this.itemSize / 2)) {
                                 gridData = nowGridData
                             }
                         }
@@ -761,7 +761,7 @@ export class EliminateViewComp extends CCComp {
                 this.editingData.brickData.rotateFlag &&
                 event.getUILocation().subtract(this.touchStartLocation).length() < this.rotateFaultTolerant
             ) {
-                console.log("进这里啦?????????????????????")
+                //方块可以旋转了
                 this.rotateFlag = true
                 this.rotateBrickData = this.editingData.brickData;
                 if (this.rotateBrickData.brickNode) {
@@ -1031,8 +1031,8 @@ export class EliminateViewComp extends CCComp {
             const uiTransform = node.getComponent(UITransform);
             if (uiTransform) {
                 uiTransform.setContentSize(
-                    this.itemSize - this.itemSpacing * 2,
-                    this.itemSize - this.itemSpacing * 2,
+                    this.itemSize,
+                    this.itemSize,
                 )
             }
             node.on(Node.EventType.TOUCH_START, (event: EventTouch) => {