private void Start() { //Contains each line of the exercise being read Queue <string> exercise = new Queue <string>(); //The worksheet is named after the school day it is associated too //As this school day has just been finished we -1. string fileName = (FindObjectOfType <GameManager>().GetSchoolDay() - 1).ToString(); StreamReader reader = File.OpenText(Application.dataPath + "/StreamingAssets/Worksheet/" + fileName + ".txt"); string line = reader.ReadLine(); int numInputFields = 0; bool firstLine = true; while (line != null) { if (firstLine) { firstLine = false; educationReward = int.Parse(line); } else { if (line.Contains("<if>")) { numInputFields++; } if (line == "<mc>" || line == "<h>") { numExercies++; } else if (line == "</mc>") { //Instantiate the dropdown prefab GameObject obj = Instantiate(dropdown, content.text.transform); exercises.Enqueue(new MultipleChoice(exercise, content, output, obj, this)); } else if (line == "</h>") { //Instantiate the inputfield prefab List <GameObject> objects = new List <GameObject>(); for (int i = 0; i < numInputFields; i++) { objects.Add(Instantiate(inputField, content.text.transform)); } numInputFields = 0; exercises.Enqueue(new HaskellQuestion(exercise, content, output, objects, this, Application.dataPath)); } else { exercise.Enqueue(line); } } line = reader.ReadLine(); } reader.Close(); totalExercises.text = numExercies.ToString(); //Display the first exercise currentExercise = exercises.Dequeue(); currentExercise.Display(); RunButton(); }
public void Next() { currentExercise.Destroy(); currentExercise = exercises.Dequeue(); currentExercise.Display(); RunButton(); next.interactable = false; if (exercises.Count == 0) { next.gameObject.SetActive(false); exit.gameObject.SetActive(true); } }