예제 #1
0
파일: Aircraft.cs 프로젝트: vmuzhyk/Exams
        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");
        }
예제 #2
0
        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})");
        }
예제 #3
0
파일: Fighter.cs 프로젝트: vmuzhyk/Exams
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
파일: Army.cs 프로젝트: vmuzhyk/Exams
        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);
        }