Пример #1
0
    public void PlayerClicked(int i)
    {
        if (state == states.SetupOrder)
        {
            Transform playerPanel = setupPanel.GetChild(i - 1);
            string    playername  = playerPanel.Find("Inputfield/Playername").GetComponent <InputField> ().text;
            print(string.Format("Player {0}:{1} clicked!", i, playername));

            GameObject playerObj = new GameObject("Player");
            playerObj.AddComponent <SixPocketPlayer> ();
            playerObj.transform.parent = transform.Find("Players");
            SixPocketPlayer p = playerObj.GetComponent <SixPocketPlayer> ();
            p.playername = playername;
            p.color      = Global.instance.colors [i - 1];

            if (!Global.instance.players.Contains(p) && playername != "")
            {
                Global.instance.players.Add(p);
                Transform ball      = playerPanel.Find("Ball");
                Text      ballLabel = ball.Find("BallLabel").GetComponent <Text> ();
                ballLabel.text = Global.instance.players.Count.ToString();
            }
            else
            {
                print("Player already exists?");
            }
        }
    }
Пример #2
0
    public override bool Equals(object b)
    {
        SixPocketPlayer playerB = b as SixPocketPlayer;

        return(playername == playerB.playername);
    }