Beispiel #1
0
    private IEnumerator AnswerDelay(int answer, float delay)
    {
        answered = true;
        if (quiz.IsAnswerRight(answer))
        {
            quiz.RemoveQuestion(quiz.GetQuestion());
            IncreaseScore();

            if (quiz.IsQuestionListEmpty())
            {
                GameOver();
            }
            else
            {
                audio.PlayRightAnswerAudio();
            }

            alternativesButtons[answer].GetComponent <Image>().sprite = rightAnswerColor;

            yield return(new WaitForSeconds(delay));

            alternativesButtons[answer].GetComponent <Image>().color = Color.white;
            questionPanel.SetActive(false);
        }
        else
        {
            DecreaseScore();
            audio.PlayWrongAnswerAudio();
            alternativesButtons[answer].GetComponent <Image>().sprite = wrongAnswerColor;

            yield return(new WaitForSeconds(delay));

            alternativesButtons[answer].GetComponent <Image>().color = Color.white;
            questionPanel.SetActive(false);
        }
        answered = false;
    }