diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs')
-rw-r--r-- | Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs b/Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs new file mode 100644 index 00000000..1208b5f6 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs @@ -0,0 +1,59 @@ +using System;
+using UnityEngine;
+
+namespace XUtliPoolLib
+{
+ public class XElapseTimer
+ {
+ public float LeftTime
+ {
+ get
+ {
+ return this.m_LeftTime;
+ }
+ set
+ {
+ this.m_LeftTime = value;
+ this.m_OriLeftTime = this.m_LeftTime;
+ this.m_LastTime = -1f;
+ this.m_PassTime = 0f;
+ }
+ }
+
+ public float PassTime
+ {
+ get
+ {
+ return this.m_PassTime;
+ }
+ }
+
+ private float m_OriLeftTime = 0f;
+
+ private float m_LeftTime = 0f;
+
+ private float m_LastTime = -1f;
+
+ private float m_PassTime = 0f;
+
+ public void Update()
+ {
+ this.m_PassTime = 0f;
+ bool flag = this.m_LastTime < 0f;
+ if (flag)
+ {
+ this.m_LastTime = Time.time;
+ }
+ else
+ {
+ this.m_PassTime = Time.time - this.m_LastTime;
+ }
+ this.m_LeftTime = this.m_OriLeftTime - this.m_PassTime;
+ bool flag2 = this.m_LeftTime < 0f;
+ if (flag2)
+ {
+ this.m_LeftTime = 0f;
+ }
+ }
+ }
+}
|