Пример #1
0
        private void AttackHeroes(Enemy enemyBeingAttacked)
        {
            IEnumerable <Entity> enemies;

            if (enemyBeingAttacked == null)
            {
                enemies = Enemies;
            }
            else
            {
                enemies = Enemies.Where(e => e != enemyBeingAttacked);
            }

            Random rand = new Random();

            foreach (var enemy in enemies)
            {
                var count = Heroes.Count();
                if (count < 1)
                {
                    break;
                }
                enemy.Attack(Heroes.ElementAt(rand.Next(0, count - 1)));
                if (count != Heroes.Count())
                {
                    break;
                }
            }
        }