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

            foreach (object control in playersTableLayoutPanel.Controls)
            {
                AiPlayerControl aiPlayerControl = control as AiPlayerControl;

                players.Add(aiPlayerControl.GetPlayer() as AiPlayer); // TODO: may throw exception
            }

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

            AiPlayerControl control = new AiPlayerControl("PC")
            {
                Anchor = AnchorStyles.Left | AnchorStyles.Right
            }; // TODO: generate unique name

            playersTableLayoutPanel.Controls.Add(control);
        }