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

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s