瀏覽代碼

修复只掉一个魂会报错的问题

WGL 2 月之前
父節點
當前提交
86a646b2fb
共有 1 個文件被更改,包括 12 次插入8 次删除
  1. 12 8
      ActionTowerDefense/Assets/Scripts/Characters/Enemy.cs

+ 12 - 8
ActionTowerDefense/Assets/Scripts/Characters/Enemy.cs

@@ -619,7 +619,7 @@ public class Enemy : MoveCharacter
     public void DropSouls()
     {
         int dropSoulNum = Random.Range(dropSoulMin, dropSoulMax + 1);
-        if (dropSoulNum >= 1)
+        if (dropSoulNum > 1)
         {
             for (int i = 0; i < dropSoulNum; i++)
             {
@@ -635,15 +635,19 @@ public class Enemy : MoveCharacter
         }
         else
         {
-            int randomInt = Random.Range(0, 100);
-            if (randomInt < dropProbability)
+            if(dropSoulNum == 0)
             {
-                GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
-                Vector3 dir = Vector3.up;
-                Soul soul = soulObj.GetComponent<Soul>();
-                soul.Burst(dir * soulStartSpeed);
-                soul.type = type;
+                int randomInt = Random.Range(0, 100);
+                if(randomInt >= dropProbability)
+                {
+                    return;
+                }
             }
+            GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
+            Vector3 dir = Vector3.up;
+            Soul soul = soulObj.GetComponent<Soul>();
+            soul.Burst(dir * soulStartSpeed);
+            soul.type = type;
         }
     }