Storing my choose your own adventure questions/actions


I’m in the middle of developing a simple “choose your own adventure” style of game in Unity/C#.

I’m thinking about how I’m going to store my questions:

“You walk into a dark room and see a man in the corner of the room. What do you do?”

and actions “Sneak up on him” or “Try to get by him”

Seeing as I’m going to have a lot of questions and actions, I was thinking of maybe storing them all in some form of database and getting Unity to pull information from it.
What would you suggest? sql? csv? or something else?

i think sql or a external database might be extreme for a couple hundred or even a couple thousand questions.
i dont think your game would have more than that.

a simple txt document in your asset folder should work fine.
remember … text really doesnt take up much storage. even a thousand average sentences wont even add up to a megabyte.

if you want to change things as you go you could download your text from a server.

here is an example of grabbing text from a text file and pushing it into quick organized arrays for your game. you would just use separator characters in your text document.

parcing out the data might slow you down for however many microseconds when the game starts but im sure its still faster than making a connection to a server.

public TextAsset load;//<-- drag and drop your textfile here
	public string data;
	[System.Serializable]//<--remove this line in your real build for speed!!!!
	public class Conversation{
		public string Question;
		public string[] PossibleAnswers;
        public Conversation(string s){
			string[] a = s.Split("="[0]);
			Question = a[0];
			PossibleAnswers = a[1].Split(","[0]);}

    public Conversation[] database;
	void Start () {
if (load == null) {
			            // this is example of what your text file could look like
			            // notice the seperator characters so we can read it. 
						data = "monkeys eat?=bannannas,potatoes,green beans*game developers are?=smart,nerdy*toads are?=green,pink,blue";
				} else {data = load.text;}
		string[] a = data.Split ("*" [0]);

		int i = a.Length;
        database = new Conversation*;*

while(i>0){i–;database_=new Conversation(a*);}*_

* //your questions are now loaded with cooresponing answers*
* // here is a print out of what the script found in the text so you can see*

while (i<database.Length) {
_ print(“question #”+i+" is:"+database*.Question);
int i2 = 0;
print ("possible answer: "+database.PossibleAnswers[i2]);*