Selaa lähdekoodia

修复龙卷扇部分bug

WGL 1 kuukausi sitten
vanhempi
commit
f9ca526465

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Characters/AttackTrigger.cs

@@ -101,7 +101,7 @@ public class AttackTrigger : MonoBehaviour
         if (!other.TryGetComponent(out BeHitTrigger hitTrigger)) return;
         int index = trigedObjs.IndexOf(hitTrigger);
         if (index == -1) return;
-        trigedObjs.RemoveAt(index);
+        trigedObjs.Remove(hitTrigger);
         trigedTime.RemoveAt(index);
     }
 

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs

@@ -1771,7 +1771,7 @@ public class PlayerController : MoveCharacter
 
     public override void BeHit(AttackController.AttackMethod attackMethod, Character attackFrom, int damage = -1)
     {
-        Photosphere photosphere = conductController.photosphere;
+        Photosphere photosphere = conductController.photospheres[conductController.photospheres.Count - 1];
         if (photosphere)
         {
             if(damage == -1)

+ 6 - 14
ActionTowerDefense/Assets/Scripts/Conduct/ConductController.cs

@@ -19,7 +19,7 @@ public class ConductController : MonoBehaviour
    
     [LabelText("Èڻ꼼")] public ConductSkills[] conductSkills;
 
-    public Photosphere photosphere;
+    public List<Photosphere> photospheres = new List<Photosphere>();
     
     private void Awake()
     {
@@ -148,23 +148,15 @@ public class ConductController : MonoBehaviour
                 break;
             case ConductSkills.Barrier:
                 ConductManager.Barrier barrier = conductManager.barrier;
-                Photosphere photosphere;
-                if (this.photosphere)
-                {
-                    obj = this.photosphere.gameObject;
-                    photosphere = this.photosphere;
-                }
-                else
-                {
-                    obj = PoolManager.Instantiate(barrier.obj);
-                    obj.transform.parent = transform;
-                    photosphere = obj.GetComponent<Photosphere>();
-                    this.photosphere = photosphere;
-                }
+                obj = PoolManager.Instantiate(barrier.obj);
+                obj.transform.parent = transform;
+                Photosphere photosphere = obj.GetComponent<Photosphere>();
                 obj.transform.position = transform.position + Vector3.up;
                 tagAdd += barrier.effectBonus[demonicRarity] * myTreasureTag[(int)barrier.attributeTag - 1] / 100;
                 photosphere.hp = Mathf.RoundToInt((prefabDemonic.totalHp + soldierExtraBuff.hp + gameManager.totalHp)*dienum * barrier.power[demonicRarity] * tagAdd);
                 photosphere.conductController = this;
+                photosphere.id = photospheres.Count;
+                photospheres.Add(photosphere);
                 break;
             case ConductSkills.SpiritBloodAggregator:
                 ConductManager.SpiritBloodAggregator spiritBloodAggregator = conductManager.spiritBloodAggregator;

+ 5 - 3
ActionTowerDefense/Assets/Scripts/Conduct/Photosphere.cs

@@ -12,14 +12,16 @@ public class Photosphere : MonoBehaviour
     [ShowIf("haveStayTime")][LabelText("停留时间")]public float stayTime;
     [LabelText("破碎特效")]public GameObject breakEffect;
     private float time;
-    [Header("吸收伤害")]public int hp;
+    public int hp;
+    public int id;
     public GameObject bulletPrefab;
     [Header("反伤率")] public float rate;
+    
     private void Update()
     {
         if (hp <= 0)
         {
-            conductController.photosphere = null;
+            conductController.photospheres.Remove(this);
             Transform trans = PoolManager.Instantiate(breakEffect).transform;
             trans.position = transform.position;
             gameObject.SetActive(false);
@@ -29,7 +31,7 @@ public class Photosphere : MonoBehaviour
             time += Time.deltaTime;
             if (time >= stayTime)
             {
-                conductController.photosphere = null;
+                conductController.photospheres.Remove(this);
                 gameObject.SetActive(false);
             }
         }

+ 7 - 3
ActionTowerDefense/Assets/Scripts/Conduct/TornadoFan.cs

@@ -64,9 +64,12 @@ public class TornadoFan : AttackTrigger
                     else
                     {
                         moveCharacter.ChangeState(CharacterState.Idle);
-                        bool canfly = moveCharacter.canFly;
-                        moveCharacter.rb.useGravity = !canfly;
-                        moveCharacter.nowCanFly = canfly;
+                        if (!moveCharacter.canFly)
+                        {
+                            moveCharacter.rb.useGravity = true;
+                            moveCharacter.nowCanFly =false;
+                            moveCharacter.rb.constraints = RigidbodyConstraints.FreezePositionY|RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
+                        }
                     }
 
                 }
@@ -105,6 +108,7 @@ public class TornadoFan : AttackTrigger
                     {
                         moveCharacter.rb.useGravity = false;
                         moveCharacter.nowCanFly = true;
+                        moveCharacter.rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
                     }
                 }