Beispiel #1
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 if the game was paused (esc)
            if (input.IsPauseGame())
            {
                // Overlay the pause screen
                ScreenManager.AddScreen(new PauseMenuScreen());
            }

            // Check if the start button was hit (enter)
            if (input.IsStartButton())
            {
                // Move onto the match screen
                LoadingScreen.Load(ScreenManager, false, new GameplayScreen());
            }
        }
Beispiel #2
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;
                }
            }
        }
        /// <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;
                }
            }
        }