I'm trying to implement a dialogue system for a game in Unity(c#). I'm going to use xml cause I want the dialogues to be editable/added from outside. I have a practical problem.
Let's say I got this line in XML:
<Action character="MC" name="giveItem" item="Potion" quantity="2"/>
This should tell to the inventory system of the main character that it has to give him 2 potions.
As example, not actual implementation:
MainCharacter.Inventory.giveItem("Potion",2)
The question is: With the name and parameters of the method from the XML, how do I call it? And how I call other methods that i'll need in my dialogue scripts? So far I've seen reflection and maybe a dictionary of delegates, but I'dont know is there is a better way and if those are bad practices.
Dictionary<string, delegateType>
seems like a perfectly reasonable solution. I have to ask again though, have you tried to implement it, and have you had any specific problem that needs improving? If you're only speculating, you should definitely try a solution and see if it works. – Seth Battin Feb 22 at 23:01