예제 #1
0
    //Called after each round; returns IEnumerator for timer use
    IEnumerator RoundFinished(PlayerRPS p1)
    {
        //Disables buttons for set time to prevent player from continuing round
        p1.buttonRock.interactable     = false;
        p1.buttonPaper.interactable    = false;
        p1.buttonScissors.interactable = false;

        //Timer to between rounds to display results
        yield return(new WaitForSeconds(2));

        //Resets buttons to working game state
        p1.ResetButtons();

        //Resets text to starting state
        resultGT.text = " ";
        p1TextGO.SetActive(false);
        p2TextGO.SetActive(false);
        vsGT.text = "Select Option";

        //Destroy images
        p1.DestroyP1IM();
        Destroy(p2IM);

        //Updates round number if game not finished
        if (roundNum <= totalRounds)
        {
            roundsGT.text = "Round: " + roundNum.ToString();
            p2Choice      = GetComputerChoice();
        }
        else
        {
            GameFinished(p1);
        }
    }
예제 #2
0
    void Start()
    {
        dateTime = System.DateTime.Now.ToString();

        //All text initialized to starting state

        GameObject roundsGO = GameObject.Find("Rounds");

        roundsGT      = roundsGO.GetComponent <Text>();
        roundsGT.text = "Round: " + roundNum.ToString();

        GameObject p2ScoreGO = GameObject.Find("ComputerScore");

        p2ScoreGT      = p2ScoreGO.GetComponent <Text>();
        p2ScoreGT.text = "Computer Score: " + p2Score.ToString();

        GameObject resultGO = GameObject.Find("Result");

        resultGT      = resultGO.GetComponent <Text>();
        resultGT.text = " ";

        p2TextGO = GameObject.Find("ComputerText");
        p2TextGO.SetActive(false);

        gameOverGO = GameObject.Find("GameOver");
        gameOverGO.SetActive(false);

        p1TextGO = GameObject.Find("PlayerText");
        p1TextGO.SetActive(false);

        vsGO      = GameObject.Find("VS");
        vsGT      = vsGO.GetComponent <Text>();
        vsGT.text = "Select Option";

        playAgain.gameObject.SetActive(false);
        quitGame.gameObject.SetActive(false);

        //Gets computers choice
        p2Choice = GetComputerChoice();
    }