Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
 /// <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);
     }
 }