Beispiel #1
0
        public void OnCorrectLetterHit(LetterController correctLetterCntrl)
        {
            if (ThrowBallsConfiguration.Instance.Variation == ThrowBallsVariation.BuildWord)
            {
                numLettersRemaining--;
                var word = ((LL_WordData)question).Data;

                if (flashingTextCoroutine != null)
                {
                    ThrowBallsGame.instance.StopCoroutine(flashingTextCoroutine);
                }

                if (numLettersRemaining == 0)
                {
                    string markedText = ArabicTextUtilities.GetWordWithMarkedText(word, Color.green);
                    UIController.instance.SetText(markedText);
                }
                else
                {
                    var letterToFlash = (LL_LetterData)currentLettersForLettersInWord[currentLettersForLettersInWord.Count - numLettersRemaining];
                    int numTimesLetterHasBeenFlashed = flashedLettersInLiWVariation.Count(x => x.Id == letterToFlash.Id);
                    var letterDataToFlash            = ArabicAlphabetHelper.FindLetter(AppManager.I.DB, word, letterToFlash.Data, false)[numTimesLetterHasBeenFlashed];
                    flashedLettersInLiWVariation.Add(letterToFlash);

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

                    ThrowBallsGame.instance.StartCoroutine(flashingTextCoroutine);
                }

                UIController.instance.WobbleLetterHint();

                if (numLettersRemaining != 0)
                {
                    UpdateLettersForLettersInWord(correctLetterCntrl);
                    BallController.instance.DampenVelocity();
                }
                else
                {
                    OnRoundWon(correctLetterCntrl);
                }
            }
            else
            {
                OnRoundWon(correctLetterCntrl);
            }
        }
Beispiel #2
0
        private void FlashLetter(LL_LetterData letterToFlash)
        {
            var word = ((LL_WordData)question).Data;
            int numTimesLetterHasBeenFlashed = flashedLettersInLiWVariation.Count(x => x.Id == letterToFlash.Id);
            var letterPartToFlash            = ArabicAlphabetHelper.FindLetter(AppManager.I.DB, word, letterToFlash.Data, false)[numTimesLetterHasBeenFlashed];

            flashedLettersInLiWVariation.Add(letterToFlash);

            int toCharIndex = letterPartToFlash.toCharacterIndex;

            if (letterPartToFlash.fromCharacterIndex != letterPartToFlash.toCharacterIndex)
            {
                var hexCode = ArabicAlphabetHelper.GetHexUnicodeFromChar(word.Arabic[letterPartToFlash.toCharacterIndex]);
                if (hexCode == "0651")   // Shaddah
                {
                    toCharIndex -= 1;
                }
            }

            flashingTextCoroutine = ArabicTextUtilities.GetWordWithFlashingText(word, letterPartToFlash.fromCharacterIndex, toCharIndex, Color.green, FLASHING_TEXT_CYCLE_DURATION, int.MaxValue,
                                                                                text => {
                UIController.instance.SetText(text);
            }, true);
        }
Beispiel #3
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();
            }
        }