C#: Question about using generics and picking a random type
<p>In my game I'm using a powerup system, which basically works like this:</p>

<ul>
<li>Enemy gets killed, has random chance to drop powerup box</li>
<li>Pickup powerup box to get random item</li>
</ul>

<p>The code for giving the player a random powerup looks like this...</p>

<pre><code>Type t = RandomManager.PickFromParams&lt;Type&gt;(typeof(PowerupInvincible), typeof(PowerupDoubleFireRate));
ply.AddPowerup&lt;t&gt;();
</code></pre>

<p>And the <code>AddPowerup&lt;&gt;()</code> method looks like this:</p>

<pre><code>public void AddPowerup&lt;T&gt;() where T : PowerupEffect, new()
{
    var powerup = new T();

    powerup.Activate(this);
    powerups.Add(powerup);
}
</code></pre>

<p>Now, the problem is the <code>ply.AddPowerup&lt;t&gt;()</code> line, because it complains that it can't find the type t:</p>

<blockquote>
  <p>The type or namespace name 't' could not be found (are you missing a using directive or an assembly reference?)</p>
</blockquote>

<p>Does anyone know if there's a way to fix this, or if that's not possible, show me a better way to do it? Thanks in advance!</p>
