/// <summary> /// Creates a new instance of a Bird boss /// </summary> /// <param name="content">A ContentManager to load resources with</param> /// <param name="position">The position of the Bird boss in the game world</param> public Bird(uint id, ContentManager content, Vector2 position) : base(id) { position.Y += 800; this.position = position; ScrollingShooterGame.LevelManager.Scrolling = true; this.Health = 100; this.position = position; spritesheet = content.Load<Texture2D>("Spritesheets/newsh0.shp.000001"); spriteBounds[0].X = 3; spriteBounds[0].Y = 0; spriteBounds[0].Width = 187; spriteBounds[0].Height = 84; spriteBoundsAnim[2].X = 48; spriteBoundsAnim[2].Y = 84; spriteBoundsAnim[2].Width = 23; spriteBoundsAnim[2].Height = 25; spriteBoundsAnim[1].X = 72; spriteBoundsAnim[1].Y = 84; spriteBoundsAnim[1].Width = 23; spriteBoundsAnim[1].Height = 25; spriteBoundsAnim[0].X = 96; spriteBoundsAnim[0].Y = 84; spriteBoundsAnim[0].Width = 23; spriteBoundsAnim[0].Height = 25; spriteBoundsAnim[3].X = 168; spriteBoundsAnim[3].Y = 84; spriteBoundsAnim[3].Width = 23; spriteBoundsAnim[3].Height = 25; spriteBoundsLaser[0].X = 123; spriteBoundsLaser[0].Y = 84; spriteBoundsLaser[0].Width = 19; spriteBoundsLaser[0].Height = 23; spriteBoundsLaser[1].X = 147; spriteBoundsLaser[1].Y = 84; spriteBoundsLaser[1].Width = 19; spriteBoundsLaser[1].Height = 23; spriteBoundsLaser[2].X = 195; spriteBoundsLaser[2].Y = 84; spriteBoundsLaser[2].Width = 19; spriteBoundsLaser[2].Height = 23; beakPosition.X = (spriteBounds[0].Width / 2) + 8; beakPosition.Y = spriteBounds[0].Height + spriteBoundsAnim[0].Height; LeftLaserPosition.X = (spriteBounds[0].Width / 2) + 49; LeftLaserPosition.Y = spriteBounds[0].Height + spriteBoundsLaser[0].Height - 30; RightLaserPosition.X = (spriteBounds[0].Width / 2) - 49; RightLaserPosition.Y = spriteBounds[0].Height + spriteBoundsLaser[0].Height - 30; LeftLaser = (DroneLaser)ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.DroneLaser, LeftLaserPosition); LeftLaser.isOn = laserStatus; LeftLaser.laserPower = WeaponChargeLevel.Low; RightLaser = (DroneLaser)ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.DroneLaser, RightLaserPosition); RightLaser.isOn = laserStatus; RightLaser.laserPower = WeaponChargeLevel.Low; BES = birdEntranceState.flyOver; scream = content.Load<SoundEffect>("SFX/hawk_scream"); scream.Play(); fire = content.Load<SoundEffect>("SFX/bird_fire"); hurt = content.Load<SoundEffect>("SFX/hurt_scream"); death = content.Load<SoundEffect>("SFX/death_scream"); }
/// <summary> /// Updates the Dart ship /// </summary> /// <param name="elapsedTime">The in-game time between the previous and current frame</param> public override void Update(float elapsedTime) { switch (BES) { case birdEntranceState.flyOver: this.position.Y -= elapsedTime * 500; if (position.Y <= 3892) // -200 { BES = birdEntranceState.enter; } break; case birdEntranceState.enter: this.position.Y += elapsedTime * 100; if (position.Y >= 0) { BES = birdEntranceState.normal; } ScrollingShooterGame.LevelManager.Scrolling = false; break; case birdEntranceState.normal: fireTimer += elapsedTime; laserTimer += elapsedTime; float velocity = 1; // Sense the player's position PlayerShip player = ScrollingShooterGame.Game.Player; Vector2 playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y); if (playerPosition.X - Bounds.Center.X < -20) { this.position.X -= elapsedTime * 40 * velocity; } else { if (playerPosition.X - Bounds.Center.X > 20) { this.position.X += elapsedTime * 40 * velocity; } else { if (fireTimer > 0.6f) { ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.BirdWrath, position + beakPosition); fireTimer = 0f; } } } if (fireTimer > 1.5f) { ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.BirdWrath, position + beakPosition); fireTimer = 0f; } //Firein Mah Lazars!! switch (laserState) { case LaserState.off: if (laserTimer > 3f) { laserState = LaserState.turningOn; laserAnimState = 0; } break; case LaserState.turningOn: laserAnimState++; if (laserAnimState == NUMBER_OF_ANIM_STATES_LASER - 1) { laserState = LaserState.on; laserTimer = 0f; } break; case LaserState.on: LeftLaser.isOn = true; RightLaser.isOn = true; LeftLaser.updatePosition(position.X + LeftLaserPosition.X, position.Y + LeftLaserPosition.Y); RightLaser.updatePosition(position.X + RightLaserPosition.X, position.Y + RightLaserPosition.Y); if (laserTimer > 3f) { LeftLaser.isOn = false; RightLaser.isOn = false; laserState = LaserState.turningOff; } break; case LaserState.turningOff: laserAnimState--; if (laserAnimState == 0) { laserState = LaserState.off; laserTimer = 0f; } break; } break; case birdEntranceState.exit: this.position.Y += elapsedTime * 500; ScrollingShooterGame.LevelManager.Scrolling = true; break; } }
/// <summary> /// Updates the Dart ship /// </summary> /// <param name="elapsedTime">The in-game time between the previous and current frame</param> public override void Update(float elapsedTime) { switch (BES) { case birdEntranceState.flyOver: this.position.Y -= elapsedTime * 500; if (position.Y <= 2000) // -200 { BES = birdEntranceState.enter; } break; case birdEntranceState.enter: PlayerShip player = ScrollingShooterGame.Game.Player; Vector2 playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y); if (ScrollingShooterGame.LevelManager.scrollDistance > -7300 && ScrollingShooterGame.LevelManager.Scrolling == true) { ScrollingShooterGame.LevelManager.Scrolling = false; this.position.Y = 3400; scream.Play(); } if (ScrollingShooterGame.LevelManager.Scrolling == false) { this.position.Y += elapsedTime * 100; } if (position.Y >= 3650 && ScrollingShooterGame.LevelManager.Scrolling == false) { BES = birdEntranceState.normal; } break; case birdEntranceState.normal: fireTimer += elapsedTime; laserTimer += elapsedTime; if (Health < 75 && !leftLaserDestroyed) { leftLaserDestroyed = true; RightLaser.isOn = false; hurt.Play(); } if (Health < 50 && !rightLaserDestroyed) { rightLaserDestroyed = true; LeftLaser.isOn = false; hurt.Play(); } float velocity = 1; // Sense the player's position player = ScrollingShooterGame.Game.Player; playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y); if (playerPosition.X - Bounds.Center.X < -20) { this.position.X -= elapsedTime * 40 * velocity; } else { if (playerPosition.X - Bounds.Center.X > 20) { this.position.X += elapsedTime * 40 * velocity; } else { if (fireTimer > 0.6f) { ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.BirdWrath, position + beakPosition); fire.Play(); fireTimer = 0f; } } } if (fireTimer > 1.5f) { ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.BirdWrath, position + beakPosition); fire.Play(); fireTimer = 0f; } //Firein Mah Lazars!! switch (laserState) { case LaserState.off: if (laserTimer > 3f) { laserState = LaserState.turningOn; laserAnimState = 0; } break; case LaserState.turningOn: laserAnimState++; if (laserAnimState == NUMBER_OF_ANIM_STATES_LASER - 1) { laserState = LaserState.on; laserTimer = 0f; } break; case LaserState.on: if (!rightLaserDestroyed) LeftLaser.isOn = true; if (!leftLaserDestroyed) RightLaser.isOn = true; LeftLaser.updatePosition(position.X + LeftLaserPosition.X, position.Y + LeftLaserPosition.Y); RightLaser.updatePosition(position.X + RightLaserPosition.X, position.Y + RightLaserPosition.Y); if (laserTimer > 3f) { LeftLaser.isOn = false; RightLaser.isOn = false; laserState = LaserState.turningOff; } break; case LaserState.turningOff: laserAnimState--; if (laserAnimState == 0) { laserState = LaserState.off; laserTimer = 0f; } break; } break; case birdEntranceState.exit: this.position.Y += elapsedTime * 500; break; } if (Health <= 1) { ScrollingShooterGame.LevelManager.Scrolling = true; death.Play(); } }
/// <summary> /// Creates a new instance of a Bird boss /// </summary> /// <param name="content">A ContentManager to load resources with</param> /// <param name="position">The position of the Bird boss in the game world</param> public Bird(uint id, ContentManager content, Vector2 position) : base(id) { this.position = new Vector2(300, 800); //ScrollingShooterGame.LevelManager.Scrolling = false; this.position = position; spritesheet = content.Load <Texture2D>("Spritesheets/newsh0.shp.000001"); spriteBounds[0].X = 3; spriteBounds[0].Y = 0; spriteBounds[0].Width = 187; spriteBounds[0].Height = 84; spriteBoundsAnim[2].X = 48; spriteBoundsAnim[2].Y = 84; spriteBoundsAnim[2].Width = 23; spriteBoundsAnim[2].Height = 25; spriteBoundsAnim[1].X = 72; spriteBoundsAnim[1].Y = 84; spriteBoundsAnim[1].Width = 23; spriteBoundsAnim[1].Height = 25; spriteBoundsAnim[0].X = 96; spriteBoundsAnim[0].Y = 84; spriteBoundsAnim[0].Width = 23; spriteBoundsAnim[0].Height = 25; spriteBoundsAnim[3].X = 168; spriteBoundsAnim[3].Y = 84; spriteBoundsAnim[3].Width = 23; spriteBoundsAnim[3].Height = 25; spriteBoundsLaser[0].X = 123; spriteBoundsLaser[0].Y = 84; spriteBoundsLaser[0].Width = 19; spriteBoundsLaser[0].Height = 23; spriteBoundsLaser[1].X = 147; spriteBoundsLaser[1].Y = 84; spriteBoundsLaser[1].Width = 19; spriteBoundsLaser[1].Height = 23; spriteBoundsLaser[2].X = 195; spriteBoundsLaser[2].Y = 84; spriteBoundsLaser[2].Width = 19; spriteBoundsLaser[2].Height = 23; beakPosition.X = (spriteBounds[0].Width / 2) + 8; beakPosition.Y = spriteBounds[0].Height + spriteBoundsAnim[0].Height; LeftLaserPosition.X = (spriteBounds[0].Width / 2) + 49; LeftLaserPosition.Y = spriteBounds[0].Height + spriteBoundsLaser[0].Height - 30; RightLaserPosition.X = (spriteBounds[0].Width / 2) - 49; RightLaserPosition.Y = spriteBounds[0].Height + spriteBoundsLaser[0].Height - 30; LeftLaser = (DroneLaser)ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.DroneLaser, LeftLaserPosition); LeftLaser.isOn = laserStatus; LeftLaser.laserPower = WeaponChargeLevel.Low; RightLaser = (DroneLaser)ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.DroneLaser, RightLaserPosition); RightLaser.isOn = laserStatus; RightLaser.laserPower = WeaponChargeLevel.Low; BES = birdEntranceState.flyOver; }