Countdown Controller

Presented by ICountdownController interface, this system allows to start countdown with needed time length, invoke certain action each tick and in the end of such countdown. It will also show descending numbers via IUIController in the center of screen and play tick sounds if they were assigned.

To use this system, inject ICountdownController interface into your class, as shown below:

[Inject] private ICountdownController countdownController;

Parameters in inspector

countdownSounds – you can assign your custom sounds for countdown ticks (starting from 1st, ending by Nth tick, so 0th element in this list will be the last sound before the end of countdown)

It should be like this:

Countdown sounds assignment

Available methods

void StartCountdown(float seconds, Action tickCallback, Action endCallback, Action cancelCallback = null)

This method starts cooldown with certain length in seconds, it calls tickCallback every tick, endCallback in the end of countdown and cancelCallback in case if countdown is cancelled.

Example (from DuelPlayerController.cs):

private void StartGame()
{
    countdownController.StartCountdown(3, null, ShowSkills, ShowSkills);
}

void CancelCountdown()

This method cancels current countdown and instantly calls cancel callback if it was assigned beforehand by StartCountdown method.

Last updated