summaryrefslogtreecommitdiff
path: root/SurvivalTest/Assets/Scripts/Utils/TinyCountDown.cs
diff options
context:
space:
mode:
Diffstat (limited to 'SurvivalTest/Assets/Scripts/Utils/TinyCountDown.cs')
-rw-r--r--SurvivalTest/Assets/Scripts/Utils/TinyCountDown.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/SurvivalTest/Assets/Scripts/Utils/TinyCountDown.cs b/SurvivalTest/Assets/Scripts/Utils/TinyCountDown.cs
new file mode 100644
index 0000000..dbeae55
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Utils/TinyCountDown.cs
@@ -0,0 +1,48 @@
+using System.Linq;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class TinyCountDown :Singleton<TinyCountDown>
+{
+
+ private Dictionary<string, float> m_CountDown = new Dictionary<string, float>();
+ public TinyCountDown()
+ {
+ }
+
+ public void Set(string key, float time)
+ {
+ if (!m_CountDown.ContainsKey(key))
+ {
+ m_CountDown.Add(key, time);
+ }
+ else
+ {
+ m_CountDown[key] = time;
+ }
+ }
+
+ public float Get(string key)
+ {
+ if (m_CountDown.ContainsKey(key))
+ {
+ return m_CountDown[key];
+ }
+ return 0;
+ }
+
+ public void Update()
+ {
+ List<string> keys = new List<string>(m_CountDown.Keys);
+ foreach (var key in keys)
+ {
+ m_CountDown[key] -= Time.deltaTime;
+ if(m_CountDown[key] <= 0)
+ {
+ m_CountDown.Remove(key);
+ }
+ }
+
+ }
+}