コード例 #1
0
    /// <summary>
    /// Increases the score for the winner. Then determines if there is a winner of the match. If there isn't will automatically start next round.
    /// </summary>
    public IEnumerator EndRound(BoxingTeams roundWinner)
    {
        animator.Play("SongFadeOut");
        beatController.StopSong();
        foreach (UnitStatus unit in FindObjectsOfType <UnitStatus>())
        {
            unit.InitializeUnit();
        }
        scoreboardAudio.PlayOneShot(soundset.roundEnd, 1);

        //Awards score and plays animation based off of the winner.
        switch (roundWinner)
        {
        case BoxingTeams.red:
            scoreboardAnimator.Play("RedRound");
            redScore++;
            break;

        case BoxingTeams.green:
            scoreboardAnimator.Play("GreenRound");
            greenScore++;
            break;
        }

        yield return(new WaitForSeconds(1));

        scoreboard.UpdateScoreboardText();
        scoreboardAudio.PlayOneShot(soundset.scoreboardUpdate, 0.5f);

        yield return(new WaitForSeconds(4));

        audioSource.Stop();
        currentRound++;

        //Match end conditions
        {
            if (redScore >= settings.winningThreshold && redScore > greenScore)
            {
                scoreboardAnimator.Play("RedMatch");
                scoreboardAudio.PlayOneShot(soundset.redWinner);
                Instantiate(Resources.Load <GameObject>("ReturnToMenu"), new Vector3(0, 1, 1 / 4), Quaternion.identity);
                yield break;
            }
            else if (greenScore >= settings.winningThreshold && greenScore > redScore)
            {
                scoreboardAnimator.Play("GreenMatch");
                scoreboardAudio.PlayOneShot(soundset.greenWinner);
                Instantiate(Resources.Load <GameObject>("ReturnToMenu"), new Vector3(0, 1, 1 / 4), Quaternion.identity);
                yield break;
            }
            else if (currentRound > settings.maxNumberOfRounds)
            {
                scoreboardAnimator.Play("DrawMatch");
                scoreboardAudio.PlayOneShot(soundset.draw);
                Instantiate(Resources.Load <GameObject>("ReturnToMenu"), new Vector3(0, 1, 1 / 4), Quaternion.identity);
                yield break;
            }
        }

        scoreboard.UpdateScoreboardText();

        StartCoroutine(StartRound());         //Starts a new round since the match end conditions didn't end the IEnumerator.

        yield break;
    }