Пример #1
0
 public void Update()
 {
     //if the player is within the interaction rectangle of the door
     //and they have the proper key, then open the door
     if (InteractionRectangle.Intersects(Player.CollisionRectangle) &&
         CollectablesManager.TryRemoveFromInventory(key, new Vector2(DrawRectangle.Center.X, DrawRectangle.Center.Y)))
     {
         OpenDoor((int)RoomsManager.CurrentRoom);
         AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.CurrentRoom].AddTempAnimatedSprite(
             new AnimatedSprite(new Vector2(position.X, position.Y), AnimatedSprite.GetDoorAnimation(textureType)));
     }
 }
Пример #2
0
 public void Update(float elapsedTime)
 {
     for (int i = collectables.Count - 1; i >= 0; i--)
     {
         if (collectables[i].Collected)
         {
             if (collectables[i].type == Collectable.ItemType.heart)
             {
                 Player.IncreaseHealth();
             }
             else
             {
                 CollectablesManager.AddToInventory(collectables[i]);
             }
             collectables.RemoveAt(i);
         }
         else
         {
             collectables[i].Update(elapsedTime);
         }
     }
 }
Пример #3
0
        //this function check some condition to determine whether an event should be triggered
        static void eventHandler(float elapsedTime)
        {
            switch (RoomsManager.CurrentRoom)
            {
            case RoomsManager.Rooms.tutorial0:
                if (!eventAlreadyHappened[(int)Events.introMonologue])
                {
                    TriggerEvent(Events.introMonologue);
                }
                else if (FinalBoss.Dead && Player.position.X < 200 && Player.position.Y <= 176 - Player.height &&
                         !eventAlreadyHappened[(int)Events.finalMonologue])
                {
                    TriggerEvent(Events.finalMonologue);
                }
                else if (eventAlreadyHappened[(int)Events.finalMonologue] && !MonologuesManager.MonologuePlaying)
                {
                    TriggerEvent(Events.finalCutscene);
                }
                break;

            case RoomsManager.Rooms.tutorial3:
                if (EnemyManager.enemyRoomManagers[(int)RoomsManager.CurrentRoom].enemiesType1[0].Dead &&
                    !eventAlreadyHappened[(int)Events.keySpawns1_tutorial3])
                {
                    TriggerEvent(Events.keySpawns1_tutorial3);
                }
                else if (eventAlreadyHappened[(int)Events.keySpawns1_tutorial3] && !eventAlreadyHappened[(int)Events.key1Collected_tutorial3] &&
                         CollectablesManager.collectedItems.Count == 1)
                {
                    TriggerEvent(Events.key1Collected_tutorial3);
                }
                else if (EnemyManager.enemyRoomManagers[(int)RoomsManager.CurrentRoom].enemiesType1[1].Dead &&
                         !eventAlreadyHappened[(int)Events.keySpawns2_tutorial3])
                {
                    TriggerEvent(Events.keySpawns2_tutorial3);
                }
                else if (eventAlreadyHappened[(int)Events.keySpawns2_tutorial3] && !eventAlreadyHappened[(int)Events.key2Collected_tutorial3] &&
                         CollectablesManager.collectedItems.Count == 1)
                {
                    TriggerEvent(Events.key2Collected_tutorial3);
                }
                break;

            case RoomsManager.Rooms.churchBellTower0:
                if (Player.CollisionRectangle.Intersects(new Rectangle(196, 908, 96, 76)) &&
                    CollectablesManager.TryRemoveFromInventory(Collectable.ItemType.doubleJump_powerup, new Vector2(223, 938)) &&
                    !eventAlreadyHappened[(int)Events.unlockDoubleJump])
                {
                    TriggerEvent(Events.unlockDoubleJump);
                }
                else if (eventAlreadyHappened[(int)Events.unlockDoubleJump] && !eventAlreadyHappened[(int)Events.showDoubleJumpScreen])
                {
                    TriggerEvent(Events.showDoubleJumpScreen);
                }
                else if (Player.CollisionRectangle.Intersects(new Rectangle(196, 908, 96, 76)) &&
                         CollectablesManager.TryRemoveFromInventory(Collectable.ItemType.wallJump_powerup, new Vector2(251, 938)) &&
                         !eventAlreadyHappened[(int)Events.unlockWallJump])
                {
                    TriggerEvent(Events.unlockWallJump);
                }
                else if (eventAlreadyHappened[(int)Events.unlockWallJump] && !eventAlreadyHappened[(int)Events.showWallJumpScreen])
                {
                    TriggerEvent(Events.showWallJumpScreen);
                }
                break;

            case RoomsManager.Rooms.midBoss:
                if (MidBoss.Dead && !eventAlreadyHappened[(int)Events.keyAndPowerUpSpawn_midBoss])
                {
                    TriggerEvent(Events.keyAndPowerUpSpawn_midBoss);
                }
                else if (eventAlreadyHappened[(int)Events.keyAndPowerUpSpawn_midBoss] && CollectablesManager.collectedItems.Count > 0)
                {
                    if (!eventAlreadyHappened[(int)Events.pUpCollected_midBoss])
                    {
                        foreach (Collectable collectable in CollectablesManager.collectedItems)
                        {
                            if (collectable.type == Collectable.ItemType.wallJump_powerup)
                            {
                                TriggerEvent(Events.pUpCollected_midBoss);
                                break;
                            }
                        }
                    }
                }
                break;

            case RoomsManager.Rooms.churchGroundFloor0:
                if (Player.position.X >= 88 - Player.width && Player.position.Y < 178)
                {
                    if (Player.IsOnMovingPlatform && !eventAlreadyHappened[(int)Events.activateMovingPlatforms_churchGroundFloor0])
                    {
                        TriggerEvent(Events.activateMovingPlatforms_churchGroundFloor0);
                    }
                }
                else if (!eventAlreadyHappened[(int)Events.resetMovingPlatforms_churchGroundFloor0])
                {
                    TriggerEvent(Events.resetMovingPlatforms_churchGroundFloor0);
                }
                break;

            case RoomsManager.Rooms.church1stFloor0:
                if ((Player.position.X < 1032 && Player.position.X >= 1000) ||
                    (Player.position.X < 684 && Player.position.X >= 664) ||
                    (Player.position.X < 364 && Player.position.X >= 344 && Player.position.Y > 106))
                {
                    if (!eventAlreadyHappened[(int)Events.showInvisibleTiles_church1stFloor0])
                    {
                        TriggerEvent(Events.showInvisibleTiles_church1stFloor0);
                    }
                }
                else if (!eventAlreadyHappened[(int)Events.hide_InvisibleTiles_church1stFloor0])
                {
                    TriggerEvent(Events.hide_InvisibleTiles_church1stFloor0);
                }
                break;

            case RoomsManager.Rooms.churchAltarRoom:
                if (TorchManager.AllTorchesUnlit() && !eventAlreadyHappened[(int)Events.spawnKey_altar])
                {
                    TriggerEvent(Events.spawnKey_altar);
                }
                else if (eventAlreadyHappened[(int)Events.spawnKey_altar] &&
                         !eventAlreadyHappened[(int)Events.keyCollected_altar] &&
                         CollectablesManager.collectedItems.Count > 0)
                {
                    foreach (Collectable c in CollectablesManager.collectedItems)
                    {
                        if (c.type == Collectable.ItemType.silverKey)
                        {
                            TriggerEvent(Events.keyCollected_altar);
                            break;
                        }
                    }
                }
                break;

            case RoomsManager.Rooms.finalBoss:
                if (Player.position.X <= 200 && !eventAlreadyHappened[(int)Events.terrainCollapseFinalBoss])
                {
                    TriggerEvent(Events.terrainCollapseFinalBoss);
                }
                if (eventAlreadyHappened[(int)Events.terrainCollapseFinalBoss] && !eventAlreadyHappened[(int)Events.finalBossComesAlive])
                {
                    TriggerEvent(Events.finalBossComesAlive);
                }
                if (eventAlreadyHappened[(int)Events.finalBossComesAlive] && !eventAlreadyHappened[(int)Events.activatePlatformsFinalBoss])
                {
                    TriggerEvent(Events.activatePlatformsFinalBoss);
                }
                if (FinalBoss.Dead && !eventAlreadyHappened[(int)Events.escapeFinalBossRoom])
                {
                    TriggerEvent(Events.escapeFinalBossRoom);
                }
                break;

            case RoomsManager.Rooms.escape0:
                if (Player.position.X < 1752 && !eventAlreadyHappened[(int)Events.monologue_escape0])
                {
                    TriggerEvent(Events.monologue_escape0);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 248 && !eventAlreadyHappened[(int)Events.lavaEruption1_escape0])
                {
                    TriggerEvent(Events.lavaEruption1_escape0);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 416 && !eventAlreadyHappened[(int)Events.lowerFloor1_escape0])
                {
                    TriggerEvent(Events.lowerFloor1_escape0);
                }
                if (!PlatformsManager.platformsRoomManagers[(int)RoomsManager.Rooms.escape0].movingPlatforms[1].active &&
                    !eventAlreadyHappened[(int)Events.removeFloor1_escape0] && eventAlreadyHappened[(int)Events.lowerFloor1_escape0])
                {
                    TriggerEvent(Events.removeFloor1_escape0);
                }
                if (eventAlreadyHappened[(int)Events.lowerFloor1_escape0] && !eventAlreadyHappened[(int)Events.lavaEruption2_escape0])
                {
                    TriggerEvent(Events.lavaEruption2_escape0);
                }
                if (eventAlreadyHappened[(int)Events.lavaEruption2_escape0] && !eventAlreadyHappened[(int)Events.lavaEruption3_escape0])
                {
                    TriggerEvent(Events.lavaEruption3_escape0);
                }
                if (eventAlreadyHappened[(int)Events.lavaEruption3_escape0] && !eventAlreadyHappened[(int)Events.lavaEruption4_escape0])
                {
                    TriggerEvent(Events.lavaEruption4_escape0);
                }
                if (eventAlreadyHappened[(int)Events.lowerFloor1_escape0] && !eventAlreadyHappened[(int)Events.raiseFloor2_escape0])
                {
                    TriggerEvent(Events.raiseFloor2_escape0);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1352 && !eventAlreadyHappened[(int)Events.lavaEruption5_escape0])
                {
                    TriggerEvent(Events.lavaEruption5_escape0);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1448 && !eventAlreadyHappened[(int)Events.raiseFloor3_escape0])
                {
                    TriggerEvent(Events.raiseFloor3_escape0);
                }
                if (eventAlreadyHappened[(int)Events.raiseFloor3_escape0] && !eventAlreadyHappened[(int)Events.lavaEruption6_escape0])
                {
                    TriggerEvent(Events.lavaEruption6_escape0);
                }
                break;

            case RoomsManager.Rooms.escape1:
                if (Player.IsOnMovingPlatform && !eventAlreadyHappened[(int)Events.activatePlatform_escape1])
                {
                    TriggerEvent(Events.activatePlatform_escape1);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape1].RoomWidthtPx - 881 && !eventAlreadyHappened[(int)Events.raiseFloor1_escape1])
                {
                    TriggerEvent(Events.raiseFloor1_escape1);
                }
                if (Player.position.X < 104 && !eventAlreadyHappened[(int)Events.lavaEruption1_escape1])
                {
                    TriggerEvent(Events.lavaEruption1_escape1);
                }
                break;

            case RoomsManager.Rooms.escape2:
                if (Player.position.X + Player.width < 424)
                {
                    if (!eventAlreadyHappened[(int)Events.lavaEruption_escape2])
                    {
                        TriggerEvent(Events.lavaEruption_escape2);
                    }
                    else
                    {
                        eventAlreadyHappened[(int)Events.lavaEruption_escape2] = false;
                    }
                }
                break;
            }
        }
