internal override void AttackEnemy(List <Cruiser> enemyCruisers) { var enemycruiser = enemyCruisers.OrderBy(unit => RandomService.Get()).FirstOrDefault(); enemycruiser.RemoveHealth(this.Damage); Console.Write($"{enemycruiser.Army.Name} Cruiser ({enemycruiser.CurrentHealth}) \n"); }
public override void AttackEnemy(List <Cruiser> enemyCruisers) { var enemycruiser = enemyCruisers.OrderBy(x => RandomService.Get()).First(); enemycruiser.RemoveHealth(this.Damage); Console.WriteLine($"{enemycruiser.Army.Name} Cruiser ({enemycruiser.CurrentHealth})"); }
internal override void AttackEnemy(Army enemyarmy) { base.AttackEnemy(enemyarmy); var legion = enemyarmy.AllAliveCruisers.SelectMany(cruiser => cruiser.AllAliveUnits).ToList(); var enemy = legion.OrderBy(unit => RandomService.Get()).FirstOrDefault(); if (enemy != null) { enemy.RemoveHealth(this.Damage); Console.Write($"{enemyarmy.Name} {enemy} \n"); } else { AttackEnemy(enemyarmy.AllAliveCruisers); } }
public override void AttackEnemy(Army enemyArmy) { base.AttackEnemy(enemyArmy); var enemyUnit = enemyArmy.AllAliveCruisers .SelectMany(cruiser => cruiser.AllAliveAircraft) .OrderBy(x => x.CurrentHealth / x.MaxHealth * 100) .ThenByDescending(x => x.MaxHealth) .ThenBy(x => RandomService.Get()) .FirstOrDefault(); if (enemyUnit != null) { enemyUnit.RemoveHealth(this.Damage); Console.WriteLine($"{enemyUnit.ParentCruiser.Army.Name} {enemyUnit}"); } else { AttackEnemy(enemyArmy.AllAliveCruisers); } }
public List <Unit> GetSquad(int count) { var legion = AllAliveCruisers.SelectMany(cruiser => cruiser.AllAliveUnits).ToList(); var squad = AllAliveCruisers.Concat(legion.Cast <Unit>()).OrderBy(unit => RandomService.Get()).Take(count).ToList(); return(squad); }