I'm trying to create an instance of a quest and add it to array using singleton pattern. When I run my program and it goes through this code, it stops and throws NullReferenceException. What may cause the problem?
public class IntroductionQuest : Quest
{
//SINGLTON REALIZATION
protected static IntroductionQuest instance;
private IntroductionQuest(string Name) { name = Name; }
public static IntroductionQuest Initialize(string Name)
{
if (instance == null)
{
instance = new IntroductionQuest(Name);
PublicData.Quests.Add(instance);
}
return instance;
}
//SINGLETON REALIZATION
}