So i got 10 questions, so when the game starts, example the starting question is "4 out of 10" then if the next question is random to "10 out of 10" the game ends. what i want is to random the 10 questions:
private int idMode;
public Text question;
public Text answerA;
public Text answerB;
public Text answerC;
public Text answerD;
public Text infoAnswer;
public Text stat;
public string[] questions;
public string[] alternativeA;
public string[] alternativeB;
public string[] alternativeC;
public string[] alternativeD;
public string[] correct;
private int idQuestion;
private float points;
private float fact;
private float average;
private int results;
void Start () {
idMode = PlayerPrefs.GetInt ("idMode");
idQuestion = 0;
fact = questions.Length;
question.text = questions [idQuestion];
answerA.text = alternativeA [idQuestion];
answerB.text = alternativeB [idQuestion];
answerC.text = alternativeC [idQuestion];
answerD.text = alternativeD [idQuestion];
infoAnswer.text = (idQuestion + 1).ToString() + " of " + fact.ToString () + "";
}
public void answer(string alternative)
{
if (alternative == "A") {
if (alternativeA [idQuestion] == correct [idQuestion]) {
points += 1;
} else {
}
}
if (alternative == "B") {
if (alternativeB [idQuestion] == correct [idQuestion]) {
points += 1;
} else {
}
}
if (alternative == "C") {
if (alternativeC [idQuestion] == correct [idQuestion]) {
points += 1;
} else {
}
}
if (alternative == "D") {
if (alternativeD [idQuestion] == correct [idQuestion]) {
points += 1;
} else {
}
}
nextQuestion ();
}
void nextQuestion()
{
idQuestion += Random.Range(0,10);
if(idQuestion <= (fact-1))
{
question.text = questions [idQuestion];
answerA.text = alternativeA [idQuestion];
answerB.text = alternativeB [idQuestion];
answerC.text = alternativeC [idQuestion];
answerD.text = alternativeD [idQuestion];
stat.text = " Correct: " + points.ToString () + "";
infoAnswer.text = (idQuestion + 1).ToString() + " of " + fact.ToString () + "";
}
else
{
average = 10 * (points / fact);
results = Mathf.RoundToInt (average);
if (results > PlayerPrefs.GetInt ("results" + idMode.ToString ())) {
PlayerPrefs.SetInt ("results" + idMode.ToString (), results);
PlayerPrefs.SetInt ("points" + idMode.ToString (), (int)points);
}
PlayerPrefs.SetInt ("resultsTemp" + idMode.ToString (), results);
PlayerPrefs.SetInt ("pointsTemp" + idMode.ToString (), (int)points);
Application.LoadLevel("results");
}
}
}