void FinishGame(int winnerPlayerNum)
        {
            Player2Timer.Stop();
            Player1Timer.Stop();

            MessageBox.Show("Winner: " + winnerPlayerNum.ToString() + ".Player", "End Game Window", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.Close();
        }
        private void TimeRecorder()
        {
            if (Player1Timer.Enabled)
            {
                Player1Timer.Stop();
                Player2Timer.Start();
            }

            else
            {
                Player1Timer.Start();
                Player2Timer.Stop();
            }
        }
예제 #3
0
    public void Update()
    {
        if (gameOver == true)
        {
            StartCoroutine(LoadMainMenu());
        }

        if (currentPlayer == "White" && gameOver == false)
        {
            Player1Timer -= 1 * Time.deltaTime;
            Player1THolder.SetActive(true);
            Player2THolder.SetActive(false);
        }

        else if (currentPlayer == "Black" && gameOver == false)
        {
            Player2Timer -= 1 * Time.deltaTime;
            Player1THolder.SetActive(false);
            Player2THolder.SetActive(true);
        }

        if (Player1Timer == 0 || Player1Timer <= 0)
        {
            Player1THolder.SetActive(true);
            Player2THolder.SetActive(true);
            Player1Timer = 0;
            gameOver     = true;
            WinnerHolder.SetActive(true);
            GameObject.FindGameObjectWithTag("WinnerText").GetComponent <Text>().enabled = true;
            GameObject.FindGameObjectWithTag("WinnerText").GetComponent <Text>().text    = "Black is the winner";
        }

        else if (Player2Timer == 0 || Player2Timer <= 0)
        {
            Player1THolder.SetActive(true);
            Player2THolder.SetActive(true);
            Player2Timer = 0;
            gameOver     = true;
            WinnerHolder.SetActive(true);
            GameObject.FindGameObjectWithTag("WinnerText").GetComponent <Text>().enabled = true;
            GameObject.FindGameObjectWithTag("WinnerText").GetComponent <Text>().text    = "White is the winner";
        }
        P1Timer.text = "Player 1 timer: " + Player1Timer.ToString("0");
        P2Timer.text = "Player 2 timer: " + Player2Timer.ToString("0");
    }