A handy countdown class providing a lot of convenience methods.
More...
|
| Countdown (bool loop) |
| Creates a new countdown with no TotalTime duration set yet. - Parameters
-
loop | Should the countdown loop automatically? |
More...
|
|
| Countdown (bool loop, float startDuration) |
| Creates a new countdown, starting at startDuration. More...
|
|
| Countdown (bool loop, Func< float > calculateDurationDelegate, float? startDuration=null) |
| Creates a new countdown with a delegate specifying how long it should take. More...
|
|
bool | Progress (float? deltaTime=null) |
| Progresses the countdown by deltaTime (or Time.deltaTime). Returns true if the countdown it reached zero this frame. If the countdown is already at zero when this is called and Loop is true, it is restarted automatically. More...
|
|
void | Reset () |
| Resets the countdown to TotalTime. If a CalculateDurationDelegate is supplied, a new TotalTime is picked first. More...
|
|
void | Reset (float timeLeft) |
| Sets the Duration and the TimeLeft. More...
|
|
void | Refill () |
| Loops the countdown by adding TotalTime to TimeLeft. This should only be called when TimeLeft is already zero or less. If a CalculateDurationDelegate is supplied, a new TotalTime is picked first. More...
|
|
void | Refill (float newTotalTimeLeft) |
| Loops the countdown by settings TotalTime to newTotalTimeLeft and then adds it to TimeLeft. More...
|
|
|
float | TimeLeft [get, set] |
| The time left at the current countdown. More...
|
|
float | Duration [get] |
| The initial duration set. More...
|
|
Func< float > | CalculateDurationDelegate [get, set] |
| A delegate for automatically providing a new duration when the time left runs out. More...
|
|
bool | Loop [get, set] |
| Should the countdown automatically loop when it reaches zero? More...
|
|
bool | ReachedZero [get] |
| Returns true when the countdown reached zero (or less). More...
|
|
bool | IsRunning [get] |
| Returns true if the countdown is currently over zero. More...
|
|
float | TimePassed [get] |
| Returns the time passed for this countdown: (TotalTime-TimeLeft). More...
|
|
float | PercentElapsed [get] |
| Returns 0 when the countdown is just starting and 1 when it is elapsed. If TotalTime is 0, this returns 1. More...
|
|
float | PercentLeft [get] |
| Returns 1 when the countdown is just starting and 0 when it is elapsed. If TotalTime is 0, this returns 0. More...
|
|
A handy countdown class providing a lot of convenience methods.
§ Countdown() [1/3]
UnityUtilities.Countdown.Countdown |
( |
bool |
loop | ) |
|
Creates a new countdown with no TotalTime duration set yet.
- Parameters
-
loop | Should the countdown loop automatically? |
§ Countdown() [2/3]
UnityUtilities.Countdown.Countdown |
( |
bool |
loop, |
|
|
float |
startDuration |
|
) |
| |
Creates a new countdown, starting at startDuration.
- Parameters
-
loop | Should the countdown loop automatically? |
startDuration | The starting time to count down from. |
§ Countdown() [3/3]
UnityUtilities.Countdown.Countdown |
( |
bool |
loop, |
|
|
Func< float > |
calculateDurationDelegate, |
|
|
float? |
startDuration = null |
|
) |
| |
Creates a new countdown with a delegate specifying how long it should take.
- Parameters
-
loop | Should the countdown loop automatically? |
calculateDurationDelegate | A delegate providing the value to count down from. |
startDuration | Optional: A one-time starting duration. Afterwards the calculateDurationDelegate is used. |
§ Progress()
bool UnityUtilities.Countdown.Progress |
( |
float? |
deltaTime = null | ) |
|
Progresses the countdown by deltaTime (or Time.deltaTime). Returns true if the countdown it reached zero this frame. If the countdown is already at zero when this is called and Loop is true, it is restarted automatically.
- Parameters
-
deltaTime | Optional: A deltaTime to use instead of Time.deltaTime. |
- Returns
- True if the countdown reached zero this frame. False if it is still going or was already zero and isn't looping.
§ Refill() [1/2]
void UnityUtilities.Countdown.Refill |
( |
| ) |
|
Loops the countdown by adding TotalTime to TimeLeft. This should only be called when TimeLeft is already zero or less. If a CalculateDurationDelegate is supplied, a new TotalTime is picked first.
The difference between Reset() and Loop() is that Loop() factors in when TimeLeft is already less than zero and subtracts it from the TotalTime.
§ Refill() [2/2]
void UnityUtilities.Countdown.Refill |
( |
float |
newTotalTimeLeft | ) |
|
Loops the countdown by settings TotalTime to newTotalTimeLeft and then adds it to TimeLeft.
The difference between Reset() and Loop() is that Loop() factors in when TimeLeft is already less than zero and subtracts it from the TotalTime.
- Parameters
-
newTotalTimeLeft | The time to set TotalTime to and to add to TimeLeft. |
§ Reset() [1/2]
void UnityUtilities.Countdown.Reset |
( |
| ) |
|
§ Reset() [2/2]
void UnityUtilities.Countdown.Reset |
( |
float |
timeLeft | ) |
|
Sets the Duration and the TimeLeft.
- Parameters
-
timeLeft | The time to set TotalTime and TimeLeft to. |
§ CalculateDurationDelegate
Func<float> UnityUtilities.Countdown.CalculateDurationDelegate |
|
getset |
A delegate for automatically providing a new duration when the time left runs out.
§ Duration
float UnityUtilities.Countdown.Duration |
|
get |
The initial duration set.
§ IsRunning
bool UnityUtilities.Countdown.IsRunning |
|
get |
Returns true if the countdown is currently over zero.
§ Loop
bool UnityUtilities.Countdown.Loop |
|
getset |
Should the countdown automatically loop when it reaches zero?
§ PercentElapsed
float UnityUtilities.Countdown.PercentElapsed |
|
get |
Returns 0 when the countdown is just starting and 1 when it is elapsed. If TotalTime is 0, this returns 1.
§ PercentLeft
float UnityUtilities.Countdown.PercentLeft |
|
get |
Returns 1 when the countdown is just starting and 0 when it is elapsed. If TotalTime is 0, this returns 0.
§ ReachedZero
bool UnityUtilities.Countdown.ReachedZero |
|
get |
Returns true when the countdown reached zero (or less).
§ TimeLeft
float UnityUtilities.Countdown.TimeLeft |
|
getset |
The time left at the current countdown.
§ TimePassed
float UnityUtilities.Countdown.TimePassed |
|
get |
Returns the time passed for this countdown: (TotalTime-TimeLeft).
The documentation for this class was generated from the following file: