瀏覽代碼

优化重叠

972455782 1 年之前
父節點
當前提交
5510e3fca6
共有 1 個文件被更改,包括 43 次插入37 次删除
  1. 43 37
      Assets/Game_Hyperspace/Script/Move.cs

+ 43 - 37
Assets/Game_Hyperspace/Script/Move.cs

@@ -86,7 +86,7 @@ public abstract class Move
         return false;
         return false;
     }
     }
 
 
-    protected Func<SpineAnimationLoader, Vector2, bool, bool> IsUIBlock = (SpineAnimationLoader target, Vector2 pos, bool log) =>
+    protected Func<SpineAnimationLoader, Vector2, MoveType, bool, bool> IsUIBlock = (SpineAnimationLoader target, Vector2 pos, MoveType moveType, bool log) =>
     {
     {
         var radius = target.Radius();
         var radius = target.Radius();
 
 
@@ -103,29 +103,35 @@ public abstract class Move
         if (log)
         if (log)
             Debug.Log($"pos={pos}   paddingLeft={paddingLeft}  paddingTop={paddingTop}  paddingRight={paddingRight}  paddingDown={paddingDown}");
             Debug.Log($"pos={pos}   paddingLeft={paddingLeft}  paddingTop={paddingTop}  paddingRight={paddingRight}  paddingDown={paddingDown}");
 
 
-
-
-        ////上方170  右方133
-        //if (paddingTop <= 170 && paddingRight <= 133)
-        //    return true;
-
-        ////下148  左方 370
-        //if (paddingDown <= 148f && paddingLeft <= 370)
-        //    return true;
-
+        //if(moveType == MoveType.Stay || moveType.)
         //需要对称屏蔽
         //需要对称屏蔽
 
 
-        //上方 左方
-        if ((paddingDown <= 164 || paddingTop <= 164) && (paddingLeft <= 372 || paddingRight <= 372))
-            return true;
+        if (false)
+        {
+            //上方 左方
+            if ((paddingDown <= 164 || paddingTop <= 164) && (paddingLeft <= 372 || paddingRight <= 372))
+                return true;
 
 
-        //下  右方
-        if ((paddingDown <= 108 || paddingTop <= 108) && (paddingRight <= 134 || paddingLeft <= 134))
-            return true;
+            //下  右方
+            if ((paddingDown <= 108 || paddingTop <= 108) && (paddingRight <= 134 || paddingLeft <= 134))
+                return true;
 
 
-        //右方 133
-        if (paddingRight <= 133 || paddingLeft <= 133)
-            return true;
+            //右方 133
+            if (paddingRight <= 133 || paddingLeft <= 133)
+                return true;
+        }
+        else
+        {
+            //上方 左方
+            if (paddingTop <= 164 && paddingLeft <= 372)
+                return true;
+            //下  右方
+            if (paddingDown <= 108 && paddingRight <= 134)
+                return true;
+            //右方 133
+            if (paddingRight <= 133 || paddingLeft <= 133)
+                return true;
+        }
 
 
         return false;
         return false;
     };
     };
