甘艺伟 8 hodín pred
rodič
commit
84a417dfcb

+ 21 - 3
assets/script/logic/gridMap/UECube.ts

@@ -4,6 +4,8 @@ import ResSprite from "../../frameWork/compment/ResSprite";
 import UEBase from "../../frameWork/compment/UEBase";
 import { HcType } from "../../shared/hc/PtlHcInfo";
 import AssetMgr from "../../utils/AssetMgr";
+import { uiCommon } from "../../utils/UICommon";
+import { GridConstant } from "./GridConstant";
 import UEHomeRole from "./UEHomeRole";
 
 const { ccclass, property } = cc._decorator;
@@ -112,9 +114,6 @@ export default class UECube extends UEBase {
         this.node.zIndex = this.cubeData.idx;
     }
 
-    ClearCell() {
-
-    }
 
     /** 回到原来位置 */
     BackToOriginalPos(needMove: boolean) {
@@ -164,6 +163,25 @@ export default class UECube extends UEBase {
             .start();
     }
 
+    /** 吸附效果 */
+    Adsorb(degree: number) {
+        let pos = uiCommon.GetPointOnCircle(GridConstant.CELL_WIDTH * 0.1, degree, cc.v2(0, 0));
+        cc.tween(this.itemNode)
+            .to(0.1, { position: pos })
+            .call(() => {
+
+            })
+            .start();
+    }
+
+    /** 取消吸附 */
+    CancelAdsorb() {
+        cc.tween(this.itemNode)
+            .to(0.1, { position: cc.Vec3.ZERO })
+            .start();
+    }
+
+
     public unUse() {
         this.node.destroy();
     }

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

@@ -2,6 +2,7 @@
 import GameDataCenter from "../../data/GameDataCenter";
 import UEBase from "../../frameWork/compment/UEBase";
 import EventMng from "../../manager/EventMng";
+import { uiCommon } from "../../utils/UICommon";
 import { GridEvent } from "./GridEvent";
 import UECube from "./UECube";
 import UEMergeTipItem from "./UEMergeTipItem";
@@ -27,6 +28,7 @@ export default class UEMergeTip extends UEBase {
     bg: cc.Node = null!;
 
     data: I_MergeTipData = null!;
+    lastAdsorbCube: UECube = null;
     Init(data: I_MergeTipData) {
         //检测是否重复位置和重复合成链
         // this.node.active = true;
@@ -55,6 +57,9 @@ export default class UEMergeTip extends UEBase {
             } else {
                 this.bg.angle = -25;
             }
+            let angle = uiCommon.GetTwoPointAngle(data.ueCube2.node.position, data.ueCube1.node.position);
+            this.data.ueCube2.Adsorb(angle);
+            this.lastAdsorbCube = this.data.ueCube2;
         } else {
             this.node.active = false;
             EventMng.emit(GridEvent.HC_MERGE_TIP, { isShow: false });
@@ -65,6 +70,10 @@ export default class UEMergeTip extends UEBase {
     Hide() {
         this.node.active = false;
         EventMng.emit(GridEvent.HC_MERGE_TIP, { isShow: false });
+        if (this.lastAdsorbCube) {
+            this.lastAdsorbCube.CancelAdsorb();
+            this.lastAdsorbCube = null;
+        }
     }
 
     /** 计算圆上的位置 */

+ 1 - 1
assets/script/utils/UICommon.ts

@@ -1246,7 +1246,7 @@ class UICommon {
     }
 
     /** 获取两点角度 */
-    public GetTwoPointAngle(center: cc.Vec2, point: cc.Vec2) {
+    public GetTwoPointAngle(center: cc.Vec2 | cc.Vec3, point: cc.Vec2 | cc.Vec3) {
         const dx = point.x - center.x;
         const dy = point.y - center.y;
         const angleRadians = Math.atan2(dy, dx);