Пример #1
0
    /*Countdown Cherry Bomb UI by calling CherryTimer
     * Countdown for number timer
     * Resets after each round by calling CHerryTimer Reset
     */
    public IEnumerator StartCountdown()
    {
        timeLeft++;
        numTime.text    = "10";
        numTime.enabled = true;
        while (timeLeft > 1)
        {
            yield return(new WaitForSeconds(1.0f));

            timeLeft--;
            CherryTimer();
            numTime.text = (timeLeft - 1).ToString();
            if (numTime.text == "0")
            {
                numTime.enabled = false;
            }
        }

        Explode();
        //Wait time (can be changed if you want) to show scores etc then resets
        yield return(new WaitForSeconds(0.8f));

        teamLeft = 0;
        mtc.setState(2);
        round++;
        UpdateTeamMembers();
        UpdateTeamRemain();
        yield return(new WaitForSeconds(0.8f));

        foreach (GameObject child in team)
        {
            //Debug.Log(child.transform.childCount);
            if (child.transform.childCount != 0)
            {
                teamLeft++;
                TeamController teamController = child.GetComponent <TeamController>();
                teamController.DestroyAllChildren();
            }
        }
        yield return(new WaitForSeconds(0.8f));

        UpdateLeader();
        timeLeft = 10;
        CherryTimerReset();
        if (teamLeft <= 3)
        {
            SceneManager.LoadScene(thisScene);
        }
        else
        {
            InitialGame();
        }

        StartCoroutine(StartCountdown());
    }