Пример #4
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            //drawing code here
#if LEVEL_EDITOR
            GraphicsDevice.SetRenderTarget(nativeRenderTarget);
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin();
            levelEditor.Draw(spriteBatch, tilesPerRow, infoBoxHeightPx, editorWidth, editorHeight);
            PlatformsManager.platformsRoomManagers[levelEditor.currentRoomNumber].Draw(spriteBatch);
            MouseState mouseState = Mouse.GetState();
            spriteBatch.DrawString(spriteFont, (mouseState.X / 4 + (int)Camera.position.X) + "," + (mouseState.Y / 4 + (int)Camera.position.Y), new Vector2(10, 10), Color.Blue);
            spriteBatch.End();
            GraphicsDevice.SetRenderTarget(null);
            spriteBatch.Begin(samplerState: SamplerState.PointClamp);
            spriteBatch.Draw(nativeRenderTarget, viewportRectangle, Color.White);
            levelEditor.DrawText(spriteBatch, infoBoxHeightPx);

            spriteBatch.End();
#else
            //draw only relevant classes depending on the state of the game
            spriteBatch.Begin();
            switch (currentGameState)
            {
            case GameStates.titleScreen:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                MenusManager.menus[(int)MenusManager.MenuType.titleScreen].Draw(spriteBatch);
                break;

            case GameStates.controls:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                MenusManager.menus[(int)MenusManager.MenuType.controls].Draw(spriteBatch);
                break;

            case GameStates.achievements:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                MenusManager.menus[(int)MenusManager.MenuType.achievements].Draw(spriteBatch);
                Achievements.Draw(spriteBatch);
                break;

            case GameStates.credits:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                MenusManager.menus[(int)MenusManager.MenuType.credits].Draw(spriteBatch);
                break;

            case GameStates.intro:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.intro].Draw(spriteBatch);
                break;

            case GameStates.playing:
                GraphicsDevice.SetRenderTarget(nativeRenderTarget);
                GraphicsDevice.Clear(Color.Black);
                Camera.Draw(spriteBatch);
                RoomsManager.Draw(spriteBatch);
                CollectablesManager.Draw(spriteBatch);
                Player.DrawGUI(spriteBatch);
                break;

            case GameStates.pause:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                MenusManager.menus[(int)MenusManager.MenuType.pause].Draw(spriteBatch);
                break;

            case GameStates.dead:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                Camera.Draw(spriteBatch);
                RoomsManager.Draw(spriteBatch);
                PlayerDeathManager.Draw(spriteBatch);
                break;

            case GameStates.ending:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.ending].Draw(spriteBatch);
                break;

            case GameStates.confirmQuit:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                MenusManager.menus[(int)MenusManager.MenuType.confirmQuit].Draw(spriteBatch);
                break;

            case GameStates.doubleJump:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                Camera.Draw(spriteBatch);
                RoomsManager.Draw(spriteBatch);
                MenusManager.menus[(int)MenusManager.MenuType.doubleJump].Draw(spriteBatch);
                break;

            case GameStates.wallJump:
                GraphicsDevice.SetRenderTarget(renderTarget_zoom1);
                GraphicsDevice.Clear(Color.Black);
                Camera.Draw(spriteBatch);
                RoomsManager.Draw(spriteBatch);
                MenusManager.menus[(int)MenusManager.MenuType.wallJump].Draw(spriteBatch);
                break;
            }

            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);
            spriteBatch.Begin(samplerState: SamplerState.PointClamp);
            if (currentGameState == GameStates.playing)
            {
                spriteBatch.Draw(nativeRenderTarget, viewportRectangle, Color.White);
            }
            else
            {
                spriteBatch.Draw(renderTarget_zoom1, viewportRectangle, Color.White);
            }

            spriteBatch.End();
