Beispiel #1
0
        void OnAnswered(CircleButton clickedButton)
        {
            if (Finished)
            {
                return;
            }
            Finished = true;
            game.DisableRepeatPromptButton();

            if (ReadingGameConfiguration.Instance.ShowTimer && !TutorialMode)
            {
                UI.MinigamesUI.Timer.Pause();
            }

            bool isCorrect = clickedButton != null && DataMatchingHelper.IsDataMatching(clickedButton.Answer, correctLLData, LetterEqualityStrictness.Letter);

            game.Context.GetAudioManager().PlaySound(isCorrect ? Sfx.OK : Sfx.KO);

            if (isCorrect)
            {
                clickedButton?.SetColor(Color.green);
            }
            else
            {
                if (clickedButton != null)
                {
                    TutorialUI.MarkNo(clickedButton.transform.position);
                }
            }

            if (ReadingGameConfiguration.Instance.CurrentGameType == ReadingGameConfiguration.GameType.ReadAndListen)
            {
                if (isCorrect)
                {
                    correctLLData = new LL_ImageData(correctLLData.Id);
                    var runLetter = game.runLettersBox.AddRunLetter(correctLLData, Vector3.one * 4);
                    runLetter.Stop();
                    runLetter.PlayAnimation(LLAnimationStates.LL_dancing);
                }
                else
                {
                    game.runLettersBox.AnimateAll(LLAnimationStates.LL_tickling);
                }

                // First read the answer you clicked
                if (clickedButton != null)
                {
                    game.Context.GetAudioManager().PlayVocabularyData(clickedButton.Answer, autoClose: false, callback: () =>
                    {
                        // Then read the one that is correct, if not already correct, and highlight it
                        if (!isCorrect)
                        {
                            if (TutorialMode)
                            {
                                Finished = false;
                            }
                            else
                            {
                                correctButton.SetColor(Color.green);
                                game.Context.GetAudioManager().PlayVocabularyData(correctButton.Answer,
                                                                                  callback: () =>
                                {
                                    // Then translate the sentence
                                    game.Context.GetAudioManager().PlayVocabularyData(
                                        game.CurrentQuestion.GetQuestion(),
                                        autoClose: false,
                                        keeperMode: KeeperMode.NativeNoSubtitles,
                                        callback: () => { Next(isCorrect, clickedButton); });
                                });
                            }
                        }
                        else
                        {
                            // Just translate the sentence
                            game.Context.GetAudioManager().PlayVocabularyData(game.CurrentQuestion.GetQuestion(),
                                                                              autoClose: false,
                                                                              keeperMode: KeeperMode.NativeNoSubtitles, callback: () =>
                            {
                                Next(isCorrect, clickedButton);
                            });
                        }
                    });
                }
                else
                {
                    // Time out. Just as if you failed.
                    if (TutorialMode)
                    {
                        Finished = false;
                    }
                    else
                    {
                        correctButton.SetColor(Color.green);
                        game.Context.GetAudioManager().PlayVocabularyData(correctButton.Answer,
                                                                          callback: () =>
                        {
                            // Then translate the sentence
                            game.Context.GetAudioManager().PlayVocabularyData(
                                game.CurrentQuestion.GetQuestion(),
                                autoClose: false,
                                keeperMode: KeeperMode.NativeNoSubtitles,
                                callback: () => { Next(isCorrect, clickedButton); });
                        });
                    }
                }
            }
            else
            {
                Next(isCorrect, clickedButton);
            }
        }