Example #1
0
        void UpdateQuestion(IQuestionPack questionPack)
        {
            hidePipesTimer      = 0;
            currentQuestionPack = questionPack;
            ResetLetters();

            questionLivingLetter = livingLetters[questionLetterIndex];
            ILivingLetterData correctAnswer = null;

            var correctAnswers = questionPack.GetCorrectAnswers();
            var correctList    = correctAnswers.ToList();

            correctAnswer = correctList[UnityEngine.Random.Range(0, correctList.Count)];

            if (ToboganConfiguration.Instance.Variation == ToboganVariation.SunMoon)
            {
                LL_WordData question = questionPack.GetQuestion() as LL_WordData;

                questionLivingLetter.SetQuestionText(question, 2, ToboganGame.LETTER_MARK_COLOR);
            }
            else
            {
                if (ToboganConfiguration.Instance.Difficulty <= 0.3f)
                {
                    questionLivingLetter.SetQuestionText(questionPack.GetQuestion() as LL_WordData, correctAnswer as LL_LetterData, ToboganGame.LETTER_MARK_COLOR);
                }
                else
                {
                    questionLivingLetter.SetQuestionText(questionPack.GetQuestion());
                }
            }

            var wrongAnswers = questionPack.GetWrongAnswers().ToList();

            // Shuffle wrong answers
            int n = wrongAnswers.Count;

            while (n > 1)
            {
                n--;
                int k     = UnityEngine.Random.Range(0, n + 1);
                var value = wrongAnswers[k];
                wrongAnswers[k] = wrongAnswers[n];
                wrongAnswers[n] = value;
            }

            game.pipesAnswerController.SetPipeAnswers(wrongAnswers, correctAnswer, sunMoonGameVariation);
        }
        public bool ShowChallengePopupWidget(bool showAsGoodAnswer, Action callback)
        {
            if (FastCrowdConfiguration.Instance.Variation == FastCrowdVariation.Spelling)
            {
                var popupWidget = Context.GetPopupWidget();
                popupWidget.Show();
                popupWidget.SetButtonCallback(callback);

                if (showAsGoodAnswer)
                {
                    popupWidget.SetTitle(Db.LocalizationDataId.Keeper_Good_5);
                    popupWidget.SetMark(true, true);
                }
                else
                {
                    popupWidget.SetTitle("" + QuestionNumber);
                }

                var question = CurrentQuestion.GetQuestion();
                popupWidget.SetLetterData(question);
                Context.GetAudioManager().PlayLetterData(question);
                return(true);
            }
            return(false);
        }
Example #3
0
        public void GenerateNewWord()
        {
            if (isSpelling)
            {
                IQuestionPack newQuestion = MixedLettersConfiguration.Instance.Questions.GetNextQuestion();
                question = newQuestion.GetQuestion();

                lettersInOrder = newQuestion.GetCorrectAnswers().ToList();
                VictimLLController.instance.letterObjectView.Init(question);
            }

            else
            {
                int numLettersPerRound = allLettersInAlphabet.Count / 6;
                int remainder          = allLettersInAlphabet.Count % 6;
                lettersInOrder = allLettersInAlphabet.GetRange(roundNumber * numLettersPerRound, roundNumber == 4 ? remainder : numLettersPerRound);
                VictimLLController.instance.letterObjectView.Init(null);

                string victimLLWord = "";

                for (int i = 0; i < lettersInOrder.Count; i++)
                {
                    victimLLWord += ((LL_LetterData)lettersInOrder[i]).Data.GetChar();

                    if (i != lettersInOrder.Count - 1)
                    {
                        victimLLWord += " ";
                    }
                }

                VictimLLController.instance.SetCustomText(victimLLWord);
            }
        }
Example #4
0
        void UpdateQuestion(IQuestionPack questionPack)
        {
            ResetLetters();

            questionLivingLetter = livingLetters[questionLetterIndex];

            questionLivingLetter.SetQuestionText(questionPack.GetQuestion());

            ILivingLetterData correctAnswer = null;

            var correctAnswers = questionPack.GetCorrectAnswers();
            var correctList    = correctAnswers.ToList();

            correctAnswer = correctList[UnityEngine.Random.Range(0, correctList.Count)];

            var wrongAnswers = questionPack.GetWrongAnswers().ToList();

            // Shuffle wrong answers
            int n = wrongAnswers.Count;

            while (n > 1)
            {
                n--;
                int k     = UnityEngine.Random.Range(0, n + 1);
                var value = wrongAnswers[k];
                wrongAnswers[k] = wrongAnswers[n];
                wrongAnswers[n] = value;
            }

            game.pipesAnswerController.SetPipeAnswers(wrongAnswers, correctAnswer, sunMoonGameVariation);
        }