#endif
            base.Draw(gameTime);
        }
Пример #5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            currentKeyboard   = Keyboard.GetState();
            currentGamePad    = GamePad.GetState(PlayerIndex.One);
            currentMouseState = Mouse.GetState();
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            //update logic here
#if LEVEL_EDITOR
            levelEditor.Update(currentMouseState, previousMouseState, tilesPerRow, infoBoxHeightPx);
            CameraManager.Update(elapsedTime);
            PlatformsManager.platformsRoomManagers[levelEditor.currentRoomNumber].Update(elapsedTime);
#else
            //update only relevant classes depending on the state of the game
            switch (currentGameState)
            {
            case GameStates.titleScreen:
                if (!gameInitialized)
                {
                    LoadContent();
                }
                MenusManager.menus[(int)MenusManager.MenuType.titleScreen].Update();
                break;

            case GameStates.loadGame:
                if (LoadSaveManager.LoadGame())
                {
                    currentGameState = GameStates.playing;
                }
                else
                {
                    currentGameState = GameStates.titleScreen;
                }
                break;

            case GameStates.controls:
                MenusManager.menus[(int)MenusManager.MenuType.controls].Update();
                break;

            case GameStates.achievements:
                MenusManager.menus[(int)MenusManager.MenuType.achievements].Update();
                break;

            case GameStates.credits:
                MenusManager.menus[(int)MenusManager.MenuType.credits].Update();
                break;

            case GameStates.intro:
                if (CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.intro].active)
                {
                    CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.intro].Update(elapsedTime);
                }
                else
                {
                    currentGameState = GameStates.playing;
                }
                break;

            case GameStates.playing:
                GameStats.Update(elapsedTime);
                if ((currentKeyboard.IsKeyDown(Keys.P) && !previousKeyboard.IsKeyDown(Keys.P)) ||
                    (currentKeyboard.IsKeyDown(Keys.M) && !previousKeyboard.IsKeyDown(Keys.M)) ||
                    (currentGamePad.Buttons.Start == ButtonState.Pressed && previousGamePad.Buttons.Start == ButtonState.Released))
                {
                    currentGameState = GameStates.pause;
                    break;
                }
                RoomsManager.Update(elapsedTime);
                Player.Update(elapsedTime);
                ProjectilesManager.Update(elapsedTime);
                GameEvents.Update(elapsedTime);
                Collisions.Update(elapsedTime);
                CollectablesManager.Update(elapsedTime);
                break;

            case GameStates.pause:
                if ((currentKeyboard.IsKeyDown(Keys.P) && !previousKeyboard.IsKeyDown(Keys.P)) ||
                    (currentKeyboard.IsKeyDown(Keys.M) && !previousKeyboard.IsKeyDown(Keys.M)) ||
                    (currentGamePad.Buttons.Start == ButtonState.Pressed && previousGamePad.Buttons.Start == ButtonState.Released))
                {
                    MenusManager.menus[(int)MenusManager.MenuType.pause].Reset();
                    currentGameState = GameStates.playing;
                    break;
                }
                MenusManager.menus[(int)MenusManager.MenuType.pause].Update();
                break;

            case GameStates.confirmQuit:
                MenusManager.menus[(int)MenusManager.MenuType.confirmQuit].Update();
                if (currentGameState == GameStates.titleScreen)
                {
                    gameInitialized = false;
                }
                break;

            case GameStates.dead:
                GameStats.Update(elapsedTime);
                PlayerDeathManager.Update(elapsedTime);
                break;

            case GameStates.ending:
                if (!CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.ending].active)
                {
                    LoadSaveManager.SaveHighScores(new AchievementsSaveData
                                                       (true,
                                                       (GameStats.deathsCount == 0) || Achievements.noDeath,
                                                       (GameStats.hitsCount == 0) || Achievements.noHits,
                                                       ((GameStats.gameTime < Achievements.bestTime) || (Achievements.bestTime == 0)) ? GameStats.gameTime : Achievements.bestTime
                                                       ));;
                    LoadSaveManager.DeleteSaveFile();
                    currentGameState = GameStates.achievements;
                    gameInitialized  = false;
                }
                CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.ending].Update(elapsedTime);
                break;

            case GameStates.quit:
                Exit();
                break;

            case GameStates.doubleJump:
                MenusManager.menus[(int)MenusManager.MenuType.doubleJump].Update();
                break;

            case GameStates.wallJump:
                MenusManager.menus[(int)MenusManager.MenuType.wallJump].Update();
                break;
            }
