The loading screen coordinates transitions between the menu system and the game itself. Normally one screen will transition off at the same time as the next screen is transitioning on, but for larger transitions that can take a longer time to load their data, we want the menu system to be entirely gone before we start loading the game. This is done as follows: - Tell all the existing screens to transition off. - Activate a loading screen, which will transition on at the same time. - The loading screen watches the state of the previous screens. - When it sees they have finished transitioning off, it activates the real next screen, which may take a long time to load its data. The loading screen will be the only thing displayed while this load is taking place.
Inheritance: GameScreen
Ejemplo n.º 1
0
        //displays loading screen
        public static void Load(ScreenManager screenManager, bool loadingIsSlow,
                                PlayerIndex? controllingPlayer,
                                params GameScreen[] screensToLoad)
        {
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            loadingIsSlow,
                                                            screensToLoad);

            screenManager.AddScreen(loadingScreen, controllingPlayer);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ScreenManager screenManager, bool loadingIsSlow, params GameScreen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            loadingIsSlow,
                                                            screensToLoad);

            screenManager.AddScreen(loadingScreen);
        }
        /// <summary>
        /// Активация экрана загруззки.
        /// </summary>
        public static void Load(ScreenManager screenManager, bool loadingIsSlow,
                                PlayerIndex? controllingPlayer,
                                params GameScreen[] screensToLoad)
        {
            //Даем команду текущим экранам исчезнуть.
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            //Создаем и активируем экран загрузки.
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            loadingIsSlow,
                                                            screensToLoad);

            screenManager.AddScreen(loadingScreen, controllingPlayer);
        }
Ejemplo n.º 4
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, EventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new MainMenuScreen());
 }
Ejemplo n.º 5
0
 void PlayGameMenuEntrySelected(object sender, EventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, new GameplayScreen());
 }
Ejemplo n.º 6
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)
 {
     MediaPlayer.Stop();
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(),
                        new MainMenuScreen());
 }
        private void LevelMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            string          levelFileName = MenuEntries[SelectedEntry].Text + ".lvl";
            string          gunFileName   = MenuEntries[SelectedEntry].Text.Split(' ')[0] + ".gun";
            WeaponChallenge challenge     = ActivePlayer.Profile.GetWeaponChallenge(levelFileName);

            // Load the level selected
            if (challenge.Status != GameObjects.LevelStatus.Locked)
            {
                if (Guide.IsTrialMode && SelectedEntry > 1)
                {
                    if (ActivePlayer.Profile.IsXboxLiveEnabled() && !Guide.IsVisible)
                    {
                        // Trial mode players can only play first two levels. Offer purchase
                        Guide.ShowMarketplace(ActivePlayer.PlayerIndex);
                    }
                    else
                    {
                        // Play failed sound effect
                        failedSFX.Play();
                    }
                }
                else
                {
                    ShooterGameType gameType          = challenge.GameType;
                    float           targetScoreOrTime = challenge.TargetScoreOrTime;

                    // Create message string
                    string message = string.Empty;
                    if (gameType == ShooterGameType.Targets)
                    {
                        message = "Shoot all of the targets.";
                    }
                    else if (gameType == ShooterGameType.TargetScore)
                    {
                        message = "Get a High Score over " + (int)targetScoreOrTime + ".";
                    }
                    else if (gameType == ShooterGameType.TimeTrial)
                    {
                        message = "Complete level in under " + targetScoreOrTime.ToString("F") + " secs.";
                    }
                    else if (gameType == ShooterGameType.Collection)
                    {
                        message = "Find and collect the Grenade.";
                    }
                    else if (gameType == ShooterGameType.BullseyeChallenge)
                    {
                        message = "Get a Bullseye on every target.";
                    }
                    else if (gameType == ShooterGameType.HeadshotChallenge)
                    {
                        message = "Get a Headshot on every target.";
                    }

                    ShooterGameScreen.originalGunName = ActivePlayer.Profile.SelectedWeaponName;
                    LoadingScreen.Load(ScreenManager, true, message,
                                       ActivePlayer.PlayerIndex,
                                       new ShooterGameScreen(levelFileName, gunFileName,
                                                             gameType, targetScoreOrTime));
                }
            }
            else
            {
                // Play failed sound effect
                failedSFX.Play();
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Event handler for when the Quit Game menu entry is selected.
 /// </summary>
 void QuitGameMenuEntrySelected(object sender, EventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new MainMenuScreen());
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // Look up inputs for the active player profile
            KeyboardState keyboardState = input.CurrentKeyboardStates;

            // Check to see if the game is paused (esc)
            if (input.IsPauseGame())
            {
                // Add the pause screen
                ScreenManager.AddScreen(new PauseMenuScreen());
            }
            // Check to see if a menu element was selected and ensure that the match is not over
            if (input.IsMenuSelect() && !matchOver)
            {
                // Swap the turn state
                playerTurn = !playerTurn;

                // Check if it is the player's turn
                if (playerTurn)
                {
                    // Let the player select a move
                    player.SelectMove(enemy, PlayerInfo.Moves[selectedMove], playerSpriteManager);
                }
                else
                {
                    // Select the move after the player has selected their move (Z pressed a second time)
                    enemy.SelectMove(player, enemySpriteManager);
                }

                // Check to see if the enemy is dead
                if (enemy.CurrentHP <= 0)
                {
                    // Increment the player wins and set the match to over
                    PlayerInfo.Wins += 1;
                    matchOver        = true;

                    // Play the downed animation
                    enemySpriteManager.CurrentAnimation = "Down";
                }
                // Check to see if the player is dead
                else if (player.CurrentHP <= 0)
                {
                    // Increment the palyer losses and set the match to over
                    PlayerInfo.Losses += 1;
                    matchOver          = true;

                    // Play the downed animation
                    playerSpriteManager.CurrentAnimation = "Down";
                    // Load enemy win anim
                }
            }
            // Check to see if the start button was pressed and ensure that the match is over
            if (input.IsStartButton() && matchOver)
            {
                // Load the training screen if there are still enemies to face
                if (PlayerInfo.Wins < 4)
                {
                    LoadingScreen.Load(ScreenManager, false, new TrainingScreen());
                }
                // Otherwise, wipe the save data and go back to the main menu
                else
                {
                    SaveAndLoadGame.WipeSave();
                    LoadingScreen.Load(ScreenManager, false, new MainMenuScreen());
                }
            }

            // Check if the player is navigating the menu to the left
            if (input.IsMenuLeft())
            {
                // Decrement the selected move
                selectedMove--;

                // Wrap the selected move back around to end if it passes behind the start
                if (selectedMove < 0)
                {
                    selectedMove = maxMoves - 1;
                }
            }
            // Check if the player is nagivating the menu to the right
            if (input.IsMenuRight())
            {
                // Increment the selected move
                selectedMove++;

                // Wrap the selected move back to the beginning if it goes beyond the end
                if (selectedMove >= maxMoves)
                {
                    selectedMove = 0;
                }
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Event handler for when the Play Game menu entry is selected.
 /// </summary>
 void ArtistMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                        Global.artistModeScreen);
 }
