From 23ef235a263191230031dfaa02c054197fdddd91 Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Tue, 20 Oct 2020 14:08:19 +0800
Subject: [PATCH] 完善PVE界面逻辑,使用正式的界面资源 解决bug:1.打掉小怪没有获得金币 2.摧毁塔位 塔没有消失

---
 Assets/Scripts/TowerDefense/Economy/LootDrop.cs |  165 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 86 insertions(+), 79 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Economy/LootDrop.cs b/Assets/Scripts/TowerDefense/Economy/LootDrop.cs
index 237707e..aa6b1b9 100644
--- a/Assets/Scripts/TowerDefense/Economy/LootDrop.cs
+++ b/Assets/Scripts/TowerDefense/Economy/LootDrop.cs
@@ -5,87 +5,94 @@
 
 namespace TowerDefense.Economy
 {
-	/// <summary>
-	/// A class that adds money to the currency when the attached DamagableBehaviour dies
-	/// 每一个Agent都会有一个LootDrop类,对应的DamageableBehaviour分别派生自:
-	/// Agent--Targetable--DamageableBehaviour
-	/// </summary>
-	[RequireComponent(typeof(DamageableBehaviour))]
-	public class LootDrop : MonoBehaviour
-	{
-		/// <summary>
-		/// The amount of loot/currency dropped when object "dies"
-		/// </summary>
-		public int lootDropped = 1;
+    /// <summary>
+    /// A class that adds money to the currency when the attached DamagableBehaviour dies
+    /// 每一个Agent都会有一个LootDrop类,对应的DamageableBehaviour分别派生自:
+    /// Agent--Targetable--DamageableBehaviour
+    /// </summary>
+    [RequireComponent(typeof(DamageableBehaviour))]
+    public class LootDrop : MonoBehaviour
+    {
+        /// <summary>
+        /// The amount of loot/currency dropped when object "dies"
+        /// </summary>
+        public int lootDropped = 1;
 
-		/// <summary>
-		/// The attached DamagableBehaviour
-		/// </summary>
-		protected DamageableBehaviour m_DamageableBehaviour;
+        /// <summary>
+        /// The attached DamagableBehaviour
+        /// </summary>
+        protected DamageableBehaviour m_DamageableBehaviour;
 
-		/// <summary>
-		/// Caches attached DamageableBehaviour
-		/// </summary>
-		protected virtual void OnEnable()
-		{
-			if (m_DamageableBehaviour == null)
-			{
-				m_DamageableBehaviour = GetComponent<DamageableBehaviour>();
-			}
-			m_DamageableBehaviour.configuration.died += OnDeath;
-		}
-
-		/// <summary>
-		/// Unsubscribed from the <see cref="m_DamageableBehaviour"/> died event
-		/// </summary>
-		protected virtual void OnDisable()
-		{
-			m_DamageableBehaviour.configuration.died -= OnDeath;
-		}
-
-		/// <summary>
-		/// The callback for when the attached object "dies".
-		/// Add <see cref="lootDropped"/> to current currency
-		/// </summary>
-		protected virtual void OnDeath(HealthChangeInfo info)
-		{
-			m_DamageableBehaviour.configuration.died -= OnDeath;
-
-			// 
-			// 当前LootDrop所在的Agent死亡后,给全局的CurrencyManager增加金币.
-			// 当前Agent死亡之后,需要在对手盘加入新的Agent
-			LevelManager levelManager = LevelManager.instance;
-			OpponentMgr opmgr = OpponentMgr.instance;
-			if (levelManager == null)
-				return;
-			Agent agent = gameObject.GetComponent<Agent>();
-			if( (agent!=null) && agent.opponentAgent)
-            {				
-				if (opmgr == null)
-				{
-					return;
-				}
-				opmgr.currency.AddCurrency(lootDropped);
-				/* 修改为不再死亡后发布怪物到对方视野.
-				if( agent.bRespawn)
-                {
-					AgentSetData sd = agent.mAgentData;
-					int attid = OpponentMgr.instance.GetTowerAttID(agent.waveLineID);
-					levelManager.waveManager.SpawnAgent(agent.waveLineID,sd.hp,sd.speed, attid );
-				}*/
-            }
-            else
+        /// <summary>
+        /// Caches attached DamageableBehaviour
+        /// </summary>
+        protected virtual void OnEnable()
+        {
+            if (m_DamageableBehaviour == null)
             {
-				levelManager.currency.AddCurrency(lootDropped);
-				/*
-				if (agent.bRespawn)
-                {
-					AgentSetData sd = agent.mAgentData;
-					int attid = levelManager.GetTowerAttID(agent.waveLineID);
-					opmgr.m_WaveManager.SpawnAgent(agent.waveLineID, sd.hp,sd.speed, attid );
-				}*/
-			}
+                m_DamageableBehaviour = GetComponent<DamageableBehaviour>();
+            }
+            m_DamageableBehaviour.configuration.died += OnDeath;
+        }
 
-		}
-	}
+        /// <summary>
+        /// Unsubscribed from the <see cref="m_DamageableBehaviour"/> died event
+        /// </summary>
+        protected virtual void OnDisable()
+        {
+            m_DamageableBehaviour.configuration.died -= OnDeath;
+        }
+
+        /// <summary>
+        /// The callback for when the attached object "dies".
+        /// Add <see cref="lootDropped"/> to current currency
+        /// </summary>
+        protected virtual void OnDeath(HealthChangeInfo info)
+        {
+            m_DamageableBehaviour.configuration.died -= OnDeath;
+
+            if (LevelManager.instanceExists)
+            {
+                // 当前LootDrop所在的Agent死亡后,给全局的CurrencyManager增加金币.
+                // 当前Agent死亡之后,需要在对手盘加入新的Agent
+                LevelManager levelManager = LevelManager.instance;
+                OpponentMgr opmgr = OpponentMgr.instance;
+                if (levelManager == null)
+                    return;
+                Agent agent = gameObject.GetComponent<Agent>();
+                if ((agent != null) && agent.opponentAgent)
+                {
+                    if (opmgr == null)
+                    {
+                        return;
+                    }
+                    opmgr.currency.AddCurrency(lootDropped);
+                    /* 修改为不再死亡后发布怪物到对方视野.
+                    if( agent.bRespawn)
+                    {
+                        AgentSetData sd = agent.mAgentData;
+                        int attid = OpponentMgr.instance.GetTowerAttID(agent.waveLineID);
+                        levelManager.waveManager.SpawnAgent(agent.waveLineID,sd.hp,sd.speed, attid );
+                    }*/
+                }
+                else
+                {
+                    levelManager.currency.AddCurrency(lootDropped);
+                    /*
+                    if (agent.bRespawn)
+                    {
+                        AgentSetData sd = agent.mAgentData;
+                        int attid = levelManager.GetTowerAttID(agent.waveLineID);
+                        opmgr.m_WaveManager.SpawnAgent(agent.waveLineID, sd.hp,sd.speed, attid );
+                    }*/
+                }
+            }
+            else if (EndlessLevelManager.instanceExists)
+            {
+                Agent agent = gameObject.GetComponent<Agent>();
+                if (agent != null)
+                    EndlessLevelManager.instance.Currency.AddCurrency(lootDropped);
+            }
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1