public FBQData pickRandomQuestion() { int questionType = Random.Range(0, questionList.Count); //picks a random question type from the list FBQData returnData = questionList[questionType](); //executes the function corresponding to the new question type return(returnData); }
//Generates a new question void newQuestion() { //FBQData qData = fbq.pickRandomQuestion(); //The method from the other class that picks a random question FBQData qData = fbq.pickRandomQuestion(questionTypes); //The method from the other class that picks a random question codeQuestion.GetComponent <Text>().text = qData.code; //gets the code, feedback, and answer from the returned object wrongAnswerFeedback = qData.feedback; correctAnswer = qData.answer; }
//Allows the user to restrict random questions to certain types public FBQData pickRandomQuestion(int[] questionTypes) { //Checks if the indicies are in range. If not, aborts foreach (int x in questionTypes) { if (x >= questionList.Count || x < 0) { Debug.Log("Numbers in questionTypes are out of Range. Adjust the values placed into the inspector."); Debug.Log(questionList.Count + " " + x); return(new FBQData("", "", 0)); } } FBQData returnData = questionList[questionTypes[Random.Range(0, questionTypes.Length)]](); //executes the function corresponding to the new question type return(returnData); }