Bladeren bron

锁魂塔bug修复

SZAND\msx_2 1 jaar geleden
bovenliggende
commit
793c3a015e

+ 2 - 1
ActionTowerDefense/Assets/Scenes/SampleScene.unity

@@ -523,6 +523,7 @@ MonoBehaviour:
   invincibleTime: 0
   injuryNumText: {fileID: 0}
   showInjuryNum: 0
+  ls: {fileID: 0}
   isInSoulTower: 0
   totalDieKeepTime: 2
   dieKeepTime: 0
@@ -30084,7 +30085,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 6220511700128991423, guid: dd98f16e694849044b9b84d56d30cdb1, type: 3}
       propertyPath: m_LocalPosition.x
-      value: 76
+      value: 172.3
       objectReference: {fileID: 0}
     - target: {fileID: 6220511700128991423, guid: dd98f16e694849044b9b84d56d30cdb1, type: 3}
       propertyPath: m_LocalPosition.y

+ 3 - 0
ActionTowerDefense/Assets/Scripts/Character.cs

@@ -85,6 +85,9 @@ public class Character : MonoBehaviour
     public float invincibleTime;    //无敌时间
     public GameObject injuryNumText;//伤害跳字
     public bool showInjuryNum;      //伤害跳字开关
+
+    [Header("锁魂塔")]
+    public LockSoul ls;
     public bool isInSoulTower;      //在锁魂塔范围内
 
     [Header("死亡后多久尸体消失")]

+ 16 - 2
ActionTowerDefense/Assets/Scripts/Demonic.cs

@@ -19,8 +19,11 @@ public class Demonic : MoveCharacter
     public int baseSortingOrder;
     int sortingOrder = 0;
     public float runSpeed;
+
+    [Header("Ëø»êËþ")]
     public bool isReturnSoulTower;
     public Vector3 origSoulPos;
+    public bool isRecorded;
 
     [Header("ÓÑ·½µ¥Î»×é¼þ")]
     public SearchState searchState;
@@ -68,6 +71,16 @@ public class Demonic : MoveCharacter
         OnState();
     }
 
+    private void Update()
+    {
+        base.Update();
+        if (isInSoulTower && targetCharacter == null && state != CharacterState.LockSoul && !isReturnSoulTower)
+        {
+            isReturnSoulTower = true;
+            ChangeState(CharacterState.LockSoul);
+        }
+    }
+
     public bool SearchTarget()
     {
         targetCharacter = searchTrigger.GetMinDisTarget(targetTypes, canHitFly);
@@ -579,7 +592,7 @@ public class Demonic : MoveCharacter
                 }
                 else
                 {
-                    if (transform.position.x - origSoulPos.x >= 0.5f)
+                    if (transform.position.x - origSoulPos.x >= 0.2f)
                     {
                         rb.velocity = Vector3.right * (-moveSpeed + velocityAddition);
                         if (bodyTrans.localScale.x < 0)
@@ -587,7 +600,7 @@ public class Demonic : MoveCharacter
                             Turn();
                         }
                     }
-                    else if (origSoulPos.x - transform.position.x >= 0.5f)
+                    else if (origSoulPos.x - transform.position.x >= 0.2f)
                     {
                         rb.velocity = Vector3.right * (moveSpeed + velocityAddition);
                         if (bodyTrans.localScale.x > 0)
@@ -597,6 +610,7 @@ public class Demonic : MoveCharacter
                     }
                     else
                     {
+                        rb.velocity = Vector3.zero;
                         transform.position = origSoulPos;
                         isReturnSoulTower = false;
                         targetCharacter = null;

+ 4 - 0
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -1791,6 +1791,10 @@ public class PlayerController : MoveCharacter
             spirits.ultimateTimes[spirits.nowSpirit] -= 1;
         }
         spiritSystem.RefreshPlayerUI();
+        if (isInSoulTower)
+        {
+            ls.AddDenomic(demonic);
+        }
     }
 
     public void OnDemonicRecycle(Demonic demonic)

+ 19 - 9
ActionTowerDefense/Assets/Scripts/SoulTower/LockSoul.cs

@@ -8,16 +8,10 @@ public class LockSoul : MonoBehaviour
     private int nowLock;
     public List<Demonic> souls = new List<Demonic>();
 
-    private void OnTriggerEnter(Collider other)
+    public void AddDenomic(Demonic d)
     {
-        if (other.gameObject.layer == 8)
-        {
-            Character c = other.GetComponentInParent<Character>();
-            c.isInSoulTower = true;
-        }
-        if (other.gameObject.layer == 7)
+        if (!d.isRecorded)
         {
-            Demonic d = other.GetComponentInParent<Demonic>();
             d.isInSoulTower = true;
             d.origSoulPos = d.transform.position;
             if (IsSoulsFull())
@@ -25,13 +19,29 @@ public class LockSoul : MonoBehaviour
                 Demonic s = souls[0];
                 s.isInSoulTower = false;
                 souls.Remove(s);
+                s.isRecorded = false;
+                s.ChangeState(CharacterState.Idle);
             }
             souls.Add(d);
+            d.isRecorded = true;
             nowLock++;
             d.ChangeState(CharacterState.LockSoul);
         }
     }
 
+    private void OnTriggerEnter(Collider other)
+    {
+        if (other.gameObject.layer == 8 || other.gameObject.layer == 6)
+        {
+            Character c = other.GetComponentInParent<Character>();
+            if (other.gameObject.layer == 6 && c.ls == null)
+            {
+                c.ls = this;
+            }
+            c.isInSoulTower = true;
+        }
+    }
+
     private bool IsSoulsFull()
     {
         bool isFull = false;
@@ -57,7 +67,7 @@ public class LockSoul : MonoBehaviour
 
     private void OnTriggerExit(Collider other)
     {
-        if (other.gameObject.layer == 8)
+        if (other.gameObject.layer == 8 || other.gameObject.layer == 6)
         {
             Character c = other.GetComponentInParent<Character>();
             c.isInSoulTower = false;

+ 1 - 1
ActionTowerDefense/Assets/Scripts/SoulTower/SoulMaxDistance.cs

@@ -4,7 +4,7 @@ using UnityEngine;
 
 public class SoulMaxDistance : MonoBehaviour
 {
-    private void OnTriggerEnter(Collider other)
+    private void OnTriggerExit(Collider other)
     {
         if (other.gameObject.layer == 7)
         {