private static void Attack(ContentManager Content, GameTime gameTime, Boss bossDragon, EnemyAttack bossFireBall, List<EnemyAttack> bossFireBalls) { // The boss will attack on set intervals coolDown += (float)gameTime.ElapsedGameTime.TotalSeconds; // Fireballs are added to a list to allow the boss to shoot more than once foreach (var fireBall in bossFireBalls) { fireBall.Update(); } if (coolDown > 3) { // A new fireball is generated in a position where it matches the boss mouth bossFireBall = new EnemyAttack(Content.Load<Texture2D>("Images\\Dragonfire"), new Vector2(bossDragon.Position.X - 65, bossDragon.Position.Y + bossDragon.Texture.Height / 2 - 40), 0f, -10f); bossFireBalls.Clear(); coolDown = 0; // The fireball is added to the list of fireballs bossFireBalls.Add(bossFireBall); // this variable is used as a trigger to change the boss animation shot = true; // A sound is played each time the boss fires bossDragon.PlaySound(); } }
private static void BossSummon(ContentManager Content, GameTime gameTime, Boss bossDragon, EnemyAttack bossFireBall, List<EnemyAttack> bossFireBalls) { if (shadow != 255) { // At the beginig only the shadow of the poss will be visible // This can be acheive by setting all the colors to zero and // gradually increasing the alpha channel till he is visible color = new Color(0, 0, 0, shadow); shadow += 1; bossDragon.SetColor = color; } else if (appear != 255) { // After the boss is visible the colors start appearing color = new Color(appear, appear, appear, shadow); appear += 1; bossDragon.SetColor = color; } else { // The boss won't be able to attack until he is completely colored and visible Attack(Content, gameTime, bossDragon, bossFireBall, bossFireBalls); } }
public static void FireBallGenerator(ContentManager Content, List<Enemy> dragons, List<EnemyAttack> fireBalls) { foreach (var dragon in dragons) { // If attack interval is larger that 2 -> fire if (dragon.Interval > 2) { dragon.Interval = 0; // If there are less than 10 firebals on the screen -> fire if (fireBalls.Count < 10) { // Generate a new fireBall with position of the current dragon plus his speed // The offset -40px X and 50px Y is to align the fireball with the mouth of the dragon EnemyAttack fireBall = new EnemyAttack(Content.Load<Texture2D>("Images\\FireBall"), new Vector2(dragon.Position.X - 40, dragon.Position.Y + 50), dragon.VelocityX); fireBalls.Add(fireBall); // A sound is played during each shot dragon.PlaySound(); // The dragon texture changes during each shot dragon.Texture = Content.Load<Texture2D>("Images\\Babydragon2"); } } if (dragon.CoolDown > 3) { // Used to change the texture back to normal dragon.CoolDown = 0; dragon.Texture = Content.Load<Texture2D>("Images\\Babydragon1"); } } }