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); }
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); }
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); } }
protected override void OnInitialize(IGameContext context) { //float difficulty = FastCrowdConfiguration.Instance.Difficulty; TutorialIntroState = new TakeMeHomeTutorialIntroState(this); TutorialPlayState = new TakeMeHomeTutorialPlayState(this); TutorialResetState = new TakeMeHomeTutorialResetState(this); IntroductionState = new TakeMeHomeIntroductionState(this); PlayState = new TakeMeHomePlayState(this); ResultState = new TakeMeHomeResultState(this); EndState = new TakeMeHomeEndState(this); ResetState = new TakeMeHomeResetState(this); AntureState = new TakeMeHomeAnturaState(this); InitTubes(); //setup timer and round info: currentRound = 0; Context.GetAudioManager().PlayMusic(Music.Lullaby); //add antura specific script: antura.AddComponent <TakeMeHomeAntura>(); isTimesUp = false; IQuestionPack newQuestionPack = TakeMeHomeConfiguration.Instance.Questions.GetNextQuestion(); allLetters = (List <ILivingLetterData>)newQuestionPack.GetCorrectAnswers(); string abcd = "ABCD"; for (int i = 0; i < allLetters.Count; ++i) { int index = abcd.IndexOf(((LL_LetterData)allLetters[i]).Data.SoundZone); if (!allTubes[index].activeSelf) { activeTubes.Add(allTubes[index]); allTubes[index].SetActive(true); } } //check that we have at least 2 active tubes: if (activeTubes.Count == 1) { //pink anything random int index = UnityEngine.Random.Range(0, allTubes.Count); while (allTubes[index].activeSelf == true) { index = UnityEngine.Random.Range(0, allTubes.Count); } activeTubes.Add(allTubes[index]); allTubes[index].SetActive(true); } }
void initCurrentLetter() { if (gameEnded) { return; } currentCharacter = null; currentTutorial = null; TutorialUI.Clear(false); addLine(); //get a new letter: IQuestionPack newQuestionPack = MazeConfiguration.Instance.Questions.GetNextQuestion(); List <ILivingLetterData> ldList = (List <ILivingLetterData>)newQuestionPack.GetCorrectAnswers(); LL_LetterData ld = (LL_LetterData)ldList[0]; int index = -1; if (allLetters.ContainsKey(ld.Id)) { index = allLetters[ld.Id]; } if (index == -1) { Debug.Log("Letter got from Teacher is: " + ld.Id + " - does not match 11 models we have, we will play sound of the returned data"); index = Random.Range(0, prefabs.Count); } currentLL = ld; currentPrefab = Instantiate(prefabs[index]); currentPrefab.GetComponent <MazeLetterBuilder>().build(() => { if (!isTutorialMode) { MazeConfiguration.Instance.Context.GetAudioManager().PlayVocabularyData( ld, soundType: MazeConfiguration.Instance.GetVocabularySoundType() ); } foreach (Transform child in currentPrefab.transform) { if (child.name == "Mazecharacter") { currentCharacter = child.GetComponent <MazeCharacter>(); } else if (child.name == "HandTutorial") { currentTutorial = child.GetComponent <HandTutorial>(); } } currentCharacter.gameObject.SetActive(false); currentMazeLetter = currentPrefab.GetComponentInChildren <MazeLetter>(); }); }
public ILivingLetterData getNewLetter() { ILivingLetterData newLetter = null; IQuestionProvider newQuestionProvider = SickLettersConfiguration.Instance.Questions; IQuestionPack nextQuestionPack = newQuestionProvider.GetNextQuestion(); foreach (ILivingLetterData letterData in nextQuestionPack.GetCorrectAnswers()) { newLetter = letterData; } return(newLetter); }
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); }
// ################################## // 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); }
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 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(); } }
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(); } }
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]); } } }
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); }
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(); } }
void initCurrentLetter() { currentCharacter = null; currentTutorial = null; TutorialUI.Clear(false); addLine(); //get a new letter: IQuestionPack newQuestionPack = MazeConfiguration.Instance.Questions.GetNextQuestion(); List <ILivingLetterData> ldList = (List <ILivingLetterData>)newQuestionPack.GetCorrectAnswers(); LL_LetterData ld = (LL_LetterData)ldList[0]; int index = -1; if (allLetters.ContainsKey(ld.Id)) { index = allLetters[ld.Id]; } if (index == -1) { Debug.Log("Letter got from Teacher is: " + ld.Id + " - does not match 11 models we have, we will play sound of the returned data"); index = UnityEngine.Random.Range(0, prefabs.Count); } currentLL = ld; currentPrefab = (GameObject)Instantiate(prefabs[index]); /*int index = allLetters.IndexOf(ld.Id); * * int found = -1; * for(int i =0; i < prefabs.Count; ++i) * { * if(prefabs[i].GetComponent<MazeLetterBuilder>().letterDataIndex == index) * { * found = i; * * break; * } * } * */ //currentPrefab.GetComponent<MazeLetterBuilder>().letterData = ld; currentPrefab.GetComponent <MazeLetterBuilder>().build(() => { if (!isTutorialMode) { MazeConfiguration.Instance.Context.GetAudioManager().PlayLetterData(ld); } foreach (Transform child in currentPrefab.transform) { if (child.name == "Mazecharacter") { currentCharacter = child.GetComponent <MazeCharacter>(); } else if (child.name == "HandTutorial") { currentTutorial = child.GetComponent <HandTutorial>(); } } currentCharacter.gameObject.SetActive(false); }); }
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); } }
public void StartNewQuestion(float difficulty, bool onlyLetter) { sequence = false; lLetterDataSequence.Clear(); IQuestionPack questionPack = EggConfiguration.Instance.Questions.GetNextQuestion(); questionDescription = ""; List <ILivingLetterData> correctAnswers = new List <ILivingLetterData>(); List <ILivingLetterData> wrongAnswers = new List <ILivingLetterData>(); foreach (ILivingLetterData letterData in questionPack.GetCorrectAnswers()) { correctAnswers.Add(letterData); } foreach (ILivingLetterData letterData in questionPack.GetWrongAnswers()) { wrongAnswers.Add(letterData); } if (wrongAnswers.Count == 0) { sequence = true; } int numberOfLetters = 2; numberOfLetters += ((int)(difficulty * 5) + 1); if (numberOfLetters > 8) { numberOfLetters = 8; } if (!sequence) { lLetterDataSequence.Add(correctAnswers[0]); numberOfLetters += -1; if (numberOfLetters > wrongAnswers.Count) { numberOfLetters = wrongAnswers.Count; } for (int i = 0; i < numberOfLetters; i++) { lLetterDataSequence.Add(wrongAnswers[i]); } } else { if (numberOfLetters > correctAnswers.Count) { numberOfLetters = correctAnswers.Count; } for (int i = 0; i < numberOfLetters; i++) { lLetterDataSequence.Add(correctAnswers[i]); } } }
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(); } }