public void OverrideQuestion(Pergunta newQuestion) { correctAnswer = newQuestion.GetCorrectAnswer(); for (int i = 0; i < alternative.Length; i++) { alternative[i] = newQuestion.GetAlternative(i); } }
/// <summary> /// Função que verifica a resposta e mostra o feedback /// </summary> /// <param name="value"></param> /// <returns></returns> private IEnumerator VerifyAnswer(int value) { /// Incrementa o contador de perguntas feitas qtyQuestionsDone++; /// Salva a alternativa escolhida questionAndAnswer[index].SetAnswerSelected(value); /// Verifica se a alternativa é a correta bool isCorrect = questionGroup[dificulty].GetQuestion(questionSelected).VerifyAnswer(value); /// Se for correta if (isCorrect) { /// Incrementa a pontuação e mostra o feedback positivo correctAnswers++; questionAndAnswer[index].SetIsCorrect(true); GameObject tempCorrectFeedback = Instantiate(correctFeedback, answerMeshText[value].transform.parent); tempCorrectFeedback.transform.SetSiblingIndex(0); yield return(new WaitForSeconds(3f)); Destroy(tempCorrectFeedback); } else /// Caso contrário { /// Mostra o feedback "negativo" questionAndAnswer[index].SetIsCorrect(false); if (value != -1) { GameObject tempCorrectFeedback = Instantiate(correctFeedback, answerMeshText[selectedQuestion.GetCorrectAnswer()].transform.parent); GameObject tempWrongFeedback = Instantiate(wrongFeedback, answerMeshText[value].transform.parent); tempCorrectFeedback.transform.SetSiblingIndex(0); tempWrongFeedback.transform.SetSiblingIndex(0); yield return(new WaitForSeconds(3f)); Destroy(tempCorrectFeedback); Destroy(tempWrongFeedback); } } PrepareNewQuestion(); }