@@ -174,7 +180,7 @@ public class Stay : Move
         {
         {
             var randomPos = gos[i].GetRandomPos();
             var randomPos = gos[i].GetRandomPos();
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) || (CheckOverLap(gos[i], randomPos) && count > 0))
+            while (IsUIBlock(gos[i], randomPos, MoveType.Stay, false) || (CheckOverLap(gos[i], randomPos) && count > 0))
             {
             {
                 randomPos = gos[i].GetRandomPos();
                 randomPos = gos[i].GetRandomPos();
                 count--;
                 count--;
@@ -185,30 +191,30 @@ public class Stay : Move
                     var HHeight = canvasSize.y * 0.5f;
                     var HHeight = canvasSize.y * 0.5f;
                     var canUse = false;
                     var canUse = false;
                     var newPos = Vector2.zero;
                     var newPos = Vector2.zero;
-                    for (int xPos = 0; xPos <= HWidth - 200f; xPos += 20)
+                    for (int xPos = 0; xPos <= HWidth * 0.7f; xPos += 20)
                     {
                     {
-                        for (int yPos = 0; yPos < HHeight - 150f; yPos += 15)
+                        for (int yPos = 0; yPos < HHeight * 0.7f; yPos += 15)
                         {
                         {
                             newPos.x = xPos; newPos.y = yPos;
                             newPos.x = xPos; newPos.y = yPos;
-                            if (!IsUIBlock(gos[i], newPos, false) && !CheckOverLap(gos[i], newPos))
+                            if (!IsUIBlock(gos[i], newPos, MoveType.Stay, false) && !CheckOverLap(gos[i], newPos))
                             {
                             {
                                 canUse = true;
                                 canUse = true;
                                 break;
                                 break;
                             }
                             }
                             newPos.x = xPos; newPos.y = -yPos;
                             newPos.x = xPos; newPos.y = -yPos;
-                            if (!IsUIBlock(gos[i], newPos, false) && !CheckOverLap(gos[i], newPos))
+                            if (!IsUIBlock(gos[i], newPos, MoveType.Stay, false) && !CheckOverLap(gos[i], newPos))
                             {
                             {
                                 canUse = true;
                                 canUse = true;
                                 break;
                                 break;
                             }
                             }
                             newPos.x = -xPos; newPos.y = yPos;
                             newPos.x = -xPos; newPos.y = yPos;
-                            if (!IsUIBlock(gos[i], newPos, false) && !CheckOverLap(gos[i], newPos))
+                            if (!IsUIBlock(gos[i], newPos, MoveType.Stay, false) && !CheckOverLap(gos[i], newPos))
                             {
                             {
                                 canUse = true;
                                 canUse = true;
                                 break;
                                 break;
                             }
                             }
                             newPos.x = -xPos; newPos.y = -yPos;
                             newPos.x = -xPos; newPos.y = -yPos;
-                            if (!IsUIBlock(gos[i], newPos, false) && !CheckOverLap(gos[i], newPos))
+                            if (!IsUIBlock(gos[i], newPos, MoveType.Stay, false) && !CheckOverLap(gos[i], newPos))
                             {
                             {
                                 canUse = true;
                                 canUse = true;
                                 break;
                                 break;
@@ -241,7 +247,7 @@ public class LeftToRight : Move, IUpdate
         {
         {
             var randomPos = gos[i].GetRandomPos(PosType.Left);
             var randomPos = gos[i].GetRandomPos(PosType.Left);
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) || CheckOverLap(gos[i], randomPos, MoveType.LeftToRight) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.LeftToRight, false) || CheckOverLap(gos[i], randomPos, MoveType.LeftToRight) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(PosType.Left);
                 randomPos = gos[i].GetRandomPos(PosType.Left);
                 count--;
                 count--;
@@ -267,7 +273,7 @@ public class RightToLeft : Move
         {
         {
             var randomPos = gos[i].GetRandomPos(PosType.Right);
             var randomPos = gos[i].GetRandomPos(PosType.Right);
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) || CheckOverLap(gos[i], randomPos, MoveType.RightToLeft) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.RightToLeft, false) || CheckOverLap(gos[i], randomPos, MoveType.RightToLeft) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(PosType.RightDown);
                 randomPos = gos[i].GetRandomPos(PosType.RightDown);
                 count--;
                 count--;
@@ -294,7 +300,7 @@ public class RelativeHor : Move
             var tempPos = i % 2 == 0 ? PosType.LeftDown : PosType.RightDown;
             var tempPos = i % 2 == 0 ? PosType.LeftDown : PosType.RightDown;
             var randomPos = gos[i].GetRandomPos(tempPos);
             var randomPos = gos[i].GetRandomPos(tempPos);
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) || CheckOverLap(gos[i], randomPos, MoveType.RelativeHor, gos.Count) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.RelativeHor, false) || CheckOverLap(gos[i], randomPos, MoveType.RelativeHor, gos.Count) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(tempPos);
                 randomPos = gos[i].GetRandomPos(tempPos);
                 count--;
                 count--;
@@ -321,7 +327,7 @@ public class RelativeVet : Move
             var tempPos = i % 2 == 0 ? PosType.Top : PosType.Down;
             var tempPos = i % 2 == 0 ? PosType.Top : PosType.Down;
             var randomPos = gos[i].GetRandomPos(tempPos);
             var randomPos = gos[i].GetRandomPos(tempPos);
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) || CheckOverLap(gos[i], randomPos, MoveType.RelativeVet, gos.Count) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.RelativeVet, false) || CheckOverLap(gos[i], randomPos, MoveType.RelativeVet, gos.Count) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(tempPos);
                 randomPos = gos[i].GetRandomPos(tempPos);
                 count--;
                 count--;
@@ -356,7 +362,7 @@ public class Diagonal : Move
             var randomPos = gos[i].GetRandomPos(posType, 0.25f);
             var randomPos = gos[i].GetRandomPos(posType, 0.25f);
 
 
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.Diagonal, false) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(posType, 0.25f);
                 randomPos = gos[i].GetRandomPos(posType, 0.25f);
                 count--;
                 count--;
@@ -384,7 +390,7 @@ public class W : Move
             var tempPos = i % 2 == 0 ? PosType.LeftTop : PosType.LeftDown;
             var tempPos = i % 2 == 0 ? PosType.LeftTop : PosType.LeftDown;
             var randomPos = gos[i].GetRandomPos(tempPos, 0.25f);
             var randomPos = gos[i].GetRandomPos(tempPos, 0.25f);
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.W, false) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(tempPos, 0.25f);
                 randomPos = gos[i].GetRandomPos(tempPos, 0.25f);
                 count--;
                 count--;
@@ -427,7 +433,7 @@ public class W2 : Move
 
 
             var randomPos = gos[i].GetRandomPos(tempPos, 0.25f);
             var randomPos = gos[i].GetRandomPos(tempPos, 0.25f);
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.W2, false) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(tempPos, 0.25f);
                 randomPos = gos[i].GetRandomPos(tempPos, 0.25f);
                 count--;
                 count--;
@@ -460,7 +466,7 @@ public class HOR : Move
         {
         {
             var randomPos = gos[i].GetRandomPos(tempPos);
             var randomPos = gos[i].GetRandomPos(tempPos);
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) || CheckOverLap(gos[i], randomPos) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.HOR, false) || CheckOverLap(gos[i], randomPos) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(tempPos);
                 randomPos = gos[i].GetRandomPos(tempPos);
                 count--;
                 count--;
@@ -488,7 +494,7 @@ public class VET : Move
         {
         {
             var randomPos = gos[i].GetRandomPos(tempPos);
             var randomPos = gos[i].GetRandomPos(tempPos);
             int count = RamdomNum;
             int count = RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) || CheckOverLap(gos[i], randomPos) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.VET, false) || CheckOverLap(gos[i], randomPos) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(tempPos);
                 randomPos = gos[i].GetRandomPos(tempPos);
                 count--;
                 count--;
@@ -514,7 +520,7 @@ public class ROT : Move, IUpdate
         {
         {
             var randomPos = gos[i].GetRandomPos(PosType.Rotate);
             var randomPos = gos[i].GetRandomPos(PosType.Rotate);
             int count = 2 * RamdomNum;
             int count = 2 * RamdomNum;
-            while (IsUIBlock(gos[i], randomPos, false) || CheckOverLap(gos[i], randomPos) && count > 0)
+            while (IsUIBlock(gos[i], randomPos, MoveType.ROT, false) || CheckOverLap(gos[i], randomPos) && count > 0)
             {
             {
                 randomPos = gos[i].GetRandomPos(PosType.Rotate);
                 randomPos = gos[i].GetRandomPos(PosType.Rotate);
                 count--;
                 count--;