Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CooldownManager
- {
- public float tempsCooldown;
- float tempsEcoule;
- public CooldownManager(float temps)
- {
- tempsCooldown = temps;
- }
- public bool IsReady()
- {
- if (tempsEcoule > tempsCooldown)
- {
- tempsEcoule = 0f;
- return true;
- }
- else
- return false;
- }
- public void Update(float deltaTime)
- {
- tempsEcoule += deltaTime;
- }
- }
- // DANS LE CONTROLLER DU PERSONNAGE
- // Pour gérer le cooldown du dash pour ce personnage
- CooldownManager cooldownDash;
- void Start()
- {
- // On donne la valeur du cooldown
- cooldownDash = new CooldownManager(0.5f); // 500 millisecondes
- }
- void Update()
- {
- cooldownDash.Update(Time.deltaTime);
- }
- void ActionClicGauche()
- { // par exemple
- if (cooldownDash.IsReady())
- {
- // On dash
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment