我正在進行問答遊戲。我有10個問題,但在回答完所有問題後,它只是不斷產生問題,所以我想在這裏發生的只是回答10個問題,並轉到下一個面板或場景上的得分結果。 請幫幫我。停止生成問題
public Question[] questions;
private static List<Question> unansweredQuestions;
private Question currentQuestion;
[SerializeField]
private Text questionText;
[SerializeField]
private Text trueAnswerText;
[SerializeField]
private Text falseAnswerText;
[SerializeField]
private Animator animator;
[SerializeField]
private float timeBetweenQuestions = 1;
void Start()
{
if (unansweredQuestions == null || unansweredQuestions.Count == 0)
{
unansweredQuestions = questions.ToList<Question>();
}
SetCurrentQuestion();
}
void SetCurrentQuestion()
{
int randomQuestionIndex = Random.Range (0, unansweredQuestions.Count);
currentQuestion = unansweredQuestions [randomQuestionIndex];
questionText.text = currentQuestion.question;
if (currentQuestion.isTrue)
{
trueAnswerText.text = "CORRECT";
falseAnswerText.text = "WRONG";
}else
{
trueAnswerText.text = "WRONG";
falseAnswerText.text = "CORRECT";
}
}
IEnumerator TransitionToNextQuestion()
{
unansweredQuestions.Remove(currentQuestion);
yield return new WaitForSeconds (timeBetweenQuestions);
SceneManager.LoadScene (SceneManager.GetActiveScene().buildIndex);
}
public void UserSelectTrue()
{
animator.SetTrigger ("True");
if (currentQuestion.isTrue)
{
Debug.Log ("CORRECT");
} else
{
Debug.Log ("WRONG");
}
StartCoroutine(TransitionToNextQuestion());
}
public void UserSelectFalse()
{
animator.SetTrigger ("False");
if (!currentQuestion.isTrue)
{
Debug.Log ("CORRECT");
} else
{
Debug.Log ("WRONG");
}
StartCoroutine(TransitionToNextQuestion());
}
}
我不確定單詞「直到」是你實際上的意思..「直到」繼續澆水,直到杯子已滿.. – BugFinder
我的意思是,如果所有的10個問題都回答它將移動到下一個面板。 – Magillanica
那麼你具體有什麼問題? – BugFinder