public static void LeaveSessionFromGame(ScreenManager screenManager, AudioManager audioManager)// Audio audioHelper) { // Search through Game.Components to find the NetworkSessionComponent. foreach (IGameComponent component in screenManager.Game.Components) { NetworkSessionComponent self = component as NetworkSessionComponent; if (self != null) { // Display a message box to confirm the user really wants to leave. string message; if (self.networkSession.IsHost) { message = Resources.ConfirmEndSession; } else { message = Resources.ConfirmLeaveSession; } MessageBoxScreen confirmMessageBox = new MessageBoxScreen(message); // Hook the messge box ok event to actually leave the session. confirmMessageBox.Accepted += delegate { self.LeaveSessionFromGame(audioManager);//audioHelper); }; screenManager.AddScreen(confirmMessageBox); break; } } }
/// <summary> /// Handle MenuCancel inputs by clearing our ready status, or if it is /// already clear, prompting if the user wants to leave the session. /// </summary> void HandleMenuCancel(LocalNetworkGamer gamer) { if (gamer.IsReady) { gamer.IsReady = false; } else { NetworkSessionComponent.LeaveSessionFromGame(ScreenManager, audioManager); //audioHelper); } }