예제 #1
0
        /// <summary>
        /// Raises a PlayerCount event
        /// </summary>
        /// <param name="args"></param>
        private void FireOnPlayerCountEvent(PlayerCountArgs args)
        {
            EventHandler <PlayerCountArgs> tempHandler = OnPlayerCountChanged;

            if (tempHandler != null)
            {
                tempHandler.BeginInvoke(this, args, null, null);
            }
        }
예제 #2
0
        /// <summary>
        /// Fired when player count has changed
        /// </summary>
        /// <param name="sender">Object causing this event</param>
        /// <param name="e">New player count and information about player who joined/left game</param>
        void newClient_OnPlayerCountChanged(object sender, PlayerCountArgs e)
        {
            // Let our listeners know the player count has changed
            var tempHandler = OnPlayerCountChange;

            if (OnPlayerCountChange != null)
            {
                tempHandler.BeginInvoke(clients[0].PlayerNames, null, null);
            }

            if (isShuttindDown)
            {
                return;
            }

            Output(String.Format("Player count changed: {0} / {1}", e.PlayerCount, e.MaxPlayers));

            if (e.IsBot)
            {
                Output("It's a bot, ignoring");
                return;
            }

            if (clients.Count == 0)
            {
                Output("!!! PlayerCountChanged event raised without any clients");
                return;
            }
            if (settings.IsSinglePlayerMode)
            {
                if (e.PlayerCount < e.MaxPlayers - 1)
                {
                    PushBot();
                }
            }
            else
            {
                if (e.PlayerCount < e.MaxPlayers - 1)
                {
                    PushBot();
                }
                else if (e.PlayerCount == e.MaxPlayers && clients.Count > 0)
                {
                    PopBot();
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Raised when player count changes within the game.
 /// </summary>
 /// <param name="sender">Object causing this event</param>
 /// <param name="e">Args containing new player count</param>
 private void gameClient_OnPlayerCountChanged(object sender, PlayerCountArgs e)
 {
     //Log("Player count changed -> " + e.ToString());
     FireOnPlayerCountEvent(e);
 }
예제 #4
0
 /// <summary>
 /// Raised when player count changes within the game.
 /// </summary>
 /// <param name="sender">Object causing this event</param>
 /// <param name="e">Args containing new player count</param>
 private void gameClient_OnPlayerCountChanged(object sender, PlayerCountArgs e)
 {
     //Log("Player count changed -> " + e.ToString());
     FireOnPlayerCountEvent(e);
 }
예제 #5
0
 /// <summary>
 /// Raises a PlayerCount event
 /// </summary>
 /// <param name="args"></param>
 private void FireOnPlayerCountEvent(PlayerCountArgs args)
 {
     EventHandler<PlayerCountArgs> tempHandler = OnPlayerCountChanged;
     if (tempHandler != null)
     {
         tempHandler.BeginInvoke(this, args, null, null);
     }
 }
예제 #6
0
        /// <summary>
        /// Fired when player count has changed
        /// </summary>
        /// <param name="sender">Object causing this event</param>
        /// <param name="e">New player count and information about player who joined/left game</param>
        void newClient_OnPlayerCountChanged(object sender, PlayerCountArgs e)
        {
            // Let our listeners know the player count has changed
            var tempHandler = OnPlayerCountChange;
            if (OnPlayerCountChange != null)
            {
                tempHandler.BeginInvoke(clients[0].PlayerNames, null, null);
            }

            if (isShuttindDown)
            {
                return;
            }

            Output(String.Format("Player count changed: {0} / {1}", e.PlayerCount, e.MaxPlayers));

            if (e.IsBot)
            {
                Output("It's a bot, ignoring");
                return;
            }

            if (clients.Count == 0)
            {
                Output("!!! PlayerCountChanged event raised without any clients");
                return;
            }
            if (settings.IsSinglePlayerMode)
            {
                if (e.PlayerCount < e.MaxPlayers-1)
                {
                    PushBot();
                }
            }
            else
            {
                if (e.PlayerCount < e.MaxPlayers - 1)
                {
                    PushBot();
                }
                else if (e.PlayerCount == e.MaxPlayers && clients.Count > 0)
                {
                    PopBot();
                }
            }
        }