public void Attack(List <enemyProjectile> enemyProjectiles, player player) { Random random = new Random(); if (player.respawnCutScene) { fireRate = 0; } switch (aiType) { case 2: fireRate += 1; if (fireRate == 64 + 16 || fireRate == 64 + 32 || fireRate == 64 + 48) { enemyProjectiles.Add(new enemyProjectile(new Vector2(pos.X + width / 2 - 2, pos.Y + height / 2 - 2), 1, 8, -270)); } if (fireRate >= 128 + 64) { fireRate = random.Next(-64, 64 + 32); } break; case 3: fireRate += 1; if (fireRate == 64 + 16 || fireRate == 64 + 32) { enemyProjectiles.Add(new enemyProjectile(pos, 4, 8, player)); } if (fireRate >= 128) { fireRate = random.Next(-64, 63); } break; case 4: fireRate += 1; if (fireRate >= 64) { enemyProjectiles.Add(new enemyProjectile(new Vector2(pos.X + width / 2 + 3, pos.Y + height / 2 - 2), 2, 5, -270)); enemyProjectiles.Add(new enemyProjectile(new Vector2(pos.X + width / 2 - 8, pos.Y + height / 2 - 2), 2, 5, -270)); fireRate = 0; } break; case 5: fireRate += 1; if (fireRate >= 32) { if (direction == 3) { enemyProjectiles.Add(new enemyProjectile(new Vector2(pos.X + width / 2 - 8, pos.Y + height / 2 - 2), 1, 7, -180)); } else { enemyProjectiles.Add(new enemyProjectile(new Vector2(pos.X + width / 2 - 8, pos.Y + height / 2 - 2), 1, 7, 0)); } fireRate = 0; } break; case 6: fireRate += 1; if (fireRate == 32 || fireRate == 32 + 8 || fireRate == 32 + 16) { enemyProjectiles.Add(new enemyProjectile(new Vector2(pos.X + width / 2, pos.Y + height / 2), 5, 10, random.Next(-280, -260))); } if (fireRate >= 64) { fireRate = 0; } break; } }
public void CheckHealth(List <projectile> projectiles, List <explosion> explosions, ref player player) { Rectangle enemyC = new Rectangle((int)pos.X + 6, (int)pos.Y + 6, width - 6, 24 - 6); if (pos.Y > 600) { destroy = true; } foreach (projectile p in projectiles) { Rectangle projectileC = new Rectangle((int)p.pos.X, (int)p.pos.Y, width, height); if (projectileC.Intersects(enemyC) && vulnerable) { hp -= p.dm; p.destroy = true; } } if (hp <= 0 && vulnerable) { explosions.Add(new explosion(pos)); switch (aiType) { case 1: player.score += 1000; break; case 2: player.score += 3000; break; case 3: player.score += 4000; break; } destroy = true; } }
public void CheckHealth(List <projectile> projectiles, List <explosion> explosions, List <hitEffect> hitEffects, List <gib> gibs, ref player player) { Random random = new Random(); if (!rotated) { enemyC = new Rectangle((int)pos.X + 6, (int)pos.Y + 6, width - 6, 24 - 6); } else { enemyC = new Rectangle((int)pos.X + 6 - width / 2 - 6, (int)pos.Y + 6 - 9, width - 6, 24 - 6); } if (player.playerC.Intersects(enemyC) && player.respawnDelay <= 0) { if (vulnerable) { player.hp -= 2; hp = 0; } else { player.hp = 0; } } if (pos.Y > 600) { destroy = true; } foreach (projectile p in projectiles) { if (p.projectileC.Intersects(enemyC) && vulnerable) { hp -= p.dm; if (hp >= 1) { if (!rotated) { hitEffects.Add(new hitEffect(pos)); } else { hitEffects.Add(new hitEffect(new Vector2(pos.X - width / 2, pos.Y - height / 2))); } } p.destroy = true; } } if (hp <= 0 && vulnerable) { explosions.Add(new explosion(pos)); player.totalKills += 1; player.kills += 1; for (int i = 0; i < 50; i++) { if (material == "organic") { gibs.Add(new gib(new Vector2(pos.X + 12, pos.Y + 12), random.Next(1, 7), random.Next(360), material, random.Next(10, 21))); } if (material == "metal") { gibs.Add(new gib(new Vector2(pos.X + 12, pos.Y + 12), random.Next(1, 7), random.Next(360), material, random.Next(1, 10))); } } switch (aiType) { case 1: player.score += 1000; break; case 2: player.score += 3000; break; case 3: player.score += 4000; break; case 4: player.score += 6000; break; } destroy = true; } }