Esempio n. 1
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            ScreenManager.GraphicsDevice.Clear(Color.Gainsboro);

            spriteBatch.Begin();

            level.drawBackground(spriteBatch, ref content);

            guy.Sprite.Draw();

            shoes.Sprite.Draw();

            foreach (Air air in Air.allAirs)
            {
                air.Draw();
            }

            level.drawForeground(spriteBatch, ref content);

            // Draw the level.
            level.Draw(spriteBatch, true);

            if (Level.bonusLevelsSelected || displayInterface)
            {
                level.Draw(spriteBatch, false);
            }

            if (displayInterface)
            {
                spriteBatch.DrawString(debugFont, "Angle between mouse and player: " + guy.angleBetweenGuyAndMouseCursor.ToString(), new Vector2(0, 0), Color.Black);
                spriteBatch.DrawString(debugFont, "Guy - Power (Scroll Wheel): " + guy.powerOfLauncherBeingUsed.ToString(), new Vector2(0, 20), Color.Black);
                spriteBatch.DrawString(debugFont, "Guy - Gravity (./3): " + guy.gravity.ToString(), new Vector2(0, 40), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes - Air Movement (7/8): " + shoes.airMovementSpeed.ToString(), new Vector2(0, 60), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes - Ground Movement (4/5): " + shoes.groundMovementSpeed.ToString(), new Vector2(0, 80), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes - Jump Impulse (1/2): " + shoes.jumpImpulse.ToString(), new Vector2(0, 100), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes - Gravity (9/6): " + shoes.gravity.ToString(), new Vector2(0, 120), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes - Fall From Tile Rate (/ / -): " + shoes.fallFromTileRate.ToString(), new Vector2(0, 140), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes - Preset (F Keys): " + shoes.preset, new Vector2(0, 160), Color.Black);
                spriteBatch.DrawString(debugFont, "Interface Linked (F12): " + shoes.interfaceLinked.ToString(), new Vector2(0, 180), Color.Black);
                spriteBatch.DrawString(debugFont, "Guy Debug: " + guy.debug, new Vector2(0, 200), Color.Black);
                spriteBatch.DrawString(debugFont, "Guy Debug2: " + guy.debug2, new Vector2(0, 220), Color.Black);
                spriteBatch.DrawString(debugFont, "Guy Debug3: " + guy.debug3, new Vector2(0, 240), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes Debug: " + shoes.debug.ToString(), new Vector2(0, 260), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes Debug2: " + shoes.debug2.ToString(), new Vector2(0, 280), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes Debug3: " + shoes.debug3.ToString(), new Vector2(0, 300), Color.Black);
                spriteBatch.DrawString(debugFont, "Character Debug: " + Character.charDebug, new Vector2(0, 320), Color.Black);
                spriteBatch.DrawString(debugFont, "Shoes State: " + shoes.CurrentState.ToString(), new Vector2(0, 340), Color.Black);
                spriteBatch.DrawString(debugFont, "Guy State: " + guy.CurrentState.ToString(), new Vector2(0, 360), Color.Black);
                spriteBatch.DrawString(debugFont, "AnimatedSprite Debug: " + AnimatedSprite.debug, new Vector2(0, 380), Color.Black);
                spriteBatch.DrawString(debugFont, "Air Debug: " + Air.debug, new Vector2(0, 400), Color.Black);
                spriteBatch.DrawString(debugFont, "Air Debug2: " + Air.debug2, new Vector2(0, 420), Color.Black);
                spriteBatch.DrawString(debugFont, "Game1 Debug: " + debug, new Vector2(0, 440), Color.Black);
            }

            // Draw the trajectory line while the left mouse button is being held.
            if (guy.AreGuyAndShoesCurrentlyLinked && newMouseState.LeftButton == ButtonState.Pressed)
            {
                TrajectoryLineHandler.Draw(spriteBatch, ref content);
            }

            // Write the power level below the Shoes or Guy when using a Launcher.
            displayPowerLevelIfPossible();

            // Check to see if the player won. If they did, display the level completion picture.
            drawLevelCompleteImageIfPossible();

            // Draw the faded out screen if possible.
            guy.fadeHandler.Draw(content.Load <Texture2D>("Backgrounds/blank"));

            // Draw the level name while the screen is faded out.
            if (guy.fadeHandler.HoldingWhileFaded)
            {
                spriteBatch.DrawString(ScreenManager.Font, level.getCurrentLevelName(), getLevelTransitionTextLocation(), Color.White);
            }

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            // *** Only for transitioning from the Main Menu to Level 1. ***
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, false);

            newKeyboardState = Keyboard.GetState();
            newMouseState    = Mouse.GetState();

            shoes.Update(gameTime, ref guy);
            guy.Update(gameTime, ref shoes, ref level);

            if (guy.AreGuyAndShoesCurrentlyLinked && newMouseState.LeftButton == ButtonState.Pressed &&
                !Utilities.movementLockedDueToActivePauseScreen)
            {
                TrajectoryLineHandler.Update(ref guy);
            }

            mouseRect = new Rectangle(newMouseState.X, newMouseState.Y, 16, 16);

            // Handles for if the player hits the Guy with the mouse cursor.
            handleSlappingSoundEffect();

            foreach (Air air in Air.allAirs)
            {
                air.Update(gameTime, ref shoes, ref guy);
            }

            // Hide and display the interface.
            if (!newKeyboardState.IsKeyDown(Keys.F10) && oldKeyboardState.IsKeyDown(Keys.F10))
            {
                if (displayInterface)
                {
                    displayInterface = false;
                }
                else
                {
                    displayInterface = true;
                }
            }

            MusicHandler.FadeOutMusicIfPossible(shoes.stopPlayerInputDueToLevelCompletion);

            // If the player has won the game, play the end of game sound effect.
            playEndOfGameSoundEffectIfPossible();

            // Exit to the main menu if possible.
            exitToMainMenuIfNeeded();

            // If the player presses the 'R' key, reset the player to the beginning of the level.
            restartLevelIfNecessary();

            oldKeyboardState = newKeyboardState;
            oldMouseState    = newMouseState;

            // Gradually fade in or out depending on whether we are covered by the pause screen.
            if (coveredByOtherScreen)
            {
                pauseAlpha = Math.Min(pauseAlpha + 1f / 32, 1);
            }

            else
            {
                pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0);
            }
        }