From 8637f933a9987b4b16dd9725189a1c6ee2685118 Mon Sep 17 00:00:00 2001
From: River Jiang <546213258@qq.com>
Date: Wed, 28 Oct 2020 10:12:05 +0800
Subject: [PATCH] 提交充能条特效修改 Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master

---
 Assets/Scripts/TowerDefense/Agents/HomeBaseAttacker.cs |  254 +++++++++++++++++++++++++++-----------------------
 1 files changed, 137 insertions(+), 117 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Agents/HomeBaseAttacker.cs b/Assets/Scripts/TowerDefense/Agents/HomeBaseAttacker.cs
index 5e630fc..f425f7f 100644
--- a/Assets/Scripts/TowerDefense/Agents/HomeBaseAttacker.cs
+++ b/Assets/Scripts/TowerDefense/Agents/HomeBaseAttacker.cs
@@ -1,4 +1,5 @@
-using ActionGameFramework.Health;
+using KTGMGemClient;
+using ActionGameFramework.Health;
 using Core.Health;
 using Core.Utilities;
 using TowerDefense.Level;
@@ -8,59 +9,59 @@
 
 namespace TowerDefense.Agents
 {
-	/// <summary>
-	/// A component that attacks a home base when an agent reaches it 
-	/// </summary>
-	[RequireComponent(typeof(Agent))]
-	public class HomeBaseAttacker : MonoBehaviour 
-	{
-		/// <summary>
-		/// How long the agent charges for before it attacks
-		/// the home base
-		/// </summary>
-		public float homeBaseAttackChargeTime = 0.5f;
+    /// <summary>
+    /// A component that attacks a home base when an agent reaches it 
+    /// </summary>
+    [RequireComponent(typeof(Agent))]
+    public class HomeBaseAttacker : MonoBehaviour
+    {
+        /// <summary>
+        /// How long the agent charges for before it attacks
+        /// the home base
+        /// </summary>
+        public float homeBaseAttackChargeTime = 0.5f;
 
-		/// <summary>
-		/// Timer used to stall attack to the home base
-		/// </summary>
-		protected Timer m_HomeBaseAttackTimer;
+        /// <summary>
+        /// Timer used to stall attack to the home base
+        /// </summary>
+        protected Timer m_HomeBaseAttackTimer;
 
-		/// <summary>
-		/// If the agent has reached the Player Home Base and is charging an attack
-		/// </summary>
-		protected bool m_IsChargingHomeBaseAttack;
-		
-		/// <summary>
-		/// The DamageableBehaviour on the home base 
-		/// </summary>
-		protected DamageableBehaviour m_FinalDestinationDamageableBehaviour;
+        /// <summary>
+        /// If the agent has reached the Player Home Base and is charging an attack
+        /// </summary>
+        protected bool m_IsChargingHomeBaseAttack;
 
-		/// <summary>
-		/// The agent component attached to this gameObject
-		/// </summary>
-		public Agent agent { get; protected set; }
+        /// <summary>
+        /// The DamageableBehaviour on the home base 
+        /// </summary>
+        protected DamageableBehaviour m_FinalDestinationDamageableBehaviour;
 
-		/// <summary>
-		/// Fired on completion of <see cref="m_HomeBaseAttackTimer"/>
-		/// Applies damage to the homebase
-		/// </summary>
-		protected void AttackHomeBase()
-		{
-			m_IsChargingHomeBaseAttack = false;
-			var damager = GetComponent<Damager>();
-			if (damager != null)
-			{
-				m_FinalDestinationDamageableBehaviour.TakeDamage(damager.finalDamage, transform.position, agent.configuration.alignmentProvider);
+        /// <summary>
+        /// The agent component attached to this gameObject
+        /// </summary>
+        public Agent agent { get; protected set; }
 
-				PlayerHomeBase homebase = m_FinalDestinationDamageableBehaviour.GetComponent<PlayerHomeBase>();
-				if(homebase && (!homebase.isDead) )
+        /// <summary>
+        /// Fired on completion of <see cref="m_HomeBaseAttackTimer"/>
+        /// Applies damage to the homebase
+        /// </summary>
+        protected void AttackHomeBase()
+        {
+            m_IsChargingHomeBaseAttack = false;
+            var damager = GetComponent<Damager>();
+            if (damager != null)
+            {
+                m_FinalDestinationDamageableBehaviour.TakeDamage(damager.finalDamage, transform.position, agent.configuration.alignmentProvider);
+
+                PlayerHomeBase homebase = m_FinalDestinationDamageableBehaviour.GetComponent<PlayerHomeBase>();
+                if (homebase && (!homebase.isDead))
                 {
-					// 显示塔位血条
-					float hscale = homebase.healthVal / homebase.configuration.maxHealth;
-					if ( hscale < 1.0)
+                    // 显示塔位血条
+                    float hscale = homebase.healthVal / homebase.configuration.maxHealth;
+                    if (hscale < 1.0)
                     {
-						if (homebase.opponent)
-							OpponentMgr.instance.m_CurrentArea.setTowerPosHealth(homebase.homebaseIdx, hscale);
+                        if (homebase.opponent)
+                            OpponentMgr.instance.m_CurrentArea.setTowerPosHealth(homebase.homebaseIdx, hscale);
                         else
                         {
                             if (GameUI.instanceExists)
@@ -71,81 +72,100 @@
                             else if (EndlessGameUI.instanceExists)
                             {
                                 if (EndlessGameUI.instance.selfTowerPlaceArea != null)
-                                    EndlessGameUI.instance.selfTowerPlaceArea.setTowerPosHealth(homebase.homebaseIdx, hscale);
+                                {
+                                    if (GameConfig.IsNewbie)
+                                    {
+                                        if (GameConfig.TowerFirstTakeDamage)
+                                        {
+                                            GameConfig.TowerFirstTakeDamage = false;
+                                            EndlessGameUI.instance.selfTowerPlaceArea.setTowerPosHealth(homebase.homebaseIdx, hscale);
+                                            EndlessLevelManager.instance.StopSecondWave();
+                                        }
+                                        else
+                                        {
+                                            if (GameConfig.TowerCanTakeDamage)
+                                            {
+                                                EndlessGameUI.instance.selfTowerPlaceArea.setTowerPosHealth(homebase.homebaseIdx, hscale);
+                                            }
+                                        }
+                                    }
+                                    else
+                                        EndlessGameUI.instance.selfTowerPlaceArea.setTowerPosHealth(homebase.homebaseIdx, hscale);
+                                }
                             }
-						}
-							
-					}
-				}
-			}
-			agent.Remove();
-		}
+                        }
 
-		/// <summary>
-		/// Ticks the attack timer
-		/// </summary>
-		protected virtual void Update () 
-		{
-			// Update HomeBaseAttack Timer
-			if (m_IsChargingHomeBaseAttack)
-			{
-				m_HomeBaseAttackTimer.Tick(Time.deltaTime);
-			}
-		}
+                    }
+                }
+            }
+            agent.Remove();
+        }
 
