How to create a repository of enemy objects that are initialised but then get a new instance of a random one?

I am attempting to create a really simple turn based rpg. I have created an enemy object as follows:

public class Enemy()
{
    int attack;
    int hp;
    string name;

    public Enemy(string _name, int _hp, int _attack)
    {
        name = _name;
        hp = _hp;
        attack = _attack;
    }
}

I then have a separate class where I create specific instances to represent possible enemies to encounter in the game as follows:

public static class Enemies
{
	static Enemy slime = new Creature ("Slime", 12, 2, 0, 2);
	static Enemy wolf = new Creature ("Wolf", 40, 3, 2, 5);

	public static List<Enemy > all = new List<Enemy > {
		slime,
		wolf,
	};

	public static Enemy Get (List<Enemy > enemyList)
	{
		return enemyList[Random.Range (0, enemyList.Count)];
	}
}

However if I use this method, the Get method returns that specific instance of the enemy, when I would like for it to return a new instance (so that hp is full etc.).

I have a feeling there is a much better way of doing this, could anyone point me in the correct direction?

Many thanks,

Robin

Hi Niboruga,

you’re having the same problem i am currently having.

Did you happen to find a solution?

I stole this code from

and modified it for my own purposes.

Problem is that it uses a static dictionary.
I assume this means that i won’t be able to create more than one instance of it.
I however would like to create instances of this dictionary.
if i remove the static then i get an error
“an object reference is required for the non-static field, method or property…”