예제 #1
0
        /// <summary>
        /// Respond to "Return" Item Selection
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ReturnGameMenuEntrySelected(object sender, EventArgs e)
        {
            if (!isResuming)
            {
                // Resume sounds and activate the gameplay screen
                AudioManager.PauseResumeSounds(true);

                var screens = ScreenManager.GetScreens();

                foreach (GameScreen screen in screens)
                {
                    if (!(screen is GameplayScreen))
                    {
                        screen.ExitScreen();
                    }
                }

                (ScreenManager.GetScreens()[0] as GameplayScreen).IsActive = true;
            }
            else
            {
                // Since we are resuming the game, go to the loading screen which will
                // in turn initialize the gameplay screen
                foreach (GameScreen screen in ScreenManager.GetScreens())
                {
                    screen.ExitScreen();
                }

                ScreenManager.AddScreen(new LoadingAndInstructionsScreen(true), null);
            }
        }
예제 #2
0
        /// <summary>
        /// Pause the game.
        /// </summary>
        private void PauseCurrentGame()
        {
            IsActive = false;

            // Pause sounds
            AudioManager.PauseResumeSounds(false);

            ScreenManager.AddScreen(new BackgroundScreen(false), null);
            ScreenManager.AddScreen(new PauseScreen(false), null);
        }
예제 #3
0
        /// <summary>
        /// Creates a new instance of the pause screen.
        /// </summary>
        /// <param name="isResuming">Whether or not the screen is displayed as a
        /// response to resuming the game (returning to it after the win key has
        /// been pressed, for example).</param>
        public PauseScreen(bool isResuming)
            : base("Pause")
        {
            // Create our menu entries
            MenuEntry returnGameMenuEntry = new MenuEntry("Return");
            MenuEntry exitMenuEntry       = new MenuEntry("Quit");

            // Hook up menu event handlers
            returnGameMenuEntry.Selected += ReturnGameMenuEntrySelected;
            exitMenuEntry.Selected       += OnCancel;

            // Add entries to the menu
            MenuEntries.Add(returnGameMenuEntry);
            MenuEntries.Add(exitMenuEntry);

            this.isResuming = isResuming;

            if (!isResuming)
            {
                AudioManager.PauseResumeSounds(false);
            }
        }