Browse Source

敌方英灵死亡掉落的紫魂在一定范围内随机

LAPTOP-OM1V99U2\永远de小亡灵 1 year ago
parent
commit
c7c25dd40f

+ 1 - 2
ActionTowerDefense/Assets/Resources/Prefab/Boss/YuMenGuan/Block/Block.prefab

@@ -255,8 +255,7 @@ MonoBehaviour:
   shootTrack: 0
   attack1Infos: []
   attack2Infos: []
-  attackTriggers:
-  - {fileID: 0}
+  attackTriggers: []
   targetTypes: 030000000200000001000000
   targetCharacter: {fileID: 0}
   attackTarget: {fileID: 0}

+ 7 - 5
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -51,7 +51,8 @@ public class Enemy : MoveCharacter
     public float attackRatio;
 
     [Header("µôÂä»ê")]
-    public int dropSoul = 1;
+    public int dropSoulMax = 1;
+    public int dropSoulMin = 1;
     public float dropSoulAngle = 60f;
 
     [Header("³å´Ì¹¥»÷")]
@@ -834,12 +835,13 @@ public class Enemy : MoveCharacter
 
     public void DropSouls()
     {
-        if (dropSoul > 1)
+        int dropSoulNum = Random.Range(dropSoulMin, dropSoulMax+1);
+        if (dropSoulNum > 1)
         {
-            for (int i = 0; i < dropSoul; i++)
+            for (int i = 0; i < dropSoulNum; i++)
             {
-                float angleInterval = dropSoulAngle / (float)(dropSoul - 1);
-                float angle = 90 + ((float)i - (float)(dropSoul - 1) / 2) * angleInterval;
+                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);

+ 4 - 4
ActionTowerDefense/Assets/Scripts/SoulCollector.cs

@@ -13,14 +13,14 @@ public class SoulCollector : MonoBehaviour
 
     private void OnTriggerEnter(Collider other)
     {
-        if (player == null)
-        {
-            player = GetComponentInParent<PlayerController>();
-        }
         Soul soul = other.GetComponentInParent<Soul>();
         if (soul)
         {
             other.GetComponent<BoxCollider>().enabled = false;
+            if (player == null)
+            {
+                player = GetComponentInParent<PlayerController>();
+            }
             soul.BeCollect(player.playerId);
         }
     }