Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6356321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:56:24+00:00 2026-05-24T22:56:24+00:00

In my game I’m using a powerup system, which basically works like this: Enemy

  • 0

In my game I’m using a powerup system, which basically works like this:

  • Enemy gets killed, has random chance to drop powerup box
  • Pickup powerup box to get random item

The code for giving the player a random powerup looks like this…

Type t = RandomManager.PickFromParams<Type>(typeof(PowerupInvincible), typeof(PowerupDoubleFireRate));
ply.AddPowerup<t>();

And the AddPowerup<>() method looks like this:

public void AddPowerup<T>() where T : PowerupEffect, new()
{
    var powerup = new T();

    powerup.Activate(this);
    powerups.Add(powerup);
}

Now, the problem is the ply.AddPowerup<t>() line, because it complains that it can’t find the type t:

The type or namespace name ‘t’ could not be found (are you missing a using directive or an assembly reference?)

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:56:25+00:00Added an answer on May 24, 2026 at 10:56 pm

    It sounds like you are not using generics correctly in this instance. I’m assuming PowerupInvincible, and PowerupDoubleFireRate inherit from some PowerupBase:

    PowerupBase powerUp = RandomManager.PickFromParams<PowerupBase>(typeof(PowerupInvincible), typeof(PowerupDoubleFireRate));
    
    ply.AddPowerup(powerUp);
    

    Then the method signature simple need to be:

    public void AddPowerup(PowerupBase powerup)
    {
        powerup.Activate(this);
        powerups.Add(powerup);
    }
    

    Your random manager would be responsible for choosing one of the parameters, instantiating it, and then returning the instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am making a game using andengine in android, in this game various sprites(eggs)
I'm writing a game in C using the Gtk libraries, in which the player
The game that I am creating has a highScore integer variable that gets assigned
My game has class Enemy who's AI/functionality I can change with trait Moving trait
My game is a small shooting game in cocos2d. The enemy generates the bullets
game.multiplayer = bundle.getString(multiplayer ,null); is giving the error: java.lang.NoSuchMethodError: android.os.Bundle.getString Other methods like game.word.word
Game.prototype.run = function() { window.setInterval(function() { var thisLoop = new Date().getTime(); this.update(); this.render(); lastLoop
My game normally uses GL_TEXTURE_RECTANGLE_EXT to draw 2D textures. However, since this isn't supported
The Game Boy Z80 CPU has a half-carry flag, and I can't seem to
My 'game' keeps crashing after I resume it. Basically, I launch the app and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.