Change GetMonster
method in the MonsterFactory
class to be static
class MonsterFactory
{
public static IMonster GetMonster()
{
return new Monster2();
}
}
In your Main
method call it
private IMonster monster;
void Start()
{
monster = MonsterFactory.GetMonster();
}