/// <summary> /// Attempts to join a player to a lobby. The MsgErrorCode parameter will be set if the /// operation is not succesful. /// </summary> /// <param name="lobbyID">The ID of the lobby to join.</param> /// <param name="playerName">The player's name.</param> /// <param name="error">Out parameter set to the appropriate error code when an error occurs.</param> /// <returns></returns> private bool AddPlayerToLobby( NetConnection playerConn, int lobbyID, string playerName, out MsgErrorCode error ) { bool success = true; error = MsgErrorCode.None; lock ( lobbyLock ) { if ( lobbies[lobbyID] == null ) { // Lobby doesn't exist error = MsgErrorCode.InvalidLobby; success = false; } else if ( lobbies[lobbyID].AddPlayer( playerConn, playerName ) == -1 ) { // Lobby is full error = MsgErrorCode.LobbyFull; success = false; } } return success; }
private void HandleError( MsgErrorCode err ) { string msg = ""; switch ( err ) { case MsgErrorCode.CannotCreateLobby: msg += "Can't create any more new lobbies yet."; break; case MsgErrorCode.LobbyFull: msg += "That lobby is full."; break; case MsgErrorCode.InvalidLobby: msg += "That lobby does not exist anymore."; break; } PopUpScreen popup = new PopUpScreen( msg, PopUpScreen.Style.OK ); ScreenManager.AddScreen( popup, null ); }