Example #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);
        }
Example #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);
            }
        }
Example #3
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;
                    }
                }
            }
        }