Exemplo n.º 1
0
    public void Answer(AnswerController button)
    {
        DisableAllAnswers();

        //Check if it's correct
        if (_taskLogic.isCorrect(button.num))
        {
            button.DisplayAsCorrect();
            score.AddCorrect();

            foreach (AnswerController answer in buttonAnswers)
            {
                answer.HideNumber();
            }

            //generate the next taks after a short delay
            StartCoroutine(_functionCaller.CallFunctionAfterDelay(1.2f, GenerateTask));
        }
        else
        {
            button.DisplayAsError();
            score.AddError();

            List <AnswerController> aviableAnswers = AviableAnswers();

            if (aviableAnswers.Count == 1) //if there is only one answer left reaveal it and hide it
            {
                if (aviableAnswers[0] != null)
                {
                    aviableAnswers[0].DisplayAsCorrect();
                }

                //generate the next taks after a short delay
                StartCoroutine(_functionCaller.CallFunctionAfterDelay(1.2f, GenerateTask));
            }
            else
            {
                StartCoroutine(_functionCaller.CallFunctionAfterDelay(1, EnableAllAnswers));
            }
        }
    }