Example #5
0
        public void GenerateNewWord()
        {
            if (isSpelling)
            {
                IQuestionPack newQuestionPack = MixedLettersConfiguration.Instance.Questions.GetNextQuestion();
                spellingQuestionPack = newQuestionPack;
                question             = newQuestionPack.GetQuestion();

                VictimLLController.instance.letterObjectView.Init(question);
            }

            else
            {
                VictimLLController.instance.letterObjectView.Init(null);

                string victimLLWord = "";

                for (int i = 0; i < PromptLettersInOrder.Count; i++)
                {
                    victimLLWord += ((LL_LetterData)PromptLettersInOrder[i]).Data.GetStringForDisplay();

                    if (i != PromptLettersInOrder.Count - 1)
                    {
                        victimLLWord += " ";
                    }
                }

                VictimLLController.instance.SetCustomText(victimLLWord);
            }
        }
        public IQuestion GetNextQuestion()
        {
            Debug.Log("GetNextQuestion");
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.QuestionFeeded;

            currentPack = provider.GetNextQuestion();

            List <IAnswer>    answers      = new List <IAnswer>();
            ILivingLetterData questionData = currentPack.GetQuestion();

            //____________________________________
            //Prepare answers for next method call
            //____________________________________


            foreach (var wrong in currentPack.GetWrongAnswers())
            {
                var wrongAnsw = GenerateWrongAnswer(wrong);

                answers.Add(wrongAnsw);
                totalAnswers.Add(wrongAnsw);
            }

            Debug.Log("PRE");
            int correctCount = 0;

            foreach (var correct in currentPack.GetCorrectAnswers())
            {
                var correctAnsw = GenerateCorrectAnswer(correct);
                Debug.Log("Added");
                correctCount++;
                answers.Add(correctAnsw);
                totalAnswers.Add(correctAnsw);
            }
            Debug.Log("POST");

            partialAnswers = answers.ToArray();

            // Generate the question
            var question = GenerateQuestion(questionData, correctCount);

            totalQuestions.Add(question);

            // Generate placeholders
            foreach (var correct in currentPack.GetCorrectAnswers())
            {
                GeneratePlaceHolder(question);
            }

            return(question);
        }
Example #7
0
        void OnAnswered(IQuestionPack pack, bool result)
        {
            requestNextQueston = true;
            nextQuestionTimer  = NEXT_QUESTION_TIME + REVEAL_TIME;

            game.questionsManager.OnQuestionEnd(REVEAL_TIME);

            game.OnResult(result);

            game.Context.GetLogManager().OnAnswered(pack.GetQuestion(), result);
        }
Example #8
0
        // ##################################
        //           AUXILIARY METHODS
        // ##################################

        private IQuestion CustomQuestion()
        {
            var correct = currentPack.GetCorrectAnswers().ToList()[0];

            // Generate the question (and set form for correct letter)
            var question = GenerateCustomQuestion(currentPack.GetQuestion(), correct as LL_LetterData);

            totalQuestions.Add(question);
            GeneratePlaceHolder(question, AssessmentOptions.Instance.AnswerType);

            // Generate Answer after having setted the correct form
            var correctAnsw = GenerateCorrectAnswer(correct);

            partialAnswers    = new Answer[1];
            partialAnswers[0] = correctAnsw;
            totalAnswers.Add(correctAnsw);

            return(question);
        }