#endif
            previousKeyboard   = currentKeyboard;
            previousGamePad    = currentGamePad;
            previousMouseState = currentMouseState;
            base.Update(gameTime);
        }
Пример #6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

#if LEVEL_EDITOR
            MapsManager.Inizialize(Content.Load <Texture2D>("tiles"));
            CameraManager.Inizialize
            (
                new Texture2D[(int)RoomsManager.Rooms.total]
            {
                Content.Load <Texture2D>(@"backgrounds\tutorial0"),
                Content.Load <Texture2D>(@"backgrounds\tutorial1"),
                Content.Load <Texture2D>(@"backgrounds\tutorial2"),
                Content.Load <Texture2D>(@"backgrounds\tutorial3"),
                Content.Load <Texture2D>(@"backgrounds\tutorial4"),
                Content.Load <Texture2D>(@"backgrounds\bellTower0"),
                Content.Load <Texture2D>(@"backgrounds\bellTower1"),
                Content.Load <Texture2D>(@"backgrounds\bellTower2"),
                Content.Load <Texture2D>(@"backgrounds\midBoss"),
                Content.Load <Texture2D>(@"backgrounds\groundFloor"),
                Content.Load <Texture2D>(@"backgrounds\altarRoom"),
                Content.Load <Texture2D>(@"backgrounds\firstFloor"),
                Content.Load <Texture2D>(@"backgrounds\secondFloor"),
                Content.Load <Texture2D>(@"backgrounds\descent"),
                Content.Load <Texture2D>(@"backgrounds\finalBoss"),
                Content.Load <Texture2D>(@"backgrounds\escape0"),
                Content.Load <Texture2D>(@"backgrounds\escape1"),
                Content.Load <Texture2D>(@"backgrounds\escape2"),
            }
            );
            spriteFont = Content.Load <SpriteFont>(@"fonts\monologue");
            PlatformsManager.Inizialize(Content.Load <Texture2D>("platforms"));
            levelEditor = new LevelEditor(Content.Load <SpriteFont>(@"fonts\arial32"),
                                          Content.Load <SpriteFont>(@"fonts\arial14"),
                                          Content.Load <Texture2D>("whiteTile"));
