From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/XElapseTimer.cs') 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; + } + } + } +} -- cgit v1.1-26-g67d0