Esempio n. 1
0
        /// <summary>
        ///     Calculates and returns players from controls saved in the table.
        /// </summary>
        /// <returns>Returns players from controls saved in the table.</returns>
        public IList <Player> GetPlayers()
        {
            IList <Player> players = new List <Player>();

            foreach (object control in playersTableLayoutPanel.Controls)
            {
                HumanPlayerControl humanPlayerControl = control as HumanPlayerControl;

                players.Add(humanPlayerControl.GetPlayer()); // TODO: may throw exception
            }

            return(players);
        }
Esempio n. 2
0
        /// <summary>
        ///     Adds player to table to the last position.
        /// </summary>
        public void AddPlayer(User user)
        {
            if (PlayersLimit <= PlayersCount)
            {
                throw new ArgumentException();
            }

            HumanPlayerControl control = new HumanPlayerControl
            {
                Anchor = AnchorStyles.Left | AnchorStyles.Right
            }; // TODO: generate unique name

            playersTableLayoutPanel.Controls.Add(control);
        }
Esempio n. 3
0
        /// <summary>
        ///     Replaces player on given index with given user.
        /// </summary>
        /// <param name="index">Index indicating which row of table will be replaced.</param>
        /// <param name="user">Indicates with whom will the previous user be replaced.</param>
        public void ReplacePlayer(int index, User user)
        {
            HumanPlayerControl control = (HumanPlayerControl)playersTableLayoutPanel.Controls[index];

            Global.MyUser = user;
        }