/// <summary> /// Updates the brain boss /// </summary> /// <param name="elapsedTime">Time passed since last frame</param> public override void Update(float elapsedTime) { switch (state) { case BrainBossState.Protected: //can't die in this state Health = 999999; if (protection.isDestroyed()) { ScrollingShooterGame.GameObjectManager.DestroyObject(protection.ID); state = BrainBossState.MovingToCenter; protection = null; } break; case BrainBossState.MovingToCenter: //can't die in this state Health = 999999; if (position.X < targetPositionX) position.X += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X)); else if (position.X > targetPositionY) position.X -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X)); if (position.Y < targetPositionY) position.Y += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y)); else if (position.Y > targetPositionY) position.Y -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y)); if (Math.Abs(targetPositionX - position.X) < 2 && Math.Abs(targetPositionY - position.Y) < 2) { state = BrainBossState.PsyAttack; psiEmitter.startAttacking(); } break; case BrainBossState.PsyAttack: //can't die in this state Health = 999999; if (psiEmitter.isDestroyed()) { //Health when can be hit Health = 100; state = BrainBossState.DeathCharge; } break; case BrainBossState.DeathCharge: if (Health <= 0) { ScrollingShooterGame.GameObjectManager.DestroyObject(this.ID); ScrollingShooterGame.GameObjectManager.CreateExplosion(ID); return; } Vector2 vector = ScrollingShooterGame.Game.Player.GetPosition() - (position + centerOffset); vector.Normalize(); vector *= MOVE_SPEED * elapsedTime; position.X += vector.X; position.Y += vector.Y; lightningRecharge -= elapsedTime; if (lightningRecharge <= 0) { lightningRecharge = .66f; for (int i = 0; i < 15; i++) ((EnemyLightningZap)ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyLightningZap, this.position + centerOffset)).Initialize((float)(rand.NextDouble() * Math.PI * 2), this.brainSpriteBounds.Width / 2); } break; } psiEmitter.updatePosition(this.position + centerOffset); }
/// <summary> /// Updates the brain boss /// </summary> /// <param name="elapsedTime">Time passed since last frame</param> public override void Update(float elapsedTime) { switch (state) { case BrainBossState.Protected: if (protection.Health <= 0) state = BrainBossState.MovingToCenter; break; case BrainBossState.MovingToCenter: if (position.X < screenCenterX) position.X += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(screenCenterX - position.X)); else if (position.X > screenCenterY) position.X -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(screenCenterX - position.X)); if (position.Y < screenCenterY) position.Y += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(screenCenterY - position.Y)); else if (position.Y > screenCenterY) position.Y -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(screenCenterY - position.Y)); if (Math.Abs(screenCenterX - position.X) < 2 && Math.Abs(screenCenterY - position.Y) < 2) { state = BrainBossState.PsyAttack; psiEmitter.startAttacking(); } break; case BrainBossState.PsyAttack: if (psiEmitter.isDestroyed()) state = BrainBossState.DeathCharge; break; case BrainBossState.DeathCharge: checkForCollisions(); Vector2 vector = ScrollingShooterGame.Game.Player.GetPosition() - (position + centerOffset); vector.Normalize(); vector *= MOVE_SPEED * elapsedTime; position.X += vector.X; position.Y += vector.Y; for(int i = 0; i < 2; i++) ((EnemyLightningZap) ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyLightningZap, this.position + centerOffset)).Initialize((float) (rand.NextDouble() * Math.PI * 2), this.brainSpriteBounds.Width); break; } psiEmitter.updatePosition(this.position + centerOffset); }
/// <summary> /// Updates the brain boss /// </summary> /// <param name="elapsedTime">Time passed since last frame</param> public override void Update(float elapsedTime) { //TODO: remove test timer when damage is implemented testTimer -= elapsedTime; if (testTimer <= 0) { takeDamage(1000); if (this.protection != null) protection.takeDamage(1000); if (this.psiEmitter != null) psiEmitter.takeDamage(1000); testTimer = 8f; } switch (state) { case BrainBossState.Protected: if (protection.Health <= 0) { ScrollingShooterGame.GameObjectManager.DestroyObject(protection.ID); state = BrainBossState.MovingToCenter; protection = null; } break; case BrainBossState.MovingToCenter: if (position.X < targetPositionX) position.X += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X)); else if (position.X > targetPositionY) position.X -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X)); if (position.Y < targetPositionY) position.Y += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y)); else if (position.Y > targetPositionY) position.Y -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y)); if (Math.Abs(targetPositionX - position.X) < 2 && Math.Abs(targetPositionY - position.Y) < 2) { state = BrainBossState.PsyAttack; psiEmitter.startAttacking(); } break; case BrainBossState.PsyAttack: if (psiEmitter.Health <= 0) state = BrainBossState.DeathCharge; break; case BrainBossState.DeathCharge: if (Health <= 0) { ScrollingShooterGame.GameObjectManager.DestroyObject(this.ID); ScrollingShooterGame.GameObjectManager.CreateExplosion(ID); return; } Vector2 vector = ScrollingShooterGame.Game.Player.GetPosition() - (position + centerOffset); vector.Normalize(); vector *= MOVE_SPEED * elapsedTime; position.X += vector.X; position.Y += vector.Y; for(int i = 0; i < 1; i++) ((EnemyLightningZap) ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyLightningZap, this.position + centerOffset)).Initialize((float) (rand.NextDouble() * Math.PI * 2), this.brainSpriteBounds.Width); break; } psiEmitter.updatePosition(this.position + centerOffset); }
/// <summary> /// Updates the brain boss /// </summary> /// <param name="elapsedTime">Time passed since last frame</param> public override void Update(float elapsedTime) { //TODO: remove test timer when damage is implemented testTimer -= elapsedTime; if (testTimer <= 0) { takeDamage(1000); if (this.protection != null) { protection.takeDamage(1000); } if (this.psiEmitter != null) { psiEmitter.takeDamage(1000); } testTimer = 8f; } switch (state) { case BrainBossState.Protected: if (protection.Health <= 0) { ScrollingShooterGame.GameObjectManager.DestroyObject(protection.ID); state = BrainBossState.MovingToCenter; protection = null; } break; case BrainBossState.MovingToCenter: if (position.X < targetPositionX) { position.X += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X)); } else if (position.X > targetPositionY) { position.X -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X)); } if (position.Y < targetPositionY) { position.Y += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y)); } else if (position.Y > targetPositionY) { position.Y -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y)); } if (Math.Abs(targetPositionX - position.X) < 2 && Math.Abs(targetPositionY - position.Y) < 2) { state = BrainBossState.PsyAttack; psiEmitter.startAttacking(); } break; case BrainBossState.PsyAttack: if (psiEmitter.Health <= 0) { state = BrainBossState.DeathCharge; } break; case BrainBossState.DeathCharge: if (Health <= 0) { ScrollingShooterGame.GameObjectManager.DestroyObject(this.ID); ScrollingShooterGame.GameObjectManager.CreateExplosion(ID); return; } Vector2 vector = ScrollingShooterGame.Game.Player.GetPosition() - (position + centerOffset); vector.Normalize(); vector *= MOVE_SPEED * elapsedTime; position.X += vector.X; position.Y += vector.Y; for (int i = 0; i < 1; i++) { ((EnemyLightningZap)ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyLightningZap, this.position + centerOffset)).Initialize((float)(rand.NextDouble() * Math.PI * 2), this.brainSpriteBounds.Width); } break; } psiEmitter.updatePosition(this.position + centerOffset); }