Ejemplo n.º 1
0
    private IEnumerator Countdown()
    {
        startWaitingTimeCounter = gameStartWaitingTime;
        Text t = countdown.GetComponent <Text>();

        t.color = new Color(t.color.r, t.color.g, t.color.b, 1);
        countdown.SetActive(true);

        while (startWaitingTimeCounter > 0)
        {
            // Change countdown text
            t.text = startWaitingTimeCounter.ToString();

            // Play countdown sound
            countdownSound.Play();

            yield return(new WaitForSeconds(1));

            startWaitingTimeCounter--;

            // When countdown over
            if (startWaitingTimeCounter <= 0)
            {
                // Player start moving
                player.stopMoving = false;

                // Start all Coroutines
                moonController.StartCounter();
                buffGenerator.StartCounter();

                // Fade out GO
                t.text = "GO";
                StartCoroutine("FadeOutText");

                // Play countdown end sound
                countdownEndSound.Play();

                // Play BGM
                bgm.Play();
                StartCoroutine("FadeInBGM");
            }
        }
    }