void Start() { _functionCaller = new FunctionCaller(); //[TO DO]: Avoid "new" (D in SOLID) _taskLogic = new TaskLogic(); //[TO DO]: Avoid "new" (D in SOLID) _taskLogic.LoadNumbers(); StartCoroutine(_functionCaller.CallFunctionAfterDelay(0.5f, GenerateTask)); //give time to read file }
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)); } } }