Răsfoiți Sursa

修改Z轴刷新后出现的距离bug

LAPTOP-OM1V99U2\永远de小亡灵 1 an în urmă
părinte
comite
f400e0b22b

+ 16 - 20
ActionTowerDefense/Assets/Resources/Prefab/Transfiguration/Trans_Invisible.prefab

@@ -188,7 +188,7 @@ Transform:
   - {fileID: 2730232521377132808}
   - {fileID: 5061628209490452354}
   - {fileID: 4824124076759881995}
-  - {fileID: 17818087937920490}
+  - {fileID: 2465817539840671398}
   - {fileID: 8507731236713456294}
   m_Father: {fileID: 0}
   m_RootOrder: 0
@@ -1218,7 +1218,7 @@ MonoBehaviour:
   angle: 0
   soulsNumber: 0
   rotateSpeed: 90
-  soul: {fileID: 17818087743600479}
+  soul: {fileID: 2465817539514729491}
   eSpirits: {fileID: 0}
   soulsList: []
   distance: 1.5
@@ -1226,13 +1226,13 @@ MonoBehaviour:
   destroyTime: 3
   isTransfiguration: 1
   KBoomSoulTime: -100
-  soulBoom: {fileID: 3285632007868534942}
+  soulBoom: {fileID: 1125884991471150034}
   isBooming: 0
   isBoom: 0
   boomSoulNumber: 0
   soulCollector: {fileID: 1289604965499631171}
   boomScale: 0
---- !u!1001 &1717720538502236081
+--- !u!1001 &3878033803522684157
 PrefabInstance:
   m_ObjectHideFlags: 0
   serializedVersion: 2
@@ -1291,26 +1291,12 @@ PrefabInstance:
       propertyPath: m_IsActive
       value: 0
       objectReference: {fileID: 0}
-    - target: {fileID: 4201428945599059759, guid: a956ce2c24a9a8b4b98cbf27ef623367, type: 3}
-      propertyPath: attackInfo.damage
-      value: 99999999
-      objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: a956ce2c24a9a8b4b98cbf27ef623367, type: 3}
---- !u!1 &17818087743600479 stripped
-GameObject:
-  m_CorrespondingSourceObject: {fileID: 1723151111081767150, guid: a956ce2c24a9a8b4b98cbf27ef623367, type: 3}
-  m_PrefabInstance: {fileID: 1717720538502236081}
-  m_PrefabAsset: {fileID: 0}
---- !u!4 &17818087937920490 stripped
-Transform:
-  m_CorrespondingSourceObject: {fileID: 1723151111827507803, guid: a956ce2c24a9a8b4b98cbf27ef623367, type: 3}
-  m_PrefabInstance: {fileID: 1717720538502236081}
-  m_PrefabAsset: {fileID: 0}
---- !u!114 &3285632007868534942 stripped
+--- !u!114 &1125884991471150034 stripped
 MonoBehaviour:
   m_CorrespondingSourceObject: {fileID: 4201428945599059759, guid: a956ce2c24a9a8b4b98cbf27ef623367, type: 3}
-  m_PrefabInstance: {fileID: 1717720538502236081}
+  m_PrefabInstance: {fileID: 3878033803522684157}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 0}
   m_Enabled: 1
@@ -1318,6 +1304,16 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: a7ca44b9cabcdeb4bb198cc532b04e86, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+--- !u!1 &2465817539514729491 stripped
+GameObject:
+  m_CorrespondingSourceObject: {fileID: 1723151111081767150, guid: a956ce2c24a9a8b4b98cbf27ef623367, type: 3}
+  m_PrefabInstance: {fileID: 3878033803522684157}
+  m_PrefabAsset: {fileID: 0}
+--- !u!4 &2465817539840671398 stripped
+Transform:
+  m_CorrespondingSourceObject: {fileID: 1723151111827507803, guid: a956ce2c24a9a8b4b98cbf27ef623367, type: 3}
+  m_PrefabInstance: {fileID: 3878033803522684157}
+  m_PrefabAsset: {fileID: 0}
 --- !u!1001 &7464584808883890403
 PrefabInstance:
   m_ObjectHideFlags: 0

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -464,7 +464,7 @@ public class Enemy : MoveCharacter
                             break;
                         }
                     }
