Browse Source

合成提示

甘艺伟 4 days ago
parent
commit
ad31023231

+ 38 - 3
assets/bundle/gridMap/UEMergeTip.prefab

@@ -34,10 +34,13 @@
     "_components": [
     "_components": [
       {
       {
         "__id__": 50
         "__id__": 50
+      },
+      {
+        "__id__": 51
       }
       }
     ],
     ],
     "_prefab": {
     "_prefab": {
-      "__id__": 51
+      "__id__": 52
     },
     },
     "_opacity": 255,
     "_opacity": 255,
     "_color": {
     "_color": {
@@ -49,8 +52,8 @@
     },
     },
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 100,
-      "height": 100
+      "width": 200,
+      "height": 200
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -1757,6 +1760,38 @@
     "_id": ""
     "_id": ""
   },
   },
   {
   {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
+    "_srcBlendFactor": 770,
+    "_dstBlendFactor": 771,
+    "_spriteFrame": {
+      "__uuid__": "f676efbd-584b-40d6-9040-e5e1e7f91820"
+    },
+    "_type": 0,
+    "_sizeMode": 0,
+    "_fillType": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
     "__type__": "cc.PrefabInfo",
     "__type__": "cc.PrefabInfo",
     "root": {
     "root": {
       "__id__": 1
       "__id__": 1

BIN
assets/bundle/gridMap/images/mergeTipBg.png


+ 38 - 0
assets/bundle/gridMap/images/mergeTipBg.png.meta

@@ -0,0 +1,38 @@
+{
+  "ver": "2.3.7",
+  "uuid": "9c951887-c82b-46f3-bd2b-6a6e5e01ce44",
+  "importer": "texture",
+  "type": "sprite",
+  "wrapMode": "clamp",
+  "filterMode": "bilinear",
+  "premultiplyAlpha": false,
+  "genMipmaps": false,
+  "packable": true,
+  "width": 160,
+  "height": 160,
+  "platformSettings": {},
+  "subMetas": {
+    "mergeTipBg": {
+      "ver": "1.0.6",
+      "uuid": "f676efbd-584b-40d6-9040-e5e1e7f91820",
+      "importer": "sprite-frame",
+      "rawTextureUuid": "9c951887-c82b-46f3-bd2b-6a6e5e01ce44",
+      "trimType": "auto",
+      "trimThreshold": 1,
+      "rotated": false,
+      "offsetX": 0,
+      "offsetY": 0,
+      "trimX": 0,
+      "trimY": 0,
+      "width": 160,
+      "height": 160,
+      "rawWidth": 160,
+      "rawHeight": 160,
+      "borderTop": 0,
+      "borderBottom": 0,
+      "borderLeft": 0,
+      "borderRight": 0,
+      "subMetas": {}
+    }
+  }
+}

+ 1 - 1
assets/script/data/model/GridMap/GridMapModel.ts

@@ -159,7 +159,7 @@ export default class GridMapModel extends GridMapModelData {
     public GetMergeItems(cube1: UECube, cube2: UECube) {
     public GetMergeItems(cube1: UECube, cube2: UECube) {
         let formulaKey = `${cube1.GetCubeData().type}_${cube1.GetCubeData().id}_${cube2.GetCubeData().type}_${cube2.GetCubeData().id}`;
         let formulaKey = `${cube1.GetCubeData().type}_${cube1.GetCubeData().id}_${cube2.GetCubeData().type}_${cube2.GetCubeData().id}`;
         let mergeArr = this.formulaMap[formulaKey];
         let mergeArr = this.formulaMap[formulaKey];
-        return mergeArr;
+        return mergeArr || [];
     }
     }
 
 
 
 

+ 30 - 1
assets/script/logic/gridMap/UEGridMap.ts

@@ -200,7 +200,7 @@ export default class UEGridMap extends UEBase {
             cube.node.setPosition(originalPos.x + deltaPos.x, originalPos.y + deltaPos.y);
             cube.node.setPosition(originalPos.x + deltaPos.x, originalPos.y + deltaPos.y);
             this.dragStartPos = touchPos;
             this.dragStartPos = touchPos;
             const targetCell = this.GetCellByPos(touchPos);
             const targetCell = this.GetCellByPos(touchPos);
-            if (targetCell && targetCell != this.selectedCell) {
+            if (targetCell && !targetCell.IsEmpty() && targetCell != this.selectedCell) {
                 if (GameDataCenter.gridMap.CellCanPut(this.selectedCell, targetCell)) {
                 if (GameDataCenter.gridMap.CellCanPut(this.selectedCell, targetCell)) {
                     this.ueMergeTip.node.setPosition(targetCell.node.getPosition());
                     this.ueMergeTip.node.setPosition(targetCell.node.getPosition());
                     this.ueMergeTip.Init({
                     this.ueMergeTip.Init({
@@ -374,6 +374,35 @@ export default class UEGridMap extends UEBase {
         mergeCube.node.runAction(seq);
         mergeCube.node.runAction(seq);
     }
     }
 
 
+    /** 计算圆上的位置 */
+    private GetCirclePosition(index: number, total: number): cc.Vec2 {
+        const radius = 150; // 圆的半径
+
+        if (total === 1) {
+            // 只有一个元素时,放在正上方
+            return cc.v2(0, radius);
+        }
+
+        // 计算每个元素之间的角度
+        const angleStep = 60; // 相邻两个元素之间的角度
+        const startAngle = 90 + ((total - 1) * angleStep) / 2; // 从90度(正上方)开始,向右分布
+
+        // 计算当前元素的角度(角度转弧度)
+        const angle = (startAngle - index * angleStep) * Math.PI / 180; // 减去角度使其向右分布
 
 
+        // 计算圆上的位置
+        const x = radius * Math.cos(angle);
+        const y = radius * Math.sin(angle);
+
+        return cc.v2(x, y);
+    }
+
+    /** 设置物品在圆上的位置 */
+    private SetItemsPosition(mergeArr: any[]) {
+        mergeArr.forEach((item, index) => {
+            const pos = this.GetCirclePosition(index, mergeArr.length);
+            item.node.setPosition(pos);
+        });
+    }
 
 
 }
 }

+ 28 - 0
assets/script/logic/gridMap/UEMergeTip.ts

@@ -34,6 +34,8 @@ export default class UEMergeTip extends UEBase {
             this.node.active = true;
             this.node.active = true;
             for (let i = 1; i <= 4; i++) {
             for (let i = 1; i <= 4; i++) {
                 let itemNode = this.node.children[i - 1];
                 let itemNode = this.node.children[i - 1];
+                let pos = this.GetCirclePosition(i - 1, mergeArr.length);
+                itemNode.setPosition(pos);
                 this.ShowItem(itemNode, mergeArr[i - 1]);
                 this.ShowItem(itemNode, mergeArr[i - 1]);
             }
             }
         } else {
         } else {
@@ -46,6 +48,7 @@ export default class UEMergeTip extends UEBase {
         let node_lock = node.getChildByName("node_lock");
         let node_lock = node.getChildByName("node_lock");
         if (data) {
         if (data) {
             node.active = true;
             node.active = true;
+            node_lock.active = false;
             if (data.type == E_CubeType.Emitter) {
             if (data.type == E_CubeType.Emitter) {
                 let mergePropCfg = Gamecfg.emitterInfo.getItem(data.id.toString());
                 let mergePropCfg = Gamecfg.emitterInfo.getItem(data.id.toString());
                 sp_icon.setSpriteFrame('gridMap', `mergeProp/${mergePropCfg.icon}`);
                 sp_icon.setSpriteFrame('gridMap', `mergeProp/${mergePropCfg.icon}`);
@@ -61,4 +64,29 @@ export default class UEMergeTip extends UEBase {
         }
         }
     }
     }
 
 
+    /** 计算圆上的位置 */
+    private GetCirclePosition(index: number, total: number): cc.Vec2 {
+        const radius = 100; // 圆的半径
+
+        if (total === 1) {
+            // 只有一个元素时,放在正上方
+            return cc.v2(0, radius);
+        }
+
+
+        // 计算每个元素之间的角度
+        const angleStep = 60; // 相邻两个元素之间的角度
+        const startAngle = 90 + -total * angleStep / 2 + angleStep / 2; // 从90度(正上方)开始,向右分布
+
+        // 计算当前元素的角度(角度转弧度)
+        const angle = (startAngle + index * angleStep) * Math.PI / 180; // 减去角度使其向右分布
+
+        // 计算圆上的位置
+        const x = radius * Math.cos(angle);
+        const y = radius * Math.sin(angle);
+
+        return cc.v2(x, y);
+    }
+
+
 }
 }