-		/// <summary>
-		/// Caches the attached Agent and subscribes to the destinationReached event
-		/// </summary>
-		protected virtual void Awake()
-		{
-			agent = GetComponent<Agent>();
-			agent.destinationReached += OnDestinationReached;
-			agent.died += OnDied;
-		}
+        /// <summary>
+        /// Ticks the attack timer
+        /// </summary>
+        protected virtual void Update()
+        {
+            // Update HomeBaseAttack Timer
+            if (m_IsChargingHomeBaseAttack)
+            {
+                m_HomeBaseAttackTimer.Tick(Time.deltaTime);
+            }
+        }
 
-		/// <summary>
-		/// Unsubscribes from the destinationReached event
-		/// </summary>
-		protected virtual void OnDestroy()
-		{
-			if (agent != null)
-			{
-				agent.destinationReached -= OnDestinationReached;
-				agent.died -= OnDied;
-			}
-		}
+        /// <summary>
+        /// Caches the attached Agent and subscribes to the destinationReached event
+        /// </summary>
+        protected virtual void Awake()
+        {
+            agent = GetComponent<Agent>();
+            agent.destinationReached += OnDestinationReached;
+            agent.died += OnDied;
+        }
 
-		/// <summary>
-		/// Stops the attack on the home base
-		/// </summary>
-		void OnDied(DamageableBehaviour damageableBehaviour)
-		{
-			m_IsChargingHomeBaseAttack = false;
-		}
+        /// <summary>
+        /// Unsubscribes from the destinationReached event
+        /// </summary>
+        protected virtual void OnDestroy()
+        {
+            if (agent != null)
+            {
+                agent.destinationReached -= OnDestinationReached;
+                agent.died -= OnDied;
+            }
+        }
 
-		/// <summary>
-		/// Fired then the agent reached its final node,
-		/// Starts the attack timer
-		/// </summary>
-		/// <param name="homeBase"></param>
-		void OnDestinationReached (Node homeBase)
-		{
-			if (agent.bInDeathState) return;
+        /// <summary>
+        /// Stops the attack on the home base
+        /// </summary>
+        void OnDied(DamageableBehaviour damageableBehaviour)
+        {
+            m_IsChargingHomeBaseAttack = false;
+        }
 
-			m_FinalDestinationDamageableBehaviour = homeBase.GetComponent<DamageableBehaviour>();
-			// start timer 
-			if (m_HomeBaseAttackTimer == null)
-			{
-				m_HomeBaseAttackTimer = new Timer(homeBaseAttackChargeTime, AttackHomeBase);
-				//Debug.Log("HomeBase Timer 设置起来...");
-				agent.PlayAttack();
-			}
-			else
-			{
-				//m_HomeBaseAttackTimer.Reset();
-				// Debug.Log("重复设置导致有可能怪物不会消失.");
-			}
-			m_IsChargingHomeBaseAttack = true;
-		}
-	}
+        /// <summary>
+        /// Fired then the agent reached its final node,
+        /// Starts the attack timer
+        /// </summary>
+        /// <param name="homeBase"></param>
+        void OnDestinationReached(Node homeBase)
+        {
+            if (agent.bInDeathState) return;
+
+            m_FinalDestinationDamageableBehaviour = homeBase.GetComponent<DamageableBehaviour>();
+            // start timer 
+            if (m_HomeBaseAttackTimer == null)
+            {
+                m_HomeBaseAttackTimer = new Timer(homeBaseAttackChargeTime, AttackHomeBase);
+                //Debug.Log("HomeBase Timer 设置起来...");
+                agent.PlayAttack();
+            }
+            else
+            {
+                //m_HomeBaseAttackTimer.Reset();
+                // Debug.Log("重复设置导致有可能怪物不会消失.");
+            }
+            m_IsChargingHomeBaseAttack = true;
+        }
+    }
 }

--
Gitblit v1.9.1