private IEnumerator CheckCoroutine(List <PlaceholderBehaviour> placeholders, List <IQuestion> questions, IDragManager dragManager) { dragManager.DisableInput(); bool areAllCorrect = AreQuestionsCorrect(questions); if (areAllCorrect) { // Just trigger OnQuestionAnswered events if all are correct foreach (var q in questions) { var behaviour = q.gameObject.GetComponent <QuestionBehaviour>(); behaviour.OnQuestionAnswered(); AssessmentConfiguration.Instance.Context.GetLogManager().OnAnswer(q.LetterData(), true); yield return(TimeEngine.Wait(behaviour.TimeToWait())); } } else { foreach (var p in placeholders) { if (p.LinkedDroppable != null) { var set = p.Placeholder.GetQuestion().GetAnswerSet(); var answ = p.LinkedDroppable.GetAnswer(); if (set.IsCorrect(answ) == false) { AssessmentConfiguration.Instance.Context.GetLogManager().OnAnswer(answ.Data(), false); p.LinkedDroppable.Detach(true); } } } } allCorrect = areAllCorrect; while (wrongAnswerAnimationPlaying) { yield return(null); // wait only if previous message has not finished } if (allCorrect) { if (AppConstants.VerboseLogging) { Debug.Log("CheckCoroutine CORRECT"); } audioManager.PlaySound(Sfx.StampOK); yield return(TimeEngine.Wait(0.4f)); checkmarkWidget.Show(true); yield return(TimeEngine.Wait(1.0f)); } else { if (AppConstants.VerboseLogging) { Debug.Log("CheckCoroutine WRONG"); } wrongAnswerAnimationPlaying = true; Coroutine.Start(WrongAnswerCoroutine()); } coroutineEnded = true; dragManager.EnableInput(); }
private IEnumerator CheckCoroutine(List <PlaceholderBehaviour> placeholders, List <IQuestion> questions, IDragManager dragManager) { WrongSoundPlayed = false; CorrectSoundPlayed = false; dragManager.DisableInput(); bool areAllCorrect = AreQuestionsCorrect(questions); if (areAllCorrect) { // Log learning progress foreach (var p in placeholders) { if (p.LinkedDroppable != null) { var set = p.Placeholder.GetQuestion().GetAnswerSet(); var answ = p.LinkedDroppable.GetAnswer(); if (set.IsCorrect(answ)) { AssessmentConfiguration.Instance.Context.GetLogManager().OnAnswered(answ.Data(), true); } var pos = p.gameObject.transform.localPosition; pos.y -= 3.5f; MarkYes(pos); } } ItemFactory.Instance.GetAntura().CorrectAssessment(audioManager); // Just trigger OnQuestionAnswered events if all are correct foreach (var q in questions) { yield return(Wait.For(q.QuestionBehaviour.TimeToWait())); q.QuestionBehaviour.OnQuestionAnswered(); yield return(Wait.For(q.QuestionBehaviour.TimeToWait())); } } else { foreach (var p in placeholders) { if (p.LinkedDroppable != null) { var set = p.Placeholder.GetQuestion().GetAnswerSet(); var answ = p.LinkedDroppable.GetAnswer(); if (set.IsCorrect(answ) == false) { AssessmentConfiguration.Instance.Context.GetLogManager().OnAnswered(answ.Data(), false); PlayWrongSound(); p.LinkedDroppable.Detach(true); var pos = p.gameObject.transform.localPosition; pos.y -= 3.5f; TutorialUI.MarkNo(pos, TutorialUI.MarkSize.Normal); } else { var pos = p.gameObject.transform.localPosition; pos.y -= 3.5f; MarkYes(pos); } } } } allCorrect = areAllCorrect; while (wrongAnswerAnimationPlaying) { yield return(null); } if (allCorrect) { if (events != null && events.OnPreQuestionsAnswered != null) { yield return(new WaitCoroutine(events.OnPreQuestionsAnswered())); } yield return(Wait.For(1.0f)); } else { wrongAnswerAnimationPlaying = true; Koroutine.Run(WrongAnswerCoroutine()); } coroutineEnded = true; dragManager.EnableInput(); }