-
Notifications
You must be signed in to change notification settings - Fork 0
/
CountdownController.cs
38 lines (38 loc) · 1.31 KB
/
CountdownController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CountdownController : MonoBehaviour {
Text countdowntext;
public GameObject pauseButton;
void Start () {
countdowntext = GetComponent<Text> ();
countdowntext.text = "";
}
public void StartCountdown () {
StartCoroutine (Countdown ());
}
IEnumerator Countdown () {
yield return new WaitForSecondsRealtime (0.25f);
countdowntext.color = Color.white;
countdowntext.text = "3";
PlayAudio.PlaySound ("countdown");
yield return new WaitForSecondsRealtime (0.5f);
countdowntext.text = "2";
PlayAudio.PlaySound ("countdown");
yield return new WaitForSecondsRealtime (0.5f);
countdowntext.text = "1";
PlayAudio.PlaySound ("countdown");
yield return new WaitForSecondsRealtime (0.5f);
countdowntext.text = "0";
PlayAudio.PlaySound ("lastCountdown");
yield return new WaitForSecondsRealtime (0.4f);
pauseButton.SetActive (true);
gameObject.SetActive (false);
countdowntext.text = "";
AudioListener.pause = false;
Time.timeScale = 1;
yield return new WaitForSecondsRealtime (1f);
// pauseButton.SetActive (true);
}
}