Exemplo n.º 1
0
    public virtual IEnumerator EndRound()
    {
        ongoingRound = false;
        Debug.Log("Clear?");
        hazardSpawner.CleanAll();

        if (player1.health <= 0.0f)
        {
            player2WonRounds++;
            Debug.Log("Player 2 won the round!");
            roundInfoImage.gameObject.SetActive(true);
            upperText.text = "Blue Player";
            lowerText.text = "wins the Round!";
        }
        else if (player2.health <= 0.0f)
        {
            player1WonRounds++;
            Debug.Log("Player 1 won the round!");
            roundInfoImage.gameObject.SetActive(true);
            upperText.text = "Red Player";
            lowerText.text = "wins the Round!";
        }

        P1CloserRoundImage.color = player1WonRounds > 0 ? DataUtility.GetColorFor(PlayerID.Player1) : Color.black;
        P2CloserRoundImage.color = player2WonRounds > 0 ? DataUtility.GetColorFor(PlayerID.Player2) : Color.black;

        if (player1WonRounds >= 2)
        {
            roundInfoImage.gameObject.SetActive(true);
            upperText.text         = "Finished!";
            lowerText.text         = "Red Player Victory!";
            CenterRoundImage.color = DataUtility.GetColorFor(PlayerID.Player1);
            GameFinished(0);
        }
        else if (player2WonRounds >= 2)
        {
            roundInfoImage.gameObject.SetActive(true);
            upperText.text         = "Finished!";
            lowerText.text         = "Blue Player Victory!";
            CenterRoundImage.color = DataUtility.GetColorFor(PlayerID.Player2);
            GameFinished(1);
        }
        else
        {
            // TODO - Round transitions
            yield return(new WaitForSeconds(3.0f));

            StartCoroutine(StartNewRound());
        }
    }