public override void Update(float elapsedTime)
{
if (-ScrollingShooterGame.LevelManager.scrollDistance / 2 <= position.Y - 10) ScrollingShooterGame.LevelManager.Scrolling = false;
this.Health = Math.Min(this.Health, Math.Min(leftGun.Health, rightGun.Health));
// If the blimp is below 25% health switch the sprite
if (this.Health / maxHealth < 0.25f) state = BlimpState.Below25;
if (this.Health <= 0)
{
ScrollingShooterGame.GameObjectManager.DestroyObject(leftGun.ID);
ScrollingShooterGame.GameObjectManager.DestroyObject(rightGun.ID);
}
// Move the blimp
if (position.X - 11 <= 5 || position.X + 69 >= this.screenWidth - 30) velocity.X *= -1;
position.X -= elapsedTime * velocity.X;
this.gunTimer += elapsedTime;
if (gunTimer >= 1f)
{
// Sense the player's position
PlayerShip player = ScrollingShooterGame.Game.Player;
Vector2 playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y);
// Get a vector from our position to the player's position
Vector2 toPlayer = playerPosition - this.position;
// Shoot the shotgun if the player is within 200 units of the blimp
if (toPlayer.LengthSquared() < 40000)
{
Vector2 travel = position;
travel.X += Bounds.Width / 2;
travel.Y += Bounds.Height / 2;
ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.BlimpShotgun, travel);
gunTimer = 0;
}
}
}