Exemplo n.º 1
0
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            }

            playGameMenuEntry.prepareToDraw(content, ScreenManager.SpriteBatch, "MainMenu");
            howToPlayMenuEntry.prepareToDraw(content, ScreenManager.SpriteBatch, "MainMenu");
            bonusLevelsMenuEntry.prepareToDraw(content, ScreenManager.SpriteBatch, "MainMenu");
            conceptArtMenuEntry.prepareToDraw(content, ScreenManager.SpriteBatch, "MainMenu");
            exitMenuEntry.prepareToDraw(content, ScreenManager.SpriteBatch, "MainMenu");

            Level.bonusLevelsSelected = false;
            MusicHandler.PlayMusic(-1, ref content);
        }
Exemplo 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);

            // 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
            {
                if (Level.currentLevel != -2)
                {
                    Level.currentLevel = -2;
                    MusicHandler.PlayMusic(-2, ref content);
                }

                pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            }

            backgroundTexture = content.Load <Texture2D>("Sprites/Concept Art/ConceptArt1");

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            // Don't play music on the Concept Art screen.
            MusicHandler.StopMusic();
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Loads the next Level.
        /// </summary>
        public void LoadLevel()
        {
            impassableTileRecs = new List <Rectangle>();
            impassableTilePos  = new List <Vector2>();
            Air.resetAllAirCannons();

            if ((!Level.bonusLevelsSelected && currentLevel + 1 <= 5) || (Level.bonusLevelsSelected && currentLevel + 1 <= totalLevels))
            {
                previousLevel++;
                currentLevel++;
            }
            else
            {
                if (!Level.bonusLevelsSelected)
                {
                    currentLevel  = 0;
                    previousLevel = -1;
                }
                else if (Level.bonusLevelsSelected)
                {
                    currentLevel  = 6;
                    previousLevel = 5;
                }
            }

            MusicHandler.PlayMusic(currentLevel, ref contentManager);

            // This array will store a level. Each element in the array will be
            //  a line of tiles.
            // 0 - ****
            // 1 - ****
            // 2 - ****
            // ...

            // The problem is lines is only getting 45
            // Only goes to 65
            lines = System.IO.File.ReadAllLines("Content/Levels/" + currentLevel.ToString() + ".txt");

            int length = lines.Length;

            // The outer loop goes through the columns.
            for (int column = 0; column < numberOfTileColumns; column++)
            {
                // The inner loop goes through the rows.
                for (int row = 0; row < numberOfTilesInRow; row++)
                {
                    // The first position of the block is (0, 0), followed by (64, 0), (128, 0), etc.
                    // Going up the y axis works the same way. (0, 0), (0, 64), (0, 128), etc.

                    // Create a new tile in each position of the grid. We give Tile() the character in the string 'lines'.
                    tiles[column, row] = new Tile(lines[column][row], ref contentManager);

                    // Set the position of the tile in the Level array.
                    tiles[column, row].PositionInArray = new Vector2(column, row);

                    // Set the position of a new tile.
                    tiles[column, row].Position = new Vector2((row * 16), (column * 16));

                    // Draw a rectangle around the tile. We need this for collision detection.
                    tiles[column, row].SourceRect = new Rectangle((int)tiles[column, row].Position.X, (int)tiles[column, row].Position.Y, 16, 16);

                    // Set the rotation and center for the tile.
                    if (tiles[column, row].IsLauncher || tiles[column, row].IsAirCannon || tiles[column, row].IsAirCannonSwitch)
                    {
                        tiles[column, row].Center   = new Vector2(16 / 2, 16 / 2);
                        tiles[column, row].Rotation = Tile.getRotationInRadians(tiles[column, row]);
                    }
                    else
                    {
                        tiles[column, row].Center = new Vector2(0, 0);
                    }

                    // We are going to store all the impassable tiles rectangles in a list. We will use this for collision detection.
                    if (tiles[column, row].CollProperties == Tile.CollisionProperty.Impassable)
                    {
                        impassableTileRecs.Add(tiles[column, row].SourceRect);
                        impassableTilePos.Add(tiles[column, row].Position);
                    }

                    if (tiles[column, row].TileRepresentation == 'G' || tiles[column, row].TileRepresentation == 'g')
                    {
                        goalRectangle = tiles[column, row].SourceRect;
                    }
                    if (tiles[column, row].TileRepresentation == 'P')
                    {
                        playerStartingPosition = tiles[column, row].Position;
                    }
                }
            }
        }