Ejemplo n.º 11
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)
 {
     LoadingScreen.Load(ScreenManager, false, ActivePlayer.PlayerIndex,
                        new BackgroundScreen(),
                        new MainMenuScreen());
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Event handler for when the Start Game menu entry is selected.
 /// </summary>
 private void StartGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                        new GameplayScreen());
 }
 void LvL10(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                        new GameplayScreen());
     Debug.WriteLine("lvl10");
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Event handler for when the Play Game menu entry is selected
 /// </summary>
 void NewGameMenuEntrySelected(object sender, EventArgs e)
 {
     // Load the match info screen
     LoadingScreen.Load(ScreenManager, true, new MatchupInfoScreen());
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Event handler for when the Quit Game menu entry is selected.
 /// </summary>
 void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                        new Platformer.PlatformerGame());
 }
 /// <summary>
 /// Event handler for when the Play Game menu entry is selected.
 /// </summary>
 void hardEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                        new GameplayScreen());
 }
Ejemplo n.º 17
0
        void nextLevelMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            OptionsMenuScreen.SwitchToNextBoard();
            LoadingScreen.Load(ScreenManager, true, e.PlayerIndex, new GameplayScreen());

        }
Ejemplo n.º 18
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ScreenManager screenManager, bool loadingIsSlow,
            PlayerIndex? controllingPlayer,
            params GameScreen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            //Flush GC
            GC.Collect();

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            loadingIsSlow,
                                                            screensToLoad);

            screenManager.AddScreen(loadingScreen, controllingPlayer);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Check if the user's input is null and throw an exception if it is
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // Look up inputs for the active player profile
            KeyboardState keyboardState = input.CurrentKeyboardStates;

            // Checks to see if the user hit the pause button (esc)
            if (input.IsPauseGame())
            {
                // Add a new screen on top of our current screen to display the pause menu
                ScreenManager.AddScreen(new PauseMenuScreen());
            }

            // Check to see if our menu selection key was hit (Z)
            if (input.IsMenuSelect())
            {
                // Check to see if the player already has the move they are on in the selection screen equipped
                if (PlayerInfo.Moves.Contains(selectedMove))
                {
                    // Get the index of this move and remove it from the player's currently equipped moves
                    int index = Array.IndexOf(PlayerInfo.Moves, selectedMove);
                    PlayerInfo.Moves[index] = -1;
                }
                // Otherwise, if there is an open slot for equipping a new move
                else if (PlayerInfo.Moves.Contains(-1))
                {
                    // Get the index of the open slot and fill it with the new selected index
                    int index = Array.IndexOf(PlayerInfo.Moves, -1);
                    PlayerInfo.Moves[index] = selectedMove;
                }
            }
            // Check to see if the start button (enter) was pressed and if the player has any moves equipped (I.E anything with an index greater than -1)
            if (input.IsStartButton() && Array.Exists(PlayerInfo.Moves, selectedMove => selectedMove > -1))
            {
                // Load the next match
                LoadingScreen.Load(ScreenManager, false, new MatchupInfoScreen());
            }
            // Check to see if the up arrow key was hit
            if (input.IsMenuUp())
            {
                // Decrement the selected move
                selectedMove--;

                // Wrap the selected move around if the user goes beyond the minimum moves
                if (selectedMove < 0)
                {
                    selectedMove = maxMoves - 1;
                }
            }
            // Check to see if the down arrow key was hit
            if (input.IsMenuDown())
            {
                // Increment the selected move
                selectedMove++;

                // Wrap back around if the player goes beyond the maximum amount of moves
                if (selectedMove >= maxMoves)
                {
                    selectedMove = 0;
                }
            }
        }