Minor Code Updates, Quality Increases
Posted: July 18, 2014 Filed under: Uncategorized Leave a comment
I don’t get questions purely at random now;
this ensures I get all of the questions once before I get any question more than once
static List<int> NumberList = new List<int> ();
static int GetQuestionIndex() {
if (NumberList.Count == 0) {
FillList();
}
int RandomIndex = Random.Range (0, NumberList.Count);
int ReturnValue = NumberList [RandomIndex];
NumberList.RemoveAt (RandomIndex);
return ReturnValue;
}
static void FillList() {
NumberList.Clear ();
for(int i = 0; i < QuestionList.questions.Length; i++) {
NumberList.Add (i);
}
}