/// <summary>
        /// Event handler for when the Create Session menu entry is selected.
        /// </summary>
        void CreateSessionMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            try
            {
                // Which local profiles should we include in this session?
                IEnumerable<SignedInGamer> localGamers =
                        NetworkSessionComponent.ChooseGamers(sessionType,
                                                             ControllingPlayer.Value);

                // Begin an asynchronous create network session operation.
                IAsyncResult asyncResult = NetworkSession.BeginCreate(
                                                    sessionType, localGamers,
                                                    NetworkSessionComponent.MaxGamers,
                                                    0, null, null, null);

                // Activate the network busy screen, which will display
                // an animation until this operation has completed.
                NetworkBusyScreen busyScreen = new NetworkBusyScreen(asyncResult);

                busyScreen.OperationCompleted += CreateSessionOperationCompleted;

                ScreenManager.AddScreen(busyScreen, ControllingPlayer);
            }
            catch (Exception exception)
            {
                NetworkErrorScreen errorScreen = new NetworkErrorScreen(exception);

                ScreenManager.AddScreen(errorScreen, ControllingPlayer);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Event handler for when an available session menu entry is selected.
        /// </summary>
        void AvailableSessionMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            // Which menu entry was selected?
            AvailableSessionMenuEntry menuEntry = (AvailableSessionMenuEntry)sender;
            AvailableNetworkSession availableSession = menuEntry.AvailableSession;

            try
            {
                // Begin an asynchronous join network session operation.
                IAsyncResult asyncResult = NetworkSession.BeginJoin(availableSession,
                                                                    null, null);

                // Activate the network busy screen, which will display
                // an animation until this operation has completed.
                NetworkBusyScreen busyScreen = new NetworkBusyScreen(asyncResult);

                busyScreen.OperationCompleted += JoinSessionOperationCompleted;

                ScreenManager.AddScreen(busyScreen, ControllingPlayer);
            }
            catch (Exception exception)
            {
                NetworkErrorScreen errorScreen = new NetworkErrorScreen(exception);

                ScreenManager.AddScreen(errorScreen, ControllingPlayer);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Event handler for when the user selects ok on the "are you sure
 /// you want to quit" message box. This uses the loading screen to
 /// transition from the game back to the main menu screen.
 /// </summary>
 void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     ParentGame pg = ScreenManager.Game as ParentGame;
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(pg.NormalMode),
                                                    new MainMenuScreen(ScreenManager.Game as ParentGame));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Event handler for when the Return to Lobby menu entry is selected.
 /// </summary>
 void ReturnToLobbyMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     if (networkSession.SessionState == NetworkSessionState.Playing)
     {
         networkSession.EndGame();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Event handler for when the Quit Game menu entry is selected.
        /// </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            MessageBoxScreen confirmQuitMessageBox =
                                    new MessageBoxScreen(Resources.ConfirmQuitGame);

            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Event handler for when the End/Leave Session menu entry is selected.
 /// </summary>
 void LeaveSessionMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     NetworkSessionComponent.LeaveSession(ScreenManager, e.PlayerIndex);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Event handler for when the Back menu entry is selected.
        /// </summary>
        void BackMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            availableSessions.Dispose();

            ExitScreen();
        }
Exemplo n.º 8
0
 /// <summary>
 /// Event handler for when the Live menu entry is selected.
 /// </summary>
 void LiveMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     CreateOrFindSession(NetworkSessionType.PlayerMatch, e.PlayerIndex);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Event handler for when the user selects ok on the "are you sure
 /// you want to exit" message box.
 /// </summary>
 void ConfirmExitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     ParentGame pg = ScreenManager.Game as ParentGame;
     pg.Level_Loader.Stop();
     ScreenManager.Game.Exit();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Helper overload makes it easy to use OnCancel as a MenuEntry event handler.
 /// </summary>
 protected void OnCancel(object sender, PlayerIndexEventArgs e)
 {
     OnCancel(e.PlayerIndex);
 }
Exemplo n.º 11
0
        void ModeSelected(object sender, PlayerIndexEventArgs e)
        {
            NormalMode = (NormalMode) ? false : true;
            selectedEntry = 0;

            if (NormalMode)
            {
                menuEntries[1].Text = Mode2;
                base.menuTitle = Mode1;
            }
            else
            {
                menuEntries[1].Text = Mode1;
                base.menuTitle = Mode2;
            }

            ParentGame pg = ScreenManager.Game as ParentGame;
            pg.NormalMode = NormalMode;
            pg.LevelNum = 0;
            pg.GetLevelNum();

            LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(NormalMode), this);
        }
Exemplo n.º 12
0
 void LevelSelectSelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(NormalMode),
         new LevelSelectScreen(ScreenManager.Game as ParentGame));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Event handler for when the System Link menu entry is selected.
 /// </summary>
 void SystemLinkMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     CreateOrFindSession(NetworkSessionType.SystemLink, e.PlayerIndex);
 }
Exemplo n.º 14
0
        void ModeSelected(object sender, PlayerIndexEventArgs e)
        {
            NormalMode = (NormalMode) ? false : true;
            selectedEntry = 0;
            if (NormalMode)
                menuEntries[1].Text = "Time Trial Mode";
            else
                menuEntries[1].Text = "Normal Mode";

            LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), this);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Event handler for when the host selects ok on the "are you sure
 /// you want to start even though not everyone is ready" message box.
 /// </summary>
 void ConfirmStartGameMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     if (networkSession.SessionState == NetworkSessionState.Lobby)
     {
         networkSession.StartGame();
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Event handler for when the Single Player menu entry is selected.
 /// </summary>
 void SinglePlayerMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     ParentGame game = ScreenManager.Game as ParentGame;
     if (!game.LevelStat[game.LevelNum - 1].locked)
     {
         LoadingScreen.Load(ScreenManager, false, e.PlayerIndex,
                            new GameplayScreen(null, ScreenManager.Game as ParentGame));
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Event handler for when the user selects ok on the "are you sure
 /// you want to exit" message box.
 /// </summary>
 void ConfirmExitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.Game.Exit();
 }