Exemplo n.º 1
0
 public void OverrideQuestion(Pergunta newQuestion)
 {
     correctAnswer = newQuestion.GetCorrectAnswer();
     for (int i = 0; i < alternative.Length; i++)
     {
         alternative[i] = newQuestion.GetAlternative(i);
     }
 }
Exemplo n.º 2
0
    /// <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();
    }