Пример #1
0
        /// <summary>
        /// Handles event where a player is either claiming or releasing hosting rights for this game
        /// </summary>
        ///
        /// <param name="sender">The panel sending the event</param>
        /// <param name="isHost">Whether the sending panel is trying to claim host of this game</param>
        ///
        /// <returns>True if the panel successfully claimed or released hosting rights, false otherwise</returns>
        private bool PlayerSetupPanel_PlayerHostStatusChanged(PlayerSetupPanel sender, bool isHost)
        {
            // Don't allow another player to try to be host but if the same player
            // calls this event again, just let them pass through
            if (HasHost && isHost)
            {
                UpdateServerButtonState();
                return(hostPlayer.PlayerId == sender.PlayerId);
            }

            if (isHost)
            {
                hostPlayer = sender;
            }
            else if (hostPlayer.PlayerId == sender.PlayerId)
            {
                hostPlayer = null;
            }

            UpdateServerButtonState();
            return(true);
        }
Пример #2
0
        /// <summary>
        /// Executes the given <paramref name="method"/> against the <see cref="PlayerSetupPanel"/> that has the provided <paramref name="playerId"/>.
        /// </summary>
        ///
        /// <param name="method">The method to execute</param>
        /// <param name="playerId">The unique identifier for the player panel to execute the <paramref name="method"/> against</param>
        private void ExecuteAgainstPlayer(Action <PlayerSetupPanel> method, string playerId)
        {
            PlayerSetupPanel panel = Controls.OfType <PlayerSetupPanel>().FirstOrDefault(p => p.PlayerId == playerId);

            method(panel);
        }