-                    if (Vector3.Distance(transform.position, targetCharacter.transform.position)
+                    if (Mathf.Abs(transform.position.x-targetCharacter.transform.position.x)
                         < hateDistance)
                     {
                         rushEndPos = targetCharacter.transform.position;

+ 24 - 10
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Invisible.cs

@@ -62,7 +62,8 @@ public class ESpirits_Invisible : MonoBehaviour
     }
     void OnState()
     {
-        
+        Vector3 pos1;
+        Vector3 pos2;
         switch (state)
         {
             case InvisibleState.Normal:
@@ -78,7 +79,7 @@ public class ESpirits_Invisible : MonoBehaviour
                     return;
                 }
                 posx = PlayersInput.instance[nowPlayer].transform.position.x;
-                targetPos = new Vector3(posx + offsetX, altitude + offsetY, 0);
+                targetPos = new Vector3(posx + offsetX, altitude + offsetY, transform.position.z);
                 Goto(targetPos, moveSpeed);
                 if (Vector3.Distance(targetPos, transform.position) < 1)
                 {
@@ -110,7 +111,10 @@ public class ESpirits_Invisible : MonoBehaviour
             case InvisibleState.FindSoul:
                 if (targetSoul.gameObject.activeSelf)
                 {
-                    if(Vector3.Distance(transform.position, targetSoul.transform.position) <= 1)
+                    pos1 = new Vector3(transform.position.x, transform.position.y, 0);
+                    pos2 = new Vector3(targetSoul.transform.position.x,
+                        targetSoul.transform.position.y, 0);
+                    if(Vector3.Distance(pos1, pos2) <= 1)
                     {
                         SoulInMap.souls.Remove(targetSoul);
                         targetSoul.gameObject.SetActive(false);
@@ -133,13 +137,17 @@ public class ESpirits_Invisible : MonoBehaviour
                     ChangeState(InvisibleState.Normal);
                     break;
                 }
-                targetPos = targetSoul.transform.position;
+                targetPos = new Vector3(targetSoul.transform.position.x,targetSoul.transform.position.y,
+                    transform.position.z);
+                
                 Goto(targetPos, findSoulSpeed);
                 
                 break;
             case InvisibleState.FindPlayer:
-                if (Vector3.Distance(transform.position, 
-                    enemy.targetCharacter.transform.position + Vector3.up * 0.5f)<= enemy.hateDistance)
+                pos1 = new Vector3(transform.position.x, transform.position.y, 0);
+                pos2 = new Vector3(enemy.targetCharacter.transform.position.x,
+                    enemy.targetCharacter.transform.position.y + 0.5f, 0);
+                if (Vector3.Distance(pos1,pos2)<= enemy.hateDistance)
                 {
                     ChangeState(InvisibleState.Boom);
                     break;
@@ -181,7 +189,7 @@ public class ESpirits_Invisible : MonoBehaviour
                 break;
             case InvisibleState.Hurt:
                 posx = transform.position.x;
-                targetPos = new Vector3(posx + offsetX - back, altitude + offsetY, 0);
+                targetPos = new Vector3(posx + offsetX - back, altitude + offsetY, transform.position.z);
                 
                 break;
             case InvisibleState.FindSoul:
@@ -215,17 +223,23 @@ public class ESpirits_Invisible : MonoBehaviour
     }
     public void FindSoul()
     {
-        List<Soul> souls = SoulInMap.souls;
+        Vector3 pos1;
+        Vector3 pos2;
+        List <Soul> souls = SoulInMap.souls;
         if(souls.Count == 0)
         {
             targetSoul = null;
             return;
         }
-        float minDistance = Vector3.Distance(souls[0].transform.position, transform.position);
+        pos1 = new Vector3(souls[0].transform.position.x, souls[0].transform.position.y, 0);
+        pos2 = new Vector3(transform.position.x, transform.position.y, 0);
+        float minDistance = Vector3.Distance(pos1,pos2);
         int targetSoulId = 0;
         for(int i = 1; i < souls.Count; i++)
         {
-            float distance = Vector3.Distance(souls[i].transform.position, transform.position);
+            pos1 = new Vector3(souls[i].transform.position.x, souls[i].transform.position.y, 0);
+            pos2 = new Vector3(transform.position.x, transform.position.y, 0);
+            float distance = Vector3.Distance(pos1,pos2);
             if (distance < minDistance)
             {
                 minDistance = distance;

+ 1 - 0
ActionTowerDefense/Assets/Scripts/Spirits/SoulFollowEffect.cs

@@ -85,6 +85,7 @@ public class SoulFollowEffect : MonoBehaviour
         {
             boomSoul.transform.parent = transform;
             Transform bomb = boomSoul.transform.GetChild(0);
+            boomSoul.transform.localScale = Vector3.one * boomScale;
             for (int i = 0; i < bomb.childCount; i++)
             {
                 bomb.GetChild(i).localScale = Vector3.one * boomScale;