Prechádzať zdrojové kódy

修改爆炸方向逻辑

LAPTOP-OM1V99U2\永远de小亡灵 1 rok pred
rodič
commit
dbc455e94f

+ 45 - 4
ActionTowerDefense/Assets/Scripts/Spirits/SoulBoom.cs

@@ -42,14 +42,55 @@ public class SoulBoom : MonoBehaviour
                         }
 
                         Vector3 target;
-                        if (characters[i].transform.position.x > transform.position.x)
+                        Vector3 pos1 = characters[i].transform.position;
+                        Vector3 pos2 = transform.position;
+                        if (pos1.x > pos2.x)
                         {
-                            target = attackInfo.attackDir;
+                            if (pos1.y > pos2.y)
+                            {
+                                target = new Vector3(-attackInfo.attackDir.x, attackInfo.attackDir.y,0);
+                            }
+                            else if(pos1.y < pos2.y)
+                            {
+                                target = new Vector3(-attackInfo.attackDir.x, -attackInfo.attackDir.y,0);
+
+                            }
+                            else
+                            {
+                                target = new Vector3(-attackInfo.attackDir.x, 0,0);
+                            }
+                        }
+                        else if(pos1.x < pos2.x)
+                        {
+                            if(pos1.y > pos2.y)
+                            {
+                                target = new Vector3(attackInfo.attackDir.x, attackInfo.attackDir.y, 0);
+                            }
+                            else if(pos1.y < pos2.y)
+                            {
+                                target = new Vector3(attackInfo.attackDir.x, -attackInfo.attackDir.y, 0);
+                            }
+                            else
+                            {
+                                target = new Vector3(attackInfo.attackDir.x, 0, 0);
+                            }
+
                         }
                         else
                         {
-                            target = new Vector3(-attackInfo.attackDir.x, attackInfo.attackDir.y,
-                                attackInfo.attackDir.z);
+                            if (pos1.y > pos2.y)
+                            {
+                                target = new Vector3(0, attackInfo.attackDir.y, 0);
+                            }
+                            else if (pos1.y < pos2.y)
+                            {
+                                target = new Vector3(0, -attackInfo.attackDir.y, 0);
+                            }
+                            else
+                            {
+                                target = new Vector3(0, 0, 0);
+                            }
+
                         }