SZAND\msx_2 1 год назад
Родитель
Сommit
7317dd49b4

+ 1 - 0
ActionTowerDefense/Assets/Scripts/Bullet.cs

@@ -113,6 +113,7 @@ public class Bullet : MonoBehaviour
                     }
                     if (toFloat)
                     {
+                        owner.attackToFloat = false;
                         toFloat = false;
                         hitTrigger.owner.GetComponent<MoveCharacter>().FloatStateOn();
                     }

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

@@ -104,6 +104,8 @@ public class Character : MonoBehaviour
     private Vector3 speed = new Vector3(1, 1, 0);
     public bool beLarger = false;
 
+    public bool attackToFloat = false;      //¹¥»÷ʹµÐ·½Æ¯¸¡
+
     public virtual void Init()
     {
         if (!mecanim)
@@ -199,6 +201,10 @@ public class Character : MonoBehaviour
         }
         GameObject bulletObj = PoolManager.Instantiate(bulletPrefab);
         Bullet bullet = bulletObj.GetComponent<Bullet>();
+        if (attackToFloat)
+        {
+            bullet.toFloat = true;
+        }
         Vector3 attackDir = attackInfo.attackDir.normalized;
         if (bodyTrans.localScale.x < 0)
         {

+ 16 - 7
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Float.cs

@@ -6,10 +6,12 @@ public class Trans_Float : MonoBehaviour
 {
     public PlayerController controller;
 
-    private bool isFirst;           //第一次攻击
+    private bool isFirst = true;           //第一次攻击
     private int times;              //攻击次数
     public int minTime, maxTime;   //保底范围
 
+    public bool toFloat = false;           //攻击触发漂浮
+
     private void Start()
     {
         controller = GetComponentInParent<PlayerController>();
@@ -19,19 +21,26 @@ public class Trans_Float : MonoBehaviour
     {
         if (controller.isinputJ)
         {
+            print(controller.attackToFloat);
             controller.isinputJ = false;
             if (isFirst)
             {
-                isFirst = false;
-                //触发
+                if (!controller.attackToFloat)
+                {
+                    isFirst = false;
+                    controller.attackToFloat = true;
+                }
             }
             else
             {
-                times += 1;
-                if (times >= minTime || times == maxTime)
+                if (!controller.attackToFloat)
                 {
-                    times = 0;
-                    //触发
+                    times += 1;
+                    if (times >= minTime || times == maxTime)
+                    {
+                        times = 0;
+                        controller.attackToFloat = true;
+                    }
                 }
             }
             GetComponent<Demonic>().Attack2();