diff options
Diffstat (limited to 'GameCode/CooldownCondition.cs')
-rw-r--r-- | GameCode/CooldownCondition.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/GameCode/CooldownCondition.cs b/GameCode/CooldownCondition.cs new file mode 100644 index 0000000..51bbbf6 --- /dev/null +++ b/GameCode/CooldownCondition.cs @@ -0,0 +1,20 @@ +using UnityEngine; +using UnityEngine.Events; + +public class CooldownCondition : MonoBehaviour +{ + public UnityEvent triggerEvent; + + public float cooldown = 0.25f; + + private float lastTime = -100f; + + public void TryEvent() + { + if (!(Time.time < lastTime + cooldown)) + { + lastTime = Time.time; + triggerEvent.Invoke(); + } + } +} |