title: Find random object where integer is less than value
body: <p>I want to find a random enemy that has <code>power &lt;= maxUnitPower</code>, and it has to also be <code>power &lt;= remainingPower</code>.</p>
  
  <p>I wrote some logic to manage tha scenario that creates a new List with all enemies that has less than <code>power</code>, then I pick a random enemy in that List, and check if it's <code>power</code> is less than the <code>remainingPower</code>:</p>
  
  <pre><code>WorldObjectData GetRandomEnemy(EnemyWaveData wave, int remainingPower)
  {
      List&lt;WorldObjectData&gt; relevantEnemies = new List&lt;WorldObjectData&gt;();
  
      for (int i = 0; i &lt; enemyList.enemies.Count; i++)
      {
          if(enemyList.enemies[i].power &lt;= wave.maxUnitPower)
          {
              relevantEnemies.Add(enemyList.enemies[i]);
          }
      }
  
      return GetEnemyWithinRemainingPower(relevantEnemies, remainingPower);
  }
  
  WorldObjectData GetEnemyWithinRemainingPower(List&lt;WorldObjectData&gt; enemies, int remainingPower)
  {
      WorldObjectData enemy = enemies[Random.Range(0, enemies.Count)];
  
      if (enemy.power &lt;= remainingPower)
          return enemy;
      else
          return GetEnemyWithinRemainingPower(enemies, remainingPower);
  }
  </code></pre>
  
  <p>I want to do this in Linq instead since this seems very messy, but have no idea how to achieve it. How can it be done?</p>