void OnClick()
    {
        if (MethodName == "Play")
        {
            dataHolder.Play();
        }
        else if (MethodName == "Exit")
        {
            dataHolder.Exit();
        }
        else if (MethodName == "Setup")
        {
            int choice = 0;

            if (GameObject.Find("Player1 Panel").GetComponent <PlayerSelector>().selected)
            {
                choice = 1;
            }
            else if (GameObject.Find("Player2 Panel").GetComponent <PlayerSelector>().selected)
            {
                choice = 2;
            }
            else if (GameObject.Find("Player3 Panel").GetComponent <PlayerSelector>().selected)
            {
                choice = 3;
            }

            string name = GameObject.Find("Name").GetComponent <TextMeshProUGUI>().text;
            Debug.Log(name.Length);
            if (name.Length <= 1)
            {
                text.text = "Please enter a name for your character! (2 or more Characters)";

                Color imageColor = image.color;
                Color textColor  = text.color;
                imageColor.a = 1f;
                textColor.a  = 1f;
                image.color  = imageColor;
                text.color   = textColor;
            }
            else if (choice == 0)
            {
                text.text = "Please choose a character!";

                Color imageColor = image.color;
                Color textColor  = text.color;
                imageColor.a = 1f;
                textColor.a  = 1f;
                image.color  = imageColor;
                text.color   = textColor;
            }
            else
            {
                dataHolder.SetupPlayer(name, choice);
            }
        }
    }
Esempio n. 2
0
 private void OnMouseDown()
 {
     if (MethodName == "Exit")
     {
         dataHolder.Exit();
     }
     else if (MethodName == "Reset")
     {
         dataHolder.ResetPlayer();
     }
 }