#else
            //load the game assets here
            currentGameState = GameStates.titleScreen;
            LoadSaveManager.Inizialize();
            GameStats.Inizialize();
            Achievements.Initialize(Content.Load <SpriteFont>(@"fonts\monologue"),
                                    Content.Load <SpriteFont>(@"fonts\LiberationMono12"));
            MapsManager.Inizialize(Content.Load <Texture2D>("tiles"));
            CameraManager.Inizialize
            (
                new Texture2D[(int)RoomsManager.Rooms.total]
            {
                Content.Load <Texture2D>(@"backgrounds\tutorial0"),
                Content.Load <Texture2D>(@"backgrounds\tutorial1"),
                Content.Load <Texture2D>(@"backgrounds\tutorial2"),
                Content.Load <Texture2D>(@"backgrounds\tutorial3"),
                Content.Load <Texture2D>(@"backgrounds\tutorial4"),
                Content.Load <Texture2D>(@"backgrounds\bellTower0"),
                Content.Load <Texture2D>(@"backgrounds\bellTower1"),
                Content.Load <Texture2D>(@"backgrounds\bellTower2"),
                Content.Load <Texture2D>(@"backgrounds\midBoss"),
                Content.Load <Texture2D>(@"backgrounds\groundFloor"),
                Content.Load <Texture2D>(@"backgrounds\altarRoom"),
                Content.Load <Texture2D>(@"backgrounds\firstFloor"),
                Content.Load <Texture2D>(@"backgrounds\secondFloor"),
                Content.Load <Texture2D>(@"backgrounds\descent"),
                Content.Load <Texture2D>(@"backgrounds\finalBoss"),
                Content.Load <Texture2D>(@"backgrounds\escape0"),
                Content.Load <Texture2D>(@"backgrounds\escape1"),
                Content.Load <Texture2D>(@"backgrounds\escape2"),
            }
            );
            PlatformsManager.Inizialize(Content.Load <Texture2D>("platforms"));
            ProjectilesManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            Player.Inizialize(Content.Load <Texture2D>(@"characters\player"), new Vector2(16, 185));
            RoomsManager.Inizialize();
            GameEvents.Inizialize();
            FireBallsManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            LavaGeyserManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            EnemyManager.Initialise(Content.Load <Texture2D>(@"characters\enemy1"), Content.Load <Texture2D>(@"characters\enemy2"));
            MidBoss.Initialise(Content.Load <Texture2D>(@"characters\midboss"));
            FinalBoss.Inizialize(Content.Load <Texture2D>(@"characters\finalBoss"),
                                 new Texture2D[] { Content.Load <Texture2D>(@"characters\stoneWing"),
                                                   Content.Load <Texture2D>(@"characters\healthyWing"),
                                                   Content.Load <Texture2D>(@"characters\damagedWing"),
                                                   Content.Load <Texture2D>(@"characters\deadWing") });
            CollectablesManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            MonologuesManager.Inizialize(Content.Load <Texture2D>("animatedSprites"),
                                         Content.Load <SpriteFont>(@"fonts\monologue"));
            DoorsManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            AnimatedSpritesManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            TorchManager.Initialize(Content.Load <Texture2D>("firePot"));
            PlayerDeathManager.Initialize(Content.Load <Texture2D>(@"menus\deathScreen"),
                                          Content.Load <Texture2D>(@"menus\menuOptions"));
            MenusManager.Initialize(Content.Load <Texture2D>(@"menus\menuOptions"),
                                    new Texture2D[]
            {
                Content.Load <Texture2D>(@"menus\titleScreen"),
                Content.Load <Texture2D>(@"menus\controls"),
                Content.Load <Texture2D>(@"menus\credits"),
                Content.Load <Texture2D>(@"menus\pause"),
                Content.Load <Texture2D>(@"menus\quit"),
                Content.Load <Texture2D>(@"menus\doubleJump"),
                Content.Load <Texture2D>(@"menus\wallJump"),
                Content.Load <Texture2D>(@"menus\achievements"),
            });
            CutscenesManager.Initialize(Content.Load <Texture2D>(@"characters\enemy1"),
                                        Content.Load <Texture2D>(@"characters\player"),
                                        Content.Load <SpriteFont>(@"fonts\monologue"));
            SoundEffects.Initialise
            (
                //Player Sound Effects
                Content.Load <SoundEffect>(@"sounds\pJump"),
                Content.Load <SoundEffect>(@"sounds\pShoot"),
                Content.Load <SoundEffect>(@"sounds\pHurt"),
                Content.Load <SoundEffect>(@"sounds\pickup"),

                //Enemy Sound Effects
                Content.Load <SoundEffect>(@"sounds\enemyAttack"),
                Content.Load <SoundEffect>(@"sounds\enemyHurt"),
                Content.Load <SoundEffect>(@"sounds\e2Attack"),

                //Midboss Sound Effects
                Content.Load <SoundEffect>(@"sounds\midMove"),
                Content.Load <SoundEffect>(@"sounds\midAttack"),
                Content.Load <SoundEffect>(@"sounds\midHurt"),

                Content.Load <SoundEffect>(@"sounds\finAttack"),
                Content.Load <SoundEffect>(@"sounds\finHurt"),
                Content.Load <SoundEffect>(@"sounds\finAwaken"),
                Content.Load <SoundEffect>(@"sounds\finRecover"),
                Content.Load <Song>(@"sounds\finalBossMusic")
            );
            gameInitialized = true;
            Zoom1();
#endif
        }
Пример #7
0
        public void ApplySaveData()
        {
            GameStats.Inizialize(gameTime, deathsCount, hitsCount);
            FinalBoss.Dead            = finalBossDead;
            MidBoss.Dead              = midBossDead;
            RoomsManager.CurrentRoom  = (RoomsManager.Rooms)currentRoom;
            RoomsManager.PreviousRoom = (RoomsManager.Rooms)previousRoom;
            Player.healthPoints       = health;
            Player.position           = new Vector2(playerPosition[0], playerPosition[1]);
            if (eventAlreadyHappened[(int)GameEvents.Events.unlockDoubleJump])
            {//enable double jump if it was already unlocked
                Player.doubleJumpUnlocked = true;
                AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.Rooms.churchBellTower0].AddTempAnimatedSprite(
                    new AnimatedSprite(new Vector2(211, 926), AnimatedSprite.AnimationType.displayDoubleJumpRelic, false));
            }
            if (eventAlreadyHappened[(int)GameEvents.Events.unlockWallJump])
            {//enable wall jump if it was already unlocked
                Player.wallJumpUnlocked = true;
                AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.Rooms.churchBellTower0].AddTempAnimatedSprite(
                    new AnimatedSprite(new Vector2(239, 926), AnimatedSprite.AnimationType.displayWallJumpRelic, false));
            }
            foreach (CollectablesRoomManager r in CollectablesManager.collectablesRoomManagers)
            {//remove collectables already collected
                for (int i = 0; i < r.collectables.Count; i++)
                {
                    bool delete = true;
                    foreach (int j in itemsOnMap)
                    {
                        if (r.collectables[i].ID == j || r.collectables[i].ID == -1)
                        {
                            delete = false;
                            break;
                        }
                    }
                    if (delete)
                    {
                        r.collectables.RemoveAt(i);
                        i--;
                    }
                }
            }
            CollectablesManager.collectedItems.Clear();
            foreach (int i in itemsInInventory)
            {//place items in inventory
                CollectablesManager.AddToInventory(new Collectable(Point.Zero, (Collectable.ItemType)i));
            }
            int room = 0;

            foreach (DoorsRoomManager r in DoorsManager.doorsRoomManagers)
            {//remove doors that have been opend already
                for (int i = 0; i < r.doors.Count; i++)
                {
                    bool delete = true;
                    foreach (int j in closedDoor)
                    {
                        if (r.doors[i].ID == j)
                        {
                            delete = false;
                            break;
                        }
                    }
                    if (delete)
                    {
                        r.doors[i].OpenDoor(room);
                        r.doors.RemoveAt(i);
                        i--;
                    }
                }
                room++;
            }
            GameEvents.eventAlreadyHappened = eventAlreadyHappened;
            PlayerDeathManager.ResetVariables();
            CameraManager.SwitchCamera(RoomsManager.CurrentRoom);
        }
Пример #8
0
        public static void ResetVariables()
        {//reposition the player and reset some classes to their intial state
            Player.IsOnMovingPlatform = false;
            elapsedTimeBeforeResuming = 0;
            Game1.currentGameState    = Game1.GameStates.playing;
            CameraManager.Reset();
            LavaGeyserManager.Reset();
            FireBallsManager.Reset();
            ProjectilesManager.Reset();
            EnemyManager.Reset();
            if (!MidBoss.Dead)
            {
                MidBoss.Reset();
            }
            CollectablesManager.ResetHearts();
            GameEvents.Reset();
            switch (RoomsManager.CurrentRoom)
            {
            case RoomsManager.Rooms.tutorial0:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial4)
                {
                    Player.position = new Vector2(152, 192);
                }
                else if (RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial1)
                {
                    Player.position = new Vector2(903, 185);
                }
                else
                {
                    Player.position = new Vector2(152, 150);
                }
                break;

            case RoomsManager.Rooms.tutorial1:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial0)
                {
                    Player.position = new Vector2(18, 185);
                }
                else
                {
                    Player.position = new Vector2(550, 193);
                }
                break;

            case RoomsManager.Rooms.tutorial2:
                if (Player.position.Y < 80 && RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial1 &&
                    (Player.position.X < 366 || Player.position.X > 426))
                {
                    RoomsManager.CurrentRoom  = RoomsManager.Rooms.tutorial1;
                    RoomsManager.PreviousRoom = RoomsManager.Rooms.tutorial0;
                    CameraManager.SwitchCamera(RoomsManager.Rooms.tutorial1);
                    Player.position = new Vector2(18, 185);
                }
                else
                {
                    Player.position = new Vector2(388, 153);
                }
                break;

            case RoomsManager.Rooms.tutorial3:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower0)
                {
                    Player.position = new Vector2(776, 193);
                }
                else
                {
                    Player.position = new Vector2(91, 193);
                }
                break;

            case RoomsManager.Rooms.tutorial4:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.escape2)
                {
                    Player.position = new Vector2(64, 153);
                }
                else
                {
                    Player.position = new Vector2(166, 153);
                }
                break;

            case RoomsManager.Rooms.churchBellTower0:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower1)
                {
                    if (Player.position.X < 436 && Player.position.X >= 60)
                    {
                        Player.position = new Vector2(405, 161);
                    }
                    else if (Player.position.X >= 436)
                    {
                        Player.position = new Vector2(456, 961);
                    }
                    else
                    {
                        Player.position = new Vector2(23, 961);
                    }
                }
                else if (RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial3)
                {
                    Player.position = new Vector2(23, 961);
                }
                else
                {
                    Player.position = new Vector2(456, 961);
                }
                break;

            case RoomsManager.Rooms.churchBellTower1:
                if (Player.position.X >= 436)
                {
                    Player.position = new Vector2(458, 1097);
                }
                else if (Player.position.X < 60)
                {
                    Player.position = new Vector2(23, 1097);
                }
                else
                {
                    if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower0)
                    {
                        Player.position = new Vector2(372, 1097);
                    }
                    else
                    {
                        Player.position = new Vector2(111, 121);
                    }
                }
                break;

            case RoomsManager.Rooms.churchBellTower2:
                if (Player.position.X >= 436 && Player.position.Y > 110)
                {
                    Player.position = new Vector2(464, 1177);
                }
                else if (Player.position.X >= 60)
                {
                    if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower1)
                    {
                        Player.position = new Vector2(119, 1177);
                    }
                    else
                    {
                        Player.position = new Vector2(457, 65);
                    }
                }
                else
                {
                    Player.position = new Vector2(23, 1177);
                }
                break;

            case RoomsManager.Rooms.midBoss:
                Player.position = new Vector2(452, 25);
                break;

            case RoomsManager.Rooms.churchGroundFloor0:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower0)
                {
                    Player.position = new Vector2(22, 465);
                }
                else
                {
                    Player.position = new Vector2(1160, 465);
                }
                break;

            case RoomsManager.Rooms.churchAltarRoom:
                if (Player.position.X < 104)
                {
                    Player.position = new Vector2(22, 465);
                }
                else
                {
                    Player.position = new Vector2(250, 465);
                }
                break;

            case RoomsManager.Rooms.church1stFloor0:
                if (Player.position.X < 1288)
                {
                    if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchAltarRoom)
                    {
                        Player.position = new Vector2(1208, 217);
                    }
                    else
                    {
                        Player.position = new Vector2(18, 217);
                    }
                }
                else
                {
                    Player.position = new Vector2(1320, 217);
                }
                break;

            case RoomsManager.Rooms.church2ndFloor0:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower0)
                {
                    Player.position = new Vector2(37, 481);
                }
                else
                {
                    Player.position = new Vector2(1289, 481);
                }
                break;

            case RoomsManager.Rooms.descent:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchAltarRoom)
                {
                    Player.position = new Vector2(339, 121);
                }
                else
                {
                    Player.position = new Vector2(318, 233);
                }
                break;

            case RoomsManager.Rooms.finalBoss:
                Game1.Zoom0Dot5();
                MediaPlayer.Stop();
                if (!FinalBoss.Dead)
                {
                    Player.position = new Vector2(734, 41);
                }
                else
                {
                    Player.position = new Vector2(17, 41);
                }
                break;

            case RoomsManager.Rooms.escape0:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.finalBoss)
                {
                    Player.position = new Vector2(1726, 129);
                }
                else
                {
                    Player.position = new Vector2(18, 49);
                }
                break;

            case RoomsManager.Rooms.escape1:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.escape0)
                {
                    Player.position = new Vector2(1320, 89);
                }
                else
                {
                    Player.position = new Vector2(12, 289);
                }
                break;

            case RoomsManager.Rooms.escape2:
                if (RoomsManager.PreviousRoom == RoomsManager.Rooms.escape1)
                {
                    Player.position = new Vector2(500, 289);
                }
                else
                {
                    Player.position = new Vector2(21, 129);
                }
                break;
            }
        }