Example #9
0
        public bool ShowChallengePopupWidget(bool showAsGoodAnswer, Action callback)
        {
            if (FastCrowdConfiguration.Instance.Variation == FastCrowdVariation.BuildWord)
            {
                var popupWidget = Context.GetPopupWidget();
                popupWidget.Show();
                popupWidget.SetButtonCallback(callback);

                if (showAsGoodAnswer)
                {
                    //popupWidget.SetTitle(Database.LocalizationDataId.Keeper_Good_5);
                    popupWidget.SetTitle("");
                    popupWidget.SetMark(true, true);
                }
                //else
                //    popupWidget.SetTitle("" + QuestionNumber);

                var question = CurrentQuestion.GetQuestion();
                popupWidget.SetLetterData(question);
                Context.GetAudioManager().PlayVocabularyData(question, soundType: FastCrowdConfiguration.Instance.GetVocabularySoundType());
                return(true);
            }
            return(false);
        }
Example #10
0
        public IEnumerator StartNewRound_Single()
        {
            ResetScene();

            if (!uiInitialised && !IsTutorialRound())
            {
                uiInitialised = true;

                game.Context.GetOverlayWidget().Initialize(true, false, true);
                game.Context.GetOverlayWidget().SetStarsThresholds(1, 3, 5);
                game.Context.GetOverlayWidget().SetMaxLives(MAX_NUM_BALLS);
            }

            IQuestionPack newQuestionPack = ThrowBallsConfiguration.Instance.Questions.GetNextQuestion();

            question = newQuestionPack.GetQuestion();
            ILivingLetterData        correctDatum = newQuestionPack.GetCorrectAnswers().ToList()[0];
            List <ILivingLetterData> wrongData    = newQuestionPack.GetWrongAnswers().ToList();

            if (ThrowBallsConfiguration.Instance.Variation == ThrowBallsVariation.Word ||
                ThrowBallsConfiguration.Instance.Variation == ThrowBallsVariation.Image)
            {
                correctDatum = new LL_ImageData(correctDatum.Id);

                for (int i = 0; i < wrongData.Count; i++)
                {
                    wrongData[i] = new LL_ImageData(wrongData[i].Id);
                }

                if (ThrowBallsConfiguration.Instance.Variation == ThrowBallsVariation.Image)
                {
                    question = new LL_ImageData(question.Id);
                }
            }

            SayQuestion();

            yield return(new WaitForSeconds(1f));

            int indexOfCorrectLetter = 0;

            if (game.Difficulty <= MiniGameController.EASY || IsTutorialRound())
            {
                for (int i = 0; i < NumLettersInCurrentRound; i++)
                {
                    letterPool[i].SetActive(true);
                }

                int indexOfUnobstructedLetter = 0;

                while (letterControllers[indexOfUnobstructedLetter].IsObstructedByOtherLetter())
                {
                    indexOfUnobstructedLetter++;
                }

                indexOfCorrectLetter = indexOfUnobstructedLetter;
            }

            var prevIndices = ExtractPrevIndices();

            for (int i = 0; i < NumLettersInCurrentRound; i++)
            {
                GameObject letterObj = letterPool[i];

                letterObj.SetActive(true);

                ConfigureLetterPropAndMotionVariation(letterControllers[i], prevIndices.Contains(i) ? prevMode : nextMode);

                if (i == indexOfCorrectLetter)
                {
                    letterObj.tag = Constants.CORRECT_LETTER_TAG;
                    letterControllers[i].SetData(correctDatum);
                    tutorialTarget = letterObj;
                }
                else
                {
                    letterObj.tag = Constants.WRONG_LETTER_TAG;
                    letterControllers[i].SetData(wrongData[0]);
                    wrongData.RemoveAt(0);
                }
            }

            isRoundOngoing = true;

            BallController.instance.Enable();

            UIController.instance.Enable();
            UIController.instance.EnableLetterHint();
            UIController.instance.SetLivingLetterData(question);

            if (IsTutorialRound())
            {
                audioManager.PlayDialogue(ThrowBallsConfiguration.Instance.TutorialLocalizationId);
                inputManager.Enabled = true;
                isVoiceOverDone      = true;
                ShowTutorialUI();
            }
        }
