예제 #1
0
    public void DisplayChoices(string player, string computer)
    {
        switch (playerChoice)
        {
        case "rock":
            YouImage.GetComponent <Image>().sprite = RockImage;
            YouImage.rectTransform.sizeDelta       = new Vector2(325.5f, 286.85f);
            break;

        case "paper":
            YouImage.GetComponent <Image>().sprite = PaperImage;
            YouImage.rectTransform.sizeDelta       = new Vector2(340.5f, 300.81f);
            break;

        case "scissor":
            YouImage.GetComponent <Image>().sprite = ScissorImage;
            YouImage.rectTransform.sizeDelta       = new Vector2(340.5f, 241.77f);
            break;

        default:
            break;
        }

        switch (computerChoice)
        {
        case "rock":
            ComputerImage.GetComponent <Image>().sprite = RockImage;
            ComputerImage.rectTransform.sizeDelta       = new Vector2(325.5f, 286.85f);
            break;

        case "paper":
            ComputerImage.GetComponent <Image>().sprite = PaperImage;
            ComputerImage.rectTransform.sizeDelta       = new Vector2(340.5f, 300.81f);
            break;

        case "scissor":
            ComputerImage.GetComponent <Image>().sprite = ScissorImage;
            ComputerImage.rectTransform.sizeDelta       = new Vector2(340.5f, 241.77f);
            break;

        default:
            break;
        }

        // Changing the transparency (a) component to be visible
        YouImageColor.a = 1f;
        YouImage.GetComponent <Image>().color = YouImageColor;
        ComputerImageColor.a = 1f;
        ComputerImage.GetComponent <Image>().color = ComputerImageColor;
    }
예제 #2
0
    // Start is called before the first frame update
    void Start()
    {
        //reference to scores text in-game objects
        GameObject YouScoreGO      = GameObject.Find("YouScore");
        GameObject ComputerScoreGO = GameObject.Find("ComputerScore");
        GameObject GamesPlayedGO   = GameObject.Find("GamesPlayed");

        YouImageColor   = YouImage.GetComponent <Image>().color;
        YouImageColor.a = 0f; // Color for player default (white) and transparent
        YouImage.GetComponent <Image>().color = YouImageColor;

        ComputerImageColor = ComputerImage.GetComponent <Image>().color;
        ComputerImageColor = new Color32(255, 85, 66, 0);                            // Color for computer is red and transparent
        ComputerImage.GetComponent <Image>().color = ComputerImageColor;
        ComputerImage.rectTransform.rotation       = Quaternion.Euler(0f, 180f, 0f); //Rotate Computer image

        // Gets the Text component of the GameObject
        YouScoreGT           = YouScoreGO.GetComponent <Text>();
        ComputerScoreGT      = ComputerScoreGO.GetComponent <Text>();
        GamesPlayedGT        = GamesPlayedGO.GetComponent <Text>();
        ResultText.text      = "";
        DescriptionText.text = "";
    }