我正在进行问答游戏。我有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