private void FixedUpdate() { if (_enemies.Count > 0) { foreach (var enemy in _enemies) { if (enemy == null) { DeleteEnemy(enemy); return; } if (Vector3.Distance(spaceship.position, enemy.transform.position) <= DistanceToShoot) { if (!_attacker.ContainsEnemy(enemy)) { _attacker.AddEnemy(enemy); } } else if (_attacker.ContainsEnemy(enemy)) { _attacker.DeleteEnemy(enemy); } } } }