Exemple #1
0
    private IEnumerator RoundPlaying()
    {
        ManagerFunctions.EnableScoreBoard(false, ScorePanel);

        // As soon as the round begins playing let the players control the tanks.
        ManagerFunctions.EnableTankControls(Tanks);
        ManagerFunctions.EnableAgentControls(Agents);

        CountDownText.text = string.Empty;
        MessageText.text   = string.Empty;

        while (NextState == null)
        {
            // While there is not one tank left...
            while (GameObject.FindObjectsOfType <TankHealth>().Length > 1)
            {
                if (Input.GetButtonDown("Pause"))
                {
                    PauseMenu.SetActive(true);
                    SetGameTimeScale(0.0f);
                }

                FrameCount += Time.deltaTime;
                if (FrameCount > MineSpawnDelay)
                {
                    SpawnRandomMine();
                    FrameCount = 0;
                }

                if (ManagerFunctions.GetActiveTanks() < 1 && !SpeedButton.activeInHierarchy)
                {
                    SpeedButton.SetActive(true);
                }

                yield return(null);
            }

            if (CurrentRound < NumOfRounds)
            {
                ManagerFunctions.AddScoreToFinalTank();
                NextState = RoundBreak();
            }
            else
            {
                ManagerFunctions.AddScoreToFinalTank();
                NextState = GameEnding();
            }

            yield return(null);
        }
    }
Exemple #2
0
    private IEnumerator GameEnding()
    {
        //// As soon as the round begins playing let the players control the tanks.
        ManagerFunctions.ResetSpawnPoints(Spawns);

        NameManager.Instance.InitNames();

        ManagerFunctions.EnableScoreBoard(true, ScorePanel);

        ScoreManager.Instance.ClearScores();

        StartNewRound();

        PlayerScore[] TankScores = GameObject.FindObjectsOfType <PlayerScore>();

        PlayerScore WinningTank = TankScores[0];

        foreach (PlayerScore S in TankScores)
        {
            if (S.Score > WinningTank.Score)
            {
                WinningTank = S;
            }
        }

        MessageText.text = WinningTank.GetComponent <PlayerName>().GetCurrentName() + " WINS";

        WinningTank.gameObject.transform.position = new Vector3(0.0f, 1.0f, 0.0f);

        Camera MainCamera = GameObject.FindObjectOfType <Camera>();

        MainCamera.GetComponent <Animator>().SetTrigger("WinIn");

        MenuButton.SetActive(true);

        StopAllCoroutines();

        yield return(null);
    }
Exemple #3
0
    private IEnumerator RoundBreak()
    {
        TimeLeft = 10;

        CurrentRound++;

        StartNewRound();

        ManagerFunctions.EnableScoreBoard(true, ScorePanel);

        while (TimeLeft > 1)
        {
            TimeLeft -= Time.deltaTime;

            if (TimeLeft > 3)
            {
                CountDownText.text = string.Empty;
                MessageText.text   = "ROUND " + CurrentRound.ToString();
            }
            else
            {
                if (ScorePanel.activeInHierarchy)
                {
                    ManagerFunctions.EnableScoreBoard(false, ScorePanel);
                }
                CountDownText.text = (TimeLeft).ToString("0");
                MessageText.text   = string.Empty;
            }

            yield return(null);
        }

        NextState = RoundPlaying();

        yield return(null);
    }