From ce7efae14eb31bcdfa0d540da6a1ef1457e046ab Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Wed, 04 Nov 2020 21:27:39 +0800
Subject: [PATCH] Merge commit '80b4237334a773b29bf69f38532a90ca659b3bfe' into master

---
 Assets/Scripts/Core/Utilities/Timer.cs |  181 ++++++++++++++++++++++----------------------
 1 files changed, 91 insertions(+), 90 deletions(-)

diff --git a/Assets/Scripts/Core/Utilities/Timer.cs b/Assets/Scripts/Core/Utilities/Timer.cs
index b64d148..b0a6eb9 100644
--- a/Assets/Scripts/Core/Utilities/Timer.cs
+++ b/Assets/Scripts/Core/Utilities/Timer.cs
@@ -4,115 +4,116 @@
 
 namespace Core.Utilities
 {
-	/// <summary>
-	/// A timer data model. Consumed/process by the TimedBehaviour
-	/// 塔防游戏的基础Timer包装类,设置一个time时间后要引发的操作,然后每一轮Tick这个Timer,触发后Tick返回true
-	/// 由调用层进行相应的操作。
-	/// </summary>
-	public class Timer
-	{
-		/// <summary>
-		/// Event fired on elapsing
-		/// </summary>
-		readonly Action m_Callback;
+    /// <summary>
+    /// A timer data model. Consumed/process by the TimedBehaviour
+    /// 塔防游戏的基础Timer包装类,设置一个time时间后要引发的操作,然后每一轮Tick这个Timer,触发后Tick返回true
+    /// 由调用层进行相应的操作。
+    /// </summary>
+    public class Timer
+    {
+        /// <summary>
+        /// Event fired on elapsing
+        /// </summary>
+        readonly Action m_Callback;
 
-		/// <summary>
-		/// The time
-		/// </summary>
-		float m_Time, m_CurrentTime;
+        /// <summary>
+        /// The time
+        /// </summary>
+        float m_Time, m_CurrentTime;
 
-		protected static int TIMER_IDSTART = 0;
+        protected static int TIMER_IDSTART = 0;
 
-		protected int mTimerID = 0;
+        protected int mTimerID = 0;
 
-		/// <summary>
-		/// Normalized progress of the timer
-		/// </summary>
-		public float normalizedProgress
-		{
-			get { return Mathf.Clamp(m_CurrentTime / m_Time, 0f, 1f); }
-		}
+        /// <summary>
+        /// Normalized progress of the timer
+        /// </summary>
+        public float normalizedProgress
+        {
+            get { return Mathf.Clamp(m_CurrentTime / m_Time, 0f, 1f); }
+        }
 
-		public float currentTime
+        public float currentTime
         {
             get { return this.m_CurrentTime; }
         }
 
-		public int timerID
+        public int timerID
         {
-			get { return this.mTimerID; }
+            get { return this.mTimerID; }
         }
 
-		/// <summary>
-		/// Timer constructor
-		/// </summary>
-		/// <param name="newTime">the time that timer is counting</param>
-		/// <param name="onElapsed">the event fired at the end of the timer elapsing</param>
-		public Timer(float newTime, Action onElapsed = null)
-		{
-			SetTime(newTime);
+        /// <summary>
+        /// Timer constructor
+        /// </summary>
+        /// <param name="newTime">the time that timer is counting</param>
+        /// <param name="onElapsed">the event fired at the end of the timer elapsing</param>
+        public Timer(float newTime, Action onElapsed = null)
+        {
+            SetTime(newTime);
 
-			m_CurrentTime = 0f;
-			m_Callback += onElapsed;
+            m_CurrentTime = 0f;
+            m_Callback += onElapsed;
 
-			mTimerID = TIMER_IDSTART++;
-		}
+            mTimerID = TIMER_IDSTART++;
+        }
 
-		/// <summary>
-		/// Returns the result of AssessTime
-		/// </summary>
-		/// <param name="deltaTime">change in time between ticks</param>
-		/// <returns>true if the timer has elapsed, false otherwise</returns>
-		public virtual bool Tick(float deltaTime)
-		{
-			return AssessTime(deltaTime);
-		}
+        /// <summary>
+        /// Returns the result of AssessTime
+        /// </summary>
+        /// <param name="deltaTime">change in time between ticks</param>
+        /// <returns>true if the timer has elapsed, false otherwise</returns>
+        public virtual bool Tick(float deltaTime)
+        {
+            return AssessTime(deltaTime);
+        }
 
-		/// <summary>
-		/// Checks if the time has elapsed and fires the tick event 
-		/// </summary>
-		/// <param name="deltaTime">the change in time between assessments</param>
-		/// <returns>true if the timer has elapsed, false otherwise</returns>
-		protected bool AssessTime(float deltaTime)
-		{
-			m_CurrentTime += deltaTime;
-			if (m_CurrentTime >= m_Time)
-			{
-				FireEvent();
-				return true;
-			}
+        /// <summary>
+        /// Checks if the time has elapsed and fires the tick event 
+        /// </summary>
+        /// <param name="deltaTime">the change in time between assessments</param>
+        /// <returns>true if the timer has elapsed, false otherwise</returns>
+        protected bool AssessTime(float deltaTime)
+        {
+            m_CurrentTime += deltaTime;
+            if (m_CurrentTime >= m_Time)
+            {
+                FireEvent();
+                return true;
+            }
 
-			return false;
-		}
+            return false;
+        }
 
-		/// <summary>
-		/// Resets the current time to 0
-		/// </summary>
-		public void Reset()
-		{
-			m_CurrentTime = 0;
-		}
+        /// <summary>
+        /// Resets the current time to 0
+        /// </summary>
+        public void Reset()
+        {
+            m_CurrentTime = 0;
+        }
 
-		/// <summary>
-		/// Fires the associated timer event
-		/// </summary>
-		public void FireEvent()
-		{
-			m_Callback.Invoke();
-		}
+        /// <summary>
+        /// Fires the associated timer event
+        /// </summary>
+        public void FireEvent()
+        {
+            if (m_Callback != null)
+                m_Callback.Invoke();
+        }
 
-		/// <summary>
-		/// Sets the elapsed time
-		/// </summary>
-		/// <param name="newTime">sets the time to a new value</param>
-		public void SetTime(float newTime)
-		{
-			m_Time = newTime;
+        /// <summary>
+        /// Sets the elapsed time
+        /// </summary>
+        /// <param name="newTime">sets the time to a new value</param>
+        public void SetTime(float newTime)
+        {
+            m_Time = newTime;
 
-			if (newTime <= 0)
-			{
-				m_Time = 0.1f;
-			}
-		}
-	}
+            if (newTime <= 0)
+            {
+                m_Time = 0.1f;
+            }
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1