Example #11
0
        public IEnumerator StartNewRound()
        {
            ResetScene();

            if (!uiInitialised && !IsTutorialRound())
            {
                uiInitialised = true;


                game.Context.GetOverlayWidget().Initialize(true, false, true);
                game.Context.GetOverlayWidget().SetStarsThresholds(1, 3, 5);
                game.Context.GetOverlayWidget().SetMaxLives(MAX_NUM_BALLS);
            }

            IQuestionPack newQuestionPack = ThrowBallsConfiguration.Instance.Questions.GetNextQuestion();

            question = newQuestionPack.GetQuestion();

            ILivingLetterData        correctDatum = newQuestionPack.GetCorrectAnswers().ToList()[0];
            List <ILivingLetterData> wrongData    = newQuestionPack.GetWrongAnswers().ToList();

            if (ThrowBallsConfiguration.Instance.Variation == ThrowBallsVariation.Word)
            {
                correctDatum = new LL_ImageData(correctDatum.Id);

                for (int i = 0; i < wrongData.Count; i++)
                {
                    wrongData[i] = new LL_ImageData(wrongData[i].Id);
                }
            }

            SayQuestion();

            yield return(new WaitForSeconds(1f));

            int indexOfCorrectLetter = 0;

            if (game.Difficulty <= ThrowBallsGame.ThrowBallsDifficulty.Easy || IsTutorialRound())
            {
                for (int i = 0; i < NumLettersInCurrentRound; i++)
                {
                    letterPool[i].SetActive(true);
                }

                int indexOfUnobstructedLetter = 0;

                while (letterControllers[indexOfUnobstructedLetter].IsObstructedByOtherLetter())
                {
                    indexOfUnobstructedLetter++;
                }

                indexOfCorrectLetter = indexOfUnobstructedLetter;
            }

            for (int i = 0; i < NumLettersInCurrentRound; i++)
            {
                GameObject letterObj = letterPool[i];

                letterObj.SetActive(true);

                ConfigureLetterPropAndMotionVariation(letterControllers[i]);

                if (i == indexOfCorrectLetter)
                {
                    letterObj.tag = Constants.CORRECT_LETTER_TAG;
                    letterControllers[i].SetLetter(correctDatum);
                    tutorialTarget = letterObj;
                }
                else
                {
                    letterObj.tag = Constants.WRONG_LETTER_TAG;
                    letterControllers[i].SetLetter(wrongData[0]);
                    wrongData.RemoveAt(0);
                }
            }

            isRoundOngoing = true;

            BallController.instance.Enable();

            UIController.instance.Enable();
            UIController.instance.EnableLetterHint();
            UIController.instance.SetLivingLetterData(question);

            if (IsTutorialRound())
            {
                switch (ThrowBallsConfiguration.Instance.Variation)
                {
                case ThrowBallsVariation.LetterName:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_lettername_Tuto);
                    break;

                case ThrowBallsVariation.LetterAny:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_lettername_Tuto);
                    break;

                case ThrowBallsVariation.Word:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_word_Tuto);
                    break;

                case ThrowBallsVariation.BuildWord:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_buildword_Tuto);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                inputManager.Enabled = true;
                isVoiceOverDone      = true;
                ShowTutorialUI();
            }
        }
Example #12
0
        public EggChallenge(float difficulty, bool onlyLetter)
        {
            Letters  = new List <ILivingLetterData>();
            sequence = false;

            IQuestionPack questionPack = EggConfiguration.Instance.Questions.GetNextQuestion();

            List <ILivingLetterData> correctAnswers = new List <ILivingLetterData>();
            List <ILivingLetterData> wrongAnswers   = new List <ILivingLetterData>();

            Question = questionPack.GetQuestion();
            correctAnswers.AddRange(questionPack.GetCorrectAnswers());
            wrongAnswers.AddRange(questionPack.GetWrongAnswers());

            sequence = EggConfiguration.Instance.IsSequence();

            int numberOfLetters = 3;

            if (EggConfiguration.Instance.Variation == EggVariation.BuildWord)
            {
                numberOfLetters = 8;
            }
            else
            {
                if (sequence)
                {
                    if (difficulty < 0.5f)
                    {
                        numberOfLetters += UnityEngine.Mathf.RoundToInt(difficulty * 6);
                    }
                    else
                    {
                        numberOfLetters += UnityEngine.Mathf.RoundToInt((difficulty - 0.5f) * 4f);
                    }
                    if (numberOfLetters > 6)
                    {
                        numberOfLetters = 6;
                    }
                }
                else
                {
                    numberOfLetters += (int)(difficulty * 5);

                    if (numberOfLetters > 8)
                    {
                        numberOfLetters = 8;
                    }
                }
            }

            if (!sequence)
            {
                Letters.Add(correctAnswers[0]);

                numberOfLetters -= 1;

                if (numberOfLetters > wrongAnswers.Count)
                {
                    numberOfLetters = wrongAnswers.Count;
                }

                for (int i = 0; i < numberOfLetters; i++)
                {
                    Letters.Add(wrongAnswers[i]);
                }
            }
            else
            {
                if (numberOfLetters > correctAnswers.Count)
                {
                    numberOfLetters = correctAnswers.Count;
                }

                for (int i = 0; i < numberOfLetters; i++)
                {
                    Letters.Add(correctAnswers[i]);
                }
            }
        }
Example #13
0
        public IQuestion GetNextQuestion()
        {
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.QuestionFeeded;

            currentPack = provider.GetNextQuestion();

            if (config == DefaultQuestionType.MissingForm || config == DefaultQuestionType.VisibleForm)
            {
                return(CustomQuestion());
            }

            List <Answer>     answers      = new List <Answer>();
            ILivingLetterData questionData = currentPack.GetQuestion();

            //____________________________________
            //Prepare answers for next method call
            //____________________________________


            foreach (var wrong in currentPack.GetWrongAnswers())
            {
                var wrongAnsw = GenerateWrongAnswer(wrong);

                answers.Add(wrongAnsw);
                totalAnswers.Add(wrongAnsw);
            }

            int    correctCount      = 0;
            Answer greenAnswerLetter = null;

            foreach (var correct in currentPack.GetCorrectAnswers())
            {
                var correctAnsw = GenerateCorrectAnswer(correct);
                if (correctCount == 0)
                {
                    greenAnswerLetter = correctAnsw;
                }
                correctCount++;
                answers.Add(correctAnsw);
                totalAnswers.Add(correctAnsw);
            }

            partialAnswers = answers.ToArray();

            // Generate the question
            var question = GenerateQuestion(questionData, correctCount);

            totalQuestions.Add(question);
            greenHighlightList.Add(new Tuple <IQuestion, Answer>(question, greenAnswerLetter));

            // Generate placeholders
            foreach (var correct in currentPack.GetCorrectAnswers())
            {
                GeneratePlaceHolder(question, AssessmentOptions.Instance.AnswerType);
            }
            return(question);
        }
Example #14
0
        public IEnumerator StartNewRound_LettersInWord()
        {
            IQuestionPack newQuestionPack = ThrowBallsConfiguration.Instance.Questions.GetNextQuestion();

            List <ILivingLetterData> letterData = newQuestionPack.GetCorrectAnswers().ToList();

            numLettersRemaining = letterData.Count;
            numLetters          = numLettersRemaining;

            ResetScene();

            if (roundNumber == 1)
            {
                MinigamesUI.Init(MinigamesUIElement.Lives | MinigamesUIElement.Starbar);
                MinigamesUI.Lives.Setup(MAX_NUM_BALLS);
            }

            UIController.instance.Enable();

            ILivingLetterData firstLetter = letterData[0];

            letterData.RemoveAt(0);
            List <ILivingLetterData> remainingLetters = letterData;

            question = newQuestionPack.GetQuestion();
            UIController.instance.SetLetterHint(question);

            SayQuestion();

            yield return(new WaitForSeconds(1f));

            int numLettersInRound = remainingLetters.Count + 1;

            for (int i = 0; i < numLettersInRound; i++)
            {
                GameObject letterObj = letterPool[i];

                letterObj.SetActive(true);

                letterControllers[i].SetMotionVariation(GetMotionOfRound());

                letterControllers[i].SetPropVariation(GetPropOfRound());

                if (i == 0)
                {
                    letterObj.tag = Constants.TAG_CORRECT_LETTER;
                    letterControllers[i].SetLetter(firstLetter);
                }

                else
                {
                    if (remainingLetters[0].Id == firstLetter.Id)
                    {
                        letterObj.tag = Constants.TAG_CORRECT_LETTER;
                    }

                    else
                    {
                        letterObj.tag = Constants.TAG_WRONG_LETTER;
                    }

                    letterControllers[i].SetLetter(remainingLetters[0]);

                    remainingLetters.RemoveAt(0);
                }
            }

            isRoundOngoing = true;

            BallController.instance.Enable();

            if (IsTutorialLevel())
            {
                switch (ThrowBallsConfiguration.Instance.Variation)
                {
                case ThrowBallsVariation.letters:
                    audioManager.PlayDialogue(Db.LocalizationDataId.ThrowBalls_letters_Tuto);
                    break;

                case ThrowBallsVariation.words:
                    audioManager.PlayDialogue(Db.LocalizationDataId.ThrowBalls_words_Tuto);
                    break;

                case ThrowBallsVariation.lettersinword:
                    audioManager.PlayDialogue(Db.LocalizationDataId.ThrowBalls_letterinword_Tuto);
                    break;

                default:
                    break;
                }

                inputManager.Enabled = true;
                isVoiceOverDone      = true;
                ShowTutorialUI();
            }
        }
Example #15
0
        public IEnumerator StartNewRound_LettersInWord()
        {
            IQuestionPack newQuestionPack = ThrowBallsConfiguration.Instance.Questions.GetNextQuestion();

            currentLettersForLettersInWord = newQuestionPack.GetCorrectAnswers().ToList();

            numLettersRemaining = currentLettersForLettersInWord.Count;

            ResetScene();

            List <int> sortedIndices = SortLettersByZIndex(currentLettersForLettersInWord.Count);

            if (!uiInitialised && !IsTutorialRound())
            {
                uiInitialised = true;
                game.Context.GetOverlayWidget().Initialize(true, false, true);
                game.Context.GetOverlayWidget().SetStarsThresholds(1, 3, 5);
                game.Context.GetOverlayWidget().SetMaxLives(MAX_NUM_BALLS);
            }

            question = newQuestionPack.GetQuestion();
            SayQuestion();

            yield return(new WaitForSeconds(1f));

            UIController.instance.Enable();
            UIController.instance.EnableLetterHint();
            UIController.instance.SetLivingLetterData(question);

            var letterToFlash = (LL_LetterData)currentLettersForLettersInWord[0];

            FlashLetter(letterToFlash);

            var prevIndices = ExtractPrevIndices();

            for (int i = 0; i < currentLettersForLettersInWord.Count; i++)
            {
                int        letterObjectIndex = game.Difficulty <= MiniGameController.EASY ? sortedIndices[i] : i;
                GameObject letterObj         = letterPool[letterObjectIndex];

                letterObj.SetActive(true);

                ConfigureLetterPropAndMotionVariation(letterControllers[letterObjectIndex], prevIndices.Contains(i) ? prevMode : nextMode);

                letterControllers[letterObjectIndex].SetData(currentLettersForLettersInWord[i]);
                letterObj.tag = currentLettersForLettersInWord[i].Id == currentLettersForLettersInWord[0].Id ? Constants.CORRECT_LETTER_TAG : Constants.WRONG_LETTER_TAG;

                if (i == 0)
                {
                    tutorialTarget = letterObj;
                }
            }

            isRoundOngoing = true;

            BallController.instance.Enable();

            if (IsTutorialRound())
            {
                switch (ThrowBallsConfiguration.Instance.Variation)
                {
                case ThrowBallsVariation.LetterName:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_lettername_Tuto);
                    break;

                case ThrowBallsVariation.LetterAny:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_lettername_Tuto);
                    break;

                case ThrowBallsVariation.Word:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_word_Tuto);
                    break;

                case ThrowBallsVariation.Image:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_image_Tuto);
                    break;

                case ThrowBallsVariation.BuildWord:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_buildword_Tuto);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                inputManager.Enabled = true;
                isVoiceOverDone      = true;
                ShowTutorialUI();
            }
        }
        public IQuestion GetNextQuestion()
        {
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.QuestionFeeded;

            currentPack = provider.GetNextQuestion();

            List <IAnswer>    answers      = new List <IAnswer>();
            ILivingLetterData questionData = currentPack.GetQuestion();

            //____________________________________
            //Prepare answers for next method call
            //____________________________________

            if (missingLetter)
            {
                // ### MISSING LETTER ###
                foreach (var wrong in currentPack.GetWrongAnswers())
                {
                    var wrongAnsw = GenerateWrongAnswer(wrong);

                    answers.Add(wrongAnsw);
                    totalAnswers.Add(wrongAnsw);
                }

                var correct     = currentPack.GetCorrectAnswers().ToList()[0];
                var correctAnsw = GenerateCorrectAnswer(correct);

                answers.Add(correctAnsw);
                totalAnswers.Add(correctAnsw);

                partialAnswers = answers.ToArray();

                // Generate the question
                var question = GenerateMissingLetterQuestion(questionData, correct);
                totalQuestions.Add(question);
                GeneratePlaceHolder(question);
                return(question);
            }
            else
            {
                // ### ORDER LETTERS ###
                foreach (var correct in currentPack.GetCorrectAnswers())
                {
                    var correctAnsw = GenerateCorrectAnswer(correct);
                    answers.Add(correctAnsw);
                    totalAnswers.Add(correctAnsw);
                }

                partialAnswers = answers.ToArray();

                // Generate the question
                var question = GenerateQuestion(questionData);
                totalQuestions.Add(question);

                return(question);
            }
        }
Example #17
0
        public IEnumerator StartNewRound_LettersInWord()
        {
            IQuestionPack newQuestionPack = ThrowBallsConfiguration.Instance.Questions.GetNextQuestion();

            currentLettersForLettersInWord = newQuestionPack.GetCorrectAnswers().ToList();

            numLettersRemaining = currentLettersForLettersInWord.Count;

            ResetScene();

            List <int> sortedIndices = SortLettersByZIndex(currentLettersForLettersInWord.Count);

            if (!uiInitialised && !IsTutorialRound())
            {
                uiInitialised = true;
                game.Context.GetOverlayWidget().Initialize(true, false, true);
                game.Context.GetOverlayWidget().SetStarsThresholds(1, 3, 5);
                game.Context.GetOverlayWidget().SetMaxLives(MAX_NUM_BALLS);
            }

            question = newQuestionPack.GetQuestion();
            SayQuestion();

            yield return(new WaitForSeconds(1f));

            UIController.instance.Enable();
            UIController.instance.EnableLetterHint();
            UIController.instance.SetLivingLetterData(question);

            var letterToFlash = (LL_LetterData)currentLettersForLettersInWord[0];

            var letterDataToFlash = ArabicAlphabetHelper.FindLetter(AppManager.I.DB, ((LL_WordData)question).Data, letterToFlash.Data, false)[0];

            flashingTextCoroutine = ArabicTextUtilities.GetWordWithFlashingText(((LL_WordData)question).Data, letterDataToFlash.fromCharacterIndex, letterDataToFlash.toCharacterIndex, Color.green, FLASHING_TEXT_CYCLE_DURATION, int.MaxValue,
                                                                                (string text) => {
                UIController.instance.SetText(text);
            }, false);

            flashedLettersInLiWVariation.Add(letterToFlash);

            ThrowBallsGame.instance.StartCoroutine(flashingTextCoroutine);

            for (int i = 0; i < currentLettersForLettersInWord.Count; i++)
            {
                int        letterObjectIndex = game.Difficulty <= ThrowBallsGame.ThrowBallsDifficulty.Easy ? sortedIndices[i] : i;
                GameObject letterObj         = letterPool[letterObjectIndex];

                letterObj.SetActive(true);

                ConfigureLetterPropAndMotionVariation(letterControllers[letterObjectIndex]);

                letterControllers[letterObjectIndex].SetLetter(currentLettersForLettersInWord[i]);
                letterObj.tag = currentLettersForLettersInWord[i].Id == currentLettersForLettersInWord[0].Id ? Constants.CORRECT_LETTER_TAG : Constants.WRONG_LETTER_TAG;

                if (i == 0)
                {
                    tutorialTarget = letterObj;
                }
            }

            isRoundOngoing = true;

            BallController.instance.Enable();

            if (IsTutorialRound())
            {
                switch (ThrowBallsConfiguration.Instance.Variation)
                {
                case ThrowBallsVariation.LetterName:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_lettername_Tuto);
                    break;

                case ThrowBallsVariation.LetterAny:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_lettername_Tuto);
                    break;

                case ThrowBallsVariation.Word:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_word_Tuto);
                    break;

                case ThrowBallsVariation.BuildWord:
                    audioManager.PlayDialogue(Database.LocalizationDataId.ThrowBalls_buildword_Tuto);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                inputManager.Enabled = true;
                isVoiceOverDone      = true;
                ShowTutorialUI();
            }
        }