Minor Code Updates, Quality Increases

 

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);
}
}



Leave a comment