# 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](https://heroicsolo.gitbook.io/heroic-engine/basics/publish-your-docs/ui-systems/ui-controller) 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:

```csharp
[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:

<figure><img src="https://1131436974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9rEHd0nHFvWCSkMEfAjl%2Fuploads%2F8BRKn7CKHqfQEU0ZFW8Q%2Fimage.png?alt=media&#x26;token=cf373d4e-8eef-4792-9d5f-2af303633c49" alt=""><figcaption><p>Countdown sounds assignment</p></figcaption></figure>

***

### Available methods

```csharp
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):*

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

***

```csharp
void CancelCountdown()
```

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