//Function to handle the boss death public static void Death() { if (bossAnimations[(int)bossState] != bossAnimations[(int)BossState.death]) { SoundEffects.MidbossHurt.Play(); bossAnimations[(int)bossState] = bossAnimations[(int)BossState.death]; } else if (!bossAnimations[(int)bossState].Active) { dead = true; LoadSaveManager.SaveGameProgress(); bossPoint = new Vector2(-bossWidth, -bossHeight); } }
public static void Update(float elapsedTime) { if (elapsedTimeBeforeResuming < timeBeforeResuming) { elapsedTimeBeforeResuming += elapsedTime; alphaValue = MathHelper.Lerp(0, 1, elapsedTimeBeforeResuming / timeBeforeResuming); if (elapsedTimeBeforeResuming >= timeBeforeResuming) { alphaValue = 1; } return; } else if (Game1.currentKeyboard.IsKeyDown(Keys.Enter) || (Game1.currentGamePad.Buttons.A == ButtonState.Pressed)) { Player.ReplenishHealth(); ResetVariables(); LoadSaveManager.SaveGameProgress(); } }
public static void Update(float elapsedTime) { if (switchRoom()) LoadSaveManager.SaveGameProgress(); CameraManager.Update(elapsedTime); MapsManager.maps[(int)currentRoom].Update(elapsedTime); if (currentRoom== Rooms.finalBoss) { FinalBoss.Update(elapsedTime); } if(currentRoom==Rooms.midBoss) { MidBoss.Update(elapsedTime); } EnemyManager.enemyRoomManagers[(int)currentRoom].Update(elapsedTime); FireBallsManager.Update(elapsedTime); LavaGeyserManager.Update(elapsedTime); PlatformsManager.platformsRoomManagers[(int)currentRoom].Update(elapsedTime); CollectablesManager.collectablesRoomManagers[(int)currentRoom].Update(elapsedTime); MonologuesManager.monologuesRoomManagers[(int)currentRoom].Update(elapsedTime); DoorsManager.doorsRoomManagers[(int)currentRoom].Update(); AnimatedSpritesManager.animatedSpritesRoomManagers[(int)currentRoom].Update(elapsedTime); TorchManager.Update(elapsedTime); }
/// <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); }
/// <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 }
public static void Update(float elapsedTime) { if (dead || bossAnimation == BossAnimations.stone) { return; //do not update if boss is dead } if (bossAnimation != BossAnimations.stone && bossAnimation != BossAnimations.stoneToIdle && bossAnimation != BossAnimations.falling) { //oscillatory motion bossMidPoint.Y += YSpeed; YSpeed += (bossInitialMidPoint.Y - bossMidPoint.Y) * 0.2f * elapsedTime; } bossAnimations[(int)bossAnimation].Update(elapsedTime); rightWingAnimations[(int)rightWingAnimation].Update(elapsedTime); leftWingAnimations[(int)leftWingAnimation].Update(elapsedTime); if (!bossAnimations[(int)bossAnimation].Active) {//if an animation has stopped playing because the last frame was reached //decide what animation should be played next if (bossAnimation == BossAnimations.startRecovering) { bossAnimation = BossAnimations.recovering; rightWingAnimation = WingAnimations.flap; leftWingAnimation = WingAnimations.flap; bossAnimations[(int)bossAnimation].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else { bossAnimation = BossAnimations.idle; rightWingAnimation = WingAnimations.idle; leftWingAnimation = WingAnimations.idle; if (rightWingTexture == WingTextures.stone || leftWingTexture == WingTextures.stone) { rightWingTexture = WingTextures.healthy; leftWingTexture = WingTextures.healthy; } bossAnimations[(int)bossAnimation].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } } //finate state machine determing the boss AI switch (bossAnimation) { case BossAnimations.stone: break; case BossAnimations.stoneToIdle: break; case BossAnimations.idle: //if the boss is in th eidle state, then it is ready to attack //the attacks available depend on the phace of the battle //the battle progresses to the next phase each time a wing is hit if (!bossAnimations[(int)bossAnimation].IsLastFrame()) { break; } switch (currentPhase) { case Phases.one: { if (bossHP <= 0) { bossAnimation = BossAnimations.startRecovering; bossAnimations[(int)BossAnimations.startRecovering].Reset(); LavaGeyserManager.Reset(); FireBallsManager.Reset(); rightWingAnimation = WingAnimations.spread; leftWingAnimation = WingAnimations.spread; rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); break; } if (FireBallsManager.NumberOfActiveFireballs > 0 || LavaGeyserManager.ActiveLavaGeysers > 0) { break; } int attack = rand.Next(4); if (attack == 0) { FireBallsManager.ThrowAtPlayer((int)MathHelper.Lerp(3, 6, 1 - (float)bossHP / maxBossHp), 2 + (float)rand.NextDouble(), 1f); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else if (attack == 1) { FireBallsManager.ThrowInAllDirections((int)MathHelper.Lerp(3, 7, 1 - (float)bossHP / maxBossHp), FireBall.radialShootingVelocity, (float)(0.5 + rand.NextDouble())); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else if (attack == 2) { int num = (int)MathHelper.Lerp(2, 4, 1 - (float)bossHP / maxBossHp); int[] platforms = new int[num]; for (int i = 0; i < num; i++) { int nextPlatform = rand.Next(PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms.Length - 1); while (platforms.Contains(nextPlatform)) { nextPlatform = (nextPlatform + 1) % (PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms.Length - 1); } platforms[i] = nextPlatform; } FireBallsManager.TargetPlatform(platforms, 6, 2); FireBallsManager.AddGhostFireball(7); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else { FireBallsManager.Sweep((float)(0.4 + 0.2 * rand.NextDouble()), rand.Next(3, 5)); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } SoundEffects.FinalBossAttack.Play(); break; } case Phases.two: { if (bossHP <= 0) { bossAnimation = BossAnimations.startRecovering; bossAnimations[(int)BossAnimations.startRecovering].Reset(); LavaGeyserManager.Reset(); FireBallsManager.Reset(); rightWingAnimation = WingAnimations.spread; leftWingAnimation = WingAnimations.spread; rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); break; } if (FireBallsManager.NumberOfActiveFireballs > 0 || LavaGeyserManager.ActiveLavaGeysers > 0) { break; } int attack = rand.Next(3); if (attack == 0) { attack = rand.Next(2); if (attack == 0) { FireBallsManager.ThrowAtPlayer((int)MathHelper.Lerp(4, 9, 1 - (float)bossHP / maxBossHp), (float)(3 + rand.NextDouble()), 1f); } else { FireBallsManager.ThrowInAllDirections(6, FireBall.radialShootingVelocity, (float)(1 + rand.NextDouble())); } int num = (int)MathHelper.Lerp(2, 4, 1 - (float)bossHP / maxBossHp); int[] platforms = new int[num]; for (int i = 0; i < num; i++) { int nextPlatform = rand.Next(PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms.Length - 1); while (platforms.Contains(nextPlatform)) { nextPlatform = (nextPlatform + 1) % (PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms.Length - 1); } platforms[i] = nextPlatform; } FireBallsManager.TargetPlatform(platforms, 6, 2); FireBallsManager.AddGhostFireball(7); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else if (attack == 1) { float angle = MathHelper.Lerp(90, 180, 1 - (float)bossHP / maxBossHp); FireBallsManager.TrowWithinCircularSector( (int)(angle / 6), FireBall.radialShootingVelocity * 0.8f, (float)(0.25 + 0.5 * rand.NextDouble()), angle); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else { FireBallsManager.RandomSweep((float)(1.0f + 0.2 * rand.NextDouble()), 2, 4); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } SoundEffects.FinalBossAttack.Play(); break; } case Phases.three: { if (bossHP <= 0) { bossAnimation = BossAnimations.startRecovering; bossAnimations[(int)BossAnimations.startRecovering].Reset(); LavaGeyserManager.Reset(); FireBallsManager.Reset(); rightWingAnimation = WingAnimations.spread; leftWingAnimation = WingAnimations.spread; rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); break; } if (FireBallsManager.NumberOfActiveFireballs > 0 || LavaGeyserManager.ActiveLavaGeysers > 0) { break; } int attack = rand.Next(4); if (attack == 0) { attack = rand.Next(2); if (attack == 0) { int num = 2; int[] platforms = new int[num]; for (int i = 0; i < num; i++) { int nextPlatform = rand.Next(PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms.Length - 1); while (platforms.Contains(nextPlatform)) { nextPlatform = (nextPlatform + 1) % (PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms.Length - 1); } platforms[i] = nextPlatform; } FireBallsManager.TargetPlatform(platforms, 6, 2); FireBallsManager.AddGhostFireball(7); } else { FireBallsManager.ThrowAtPlayer(4, (float)(3 + rand.NextDouble()), 1f); } LavaGeyserManager.ShootGeyser( new float[] { rand.Next((int)fireballsCenter.X - 200, (int)fireballsCenter.X + 200), rand.Next((int)fireballsCenter.X - 200, (int)fireballsCenter.X + 200), }, 3); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else if (attack == 1) { int num = 3; int[] platforms = new int[num]; for (int i = 0; i < num; i++) { int nextPlatform = rand.Next(PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms.Length - 1); while (platforms.Contains(nextPlatform)) { nextPlatform = (nextPlatform + 1) % (PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms.Length - 1); } platforms[i] = nextPlatform; } FireBallsManager.TargetPlatform(platforms, 6, 5); FireBallsManager.TrowWithinCircularSector( 20, FireBall.radialShootingVelocity * 0.8f, (float)(0.5 + 0.1 * rand.NextDouble()), 120); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else if (attack == 2) { FireBallsManager.Spiral(30, 20, MathHelper.Lerp(0.3f, 0.5f, (float)bossHP / maxBossHp), FireBall.radialShootingVelocity * 0.4f); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else { LavaGeyserManager.EquallySpaced(LavaGeyser.size * 7, 2, 0); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } SoundEffects.FinalBossAttack.Play(); break; } case Phases.four: { if (bossHP <= 0) { bossAnimation = BossAnimations.startRecovering; bossAnimations[(int)BossAnimations.startRecovering].Reset(); LavaGeyserManager.Reset(); FireBallsManager.Reset(); rightWingAnimation = WingAnimations.spread; leftWingAnimation = WingAnimations.spread; rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); break; } if (FireBallsManager.NumberOfActiveFireballs > 0 || LavaGeyserManager.ActiveLavaGeysers > 0) { break; } int attack = rand.Next(3); if (attack == 0) { FireBallsManager.Sweep((float)(0.4 + 0.2 * rand.NextDouble()), 10); LavaGeyserManager.SweepAcross( 1, 0.5f, (int)MathHelper.Lerp(4, 10, (float)bossHP / maxBossHp), 244, 524, rand.Next(2) == 0); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else if (attack == 1) { FireBallsManager.TrowWithinCircularSector( (int)(20), FireBall.radialShootingVelocity * 0.8f, (float)(0.25 + 0.5 * rand.NextDouble()), 120); LavaGeyserManager.EquallySpaced(LavaGeyser.size * 6, 2, LavaGeyser.size * 6 * (float)rand.NextDouble()); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } else { LavaGeyserManager.ShootGeyser( new float[] { rand.Next((int)fireballsCenter.X - 200, (int)fireballsCenter.X + 200), rand.Next((int)fireballsCenter.X - 200, (int)fireballsCenter.X + 200), }, 3); FireBallsManager.Spiral(30, 20, 0.3f, FireBall.radialShootingVelocity * 0.4f); bossAnimation = BossAnimations.attack; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } SoundEffects.FinalBossAttack.Play(); break; } } break; case BossAnimations.attack: //the boss is attacking elapsedAttackAnimationTime += elapsedTime; if (elapsedAttackAnimationTime >= attackAnimationTime) { elapsedAttackAnimationTime = 0; bossAnimation = BossAnimations.idle; bossAnimations[(int)BossAnimations.idle].Reset(); bossAnimations[(int)BossAnimations.endRecovering].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); } break; case BossAnimations.startRecovering: break; case BossAnimations.recovering: //the boss is recovering and its wings can be hit { if (bossAnimations[(int)bossAnimation].FrameIndex == 0 && bossAnimations[(int)bossAnimation].FreviousFrameIndex != 0) { SoundEffects.FinalBossRecover.Play(); } else if (bossAnimations[(int)bossAnimation].FrameIndex == 2 && bossAnimations[(int)bossAnimation].FreviousFrameIndex != 2) { SoundEffects.FinalBossAwaken.Play(); } elapsedRecoveryTime += elapsedTime; if (elapsedRecoveryTime >= recoveryTime) { bossAnimation = BossAnimations.endRecovering; if (rightWingHP > 0) { rightWingAnimation = WingAnimations.withdraw; } else { rightWingAnimation = WingAnimations.withdrawDead; } if (leftWingHP > 0) { leftWingAnimation = WingAnimations.withdraw; } else { leftWingAnimation = WingAnimations.withdrawDead; } bossAnimations[(int)BossAnimations.endRecovering].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); elapsedRecoveryTime = 0; bossHP = maxBossHp / 2; break; } switch (currentPhase) { case Phases.one: if (rightWingHP + leftWingHP == 3) { bossHP = maxBossHp; elapsedRecoveryTime = 0; currentPhase = Phases.two; bossAnimation = BossAnimations.endRecovering; if (rightWingHP > 0) { rightWingAnimation = WingAnimations.withdraw; } else { rightWingAnimation = WingAnimations.withdrawDead; } if (leftWingHP > 0) { leftWingAnimation = WingAnimations.withdraw; } else { leftWingAnimation = WingAnimations.withdrawDead; } bossAnimations[(int)BossAnimations.attack].Reset(); bossAnimations[(int)BossAnimations.endRecovering].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); SoundEffects.FinalBossHurt.Play(); FireBallsManager.AddGhostFireball(3); } break; case Phases.two: if (rightWingHP + leftWingHP == 2) { bossHP = maxBossHp; elapsedRecoveryTime = 0; currentPhase = Phases.three; bossAnimation = BossAnimations.endRecovering; if (rightWingHP > 0) { rightWingAnimation = WingAnimations.withdraw; } else { rightWingAnimation = WingAnimations.withdrawDead; } if (leftWingHP > 0) { leftWingAnimation = WingAnimations.withdraw; } else { leftWingAnimation = WingAnimations.withdrawDead; } bossAnimations[(int)BossAnimations.attack].Reset(); bossAnimations[(int)BossAnimations.endRecovering].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); SoundEffects.FinalBossHurt.Play(); FireBallsManager.ThrowAtPlayer(20, 2, 0.1f); CollectablesManager.collectablesRoomManagers[(int)RoomsManager.CurrentRoom].AddCollectableToMap( new Collectable(new Point(374, 475), Collectable.ItemType.heart)); } break; case Phases.three: if (rightWingHP + leftWingHP == 1) { bossHP = maxBossHp; elapsedRecoveryTime = 0; currentPhase = Phases.four; bossAnimation = BossAnimations.endRecovering; if (rightWingHP > 0) { rightWingAnimation = WingAnimations.withdraw; } else { rightWingAnimation = WingAnimations.withdrawDead; } if (leftWingHP > 0) { leftWingAnimation = WingAnimations.withdraw; } else { leftWingAnimation = WingAnimations.withdrawDead; } bossAnimations[(int)BossAnimations.attack].Reset(); bossAnimations[(int)BossAnimations.endRecovering].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); SoundEffects.FinalBossHurt.Play(); LavaGeyserManager.SweepAcross(1, 0f, 100, 159, 609, true); CollectablesManager.collectablesRoomManagers[(int)RoomsManager.CurrentRoom].AddCollectableToMap( new Collectable(new Point(378, 475), Collectable.ItemType.heart)); } break; case Phases.four: if (rightWingHP + leftWingHP == 0) { if (Player.CollisionRectangle.Right > bossMidPoint.X) { rightWingAnimation = WingAnimations.withdraw; leftWingAnimation = WingAnimations.withdrawDead; } else { rightWingAnimation = WingAnimations.withdrawDead; leftWingAnimation = WingAnimations.withdraw; } bossAnimation = BossAnimations.falling; bossAnimations[(int)BossAnimations.attack].Reset(); rightWingAnimations[(int)rightWingAnimation].Reset(); leftWingAnimations[(int)leftWingAnimation].Reset(); elapsedRecoveryTime = 0; SoundEffects.FinalBossHurt.Play(); FireBallsManager.Reset(); LavaGeyserManager.Reset(); } break; } break; } case BossAnimations.endRecovering: break; case BossAnimations.falling: //when the boss dies, it falls out of the screen { bossMidPoint.Y += YSpeed * elapsedTime; YSpeed += Gravity.gravityAcceleration * elapsedTime; if (BossDrawRectangle.Y > MapsManager.maps[(int)RoomsManager.CurrentRoom].RoomHeightPx) { dead = true; LoadSaveManager.SaveGameProgress(); MediaPlayer.Stop(); } break; } } }
static public float bestTime; //store the best game time #endregion #region CONSTRUCTOR static public void Initialize(SpriteFont _spriteFont8, SpriteFont _spriteFont12) { spriteFont8 = _spriteFont8; spriteFont12 = _spriteFont12; LoadSaveManager.LoadHighScores(); }