I am working on a game in C#.
I have a list of events, that can happen. E.g
List<Event> _events = new List<Event>();
_events.Add(new Event("A goblin approaches", 2));
_events.Add(new Event("A gang of thieves approaches", 3));
_events.Add(new Event("Some money has been stolen", 3));
_events.Add(new Event("Three goblins approach", 4));
_events.Add(new Event("A guard dies of unknown causes",4));
The string in the Event constructor is the event name and the number is the difficulty.
I was wondering if I could also add code into the constructor that can be run later on if the event is called. I'd like different code in each event.
Something like
_events.Add(new Event("Some money has been stolen", 3, "Supply.Gold = Supply.Gold -50"));
_events[2].runcode
I hope this makes sense, thanks