Ver Fonte

离卦牺牲的胖子掉落魂

LAPTOP-OM1V99U2\永远de小亡灵 há 1 ano atrás
pai
commit
66dd3dfabe
1 ficheiros alterados com 32 adições e 0 exclusões
  1. 32 0
      ActionTowerDefense/Assets/Scripts/Demonic.cs

+ 32 - 0
ActionTowerDefense/Assets/Scripts/Demonic.cs

@@ -34,6 +34,11 @@ public class Demonic : MoveCharacter
     private float adsorbTime;                           //八卦吸附中的时间
     public GameObject effectPrefab;                     //八卦卦象效果
 
+    [Header("掉落魂")]
+    public int dropSoulMax = 3;
+    public int dropSoulMin = 1;
+    public float dropSoulAngle = 60f;
+
     private void Awake()
     {
     }
@@ -671,6 +676,7 @@ public class Demonic : MoveCharacter
                 rb.velocity = Vector3.zero;
                 ani.Play("idle", 0, 0);
                 aniCollider.Play("Idle", 0, 0);
+                DropSouls();
                 break;
             default:
                 break;
@@ -712,4 +718,30 @@ public class Demonic : MoveCharacter
         base.Attack2();
         attackTarget = targetCharacter;
     }
+
+
+    public void DropSouls()
+    {
+        int dropSoulNum = Random.Range(dropSoulMin, dropSoulMax + 1);
+        if (dropSoulNum > 1)
+        {
+            for (int i = 0; i < dropSoulNum; i++)
+            {
+                float angleInterval = dropSoulAngle / (float)(dropSoulNum - 1);
+                float angle = 90 + ((float)i - (float)(dropSoulNum - 1) / 2) * angleInterval;
+                angle = angle / 180 * Mathf.PI;
+                GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
+                Vector3 dir = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0);
+                Soul soul = soulObj.GetComponent<Soul>();
+                soul.Burst(dir * soulStartSpeed);
+            }
+        }
+        else
+        {
+            GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
+            Vector3 dir = Vector3.up;
+            Soul soul = soulObj.GetComponent<Soul>();
+            soul.Burst(dir * soulStartSpeed);
+        }
+    }
 }