private void FillSamleText(ButtonComponent button) { WordToTranslate wordToTranslate = FindObjectOfType <WordToTranslate>(); if (!button || !wordToTranslate) { Debug.LogWarning("Не найден WordToTranslate"); return; } QuestionLeo quest = wordToTranslate.GetCurrentQuest(); WordLeo word = null; foreach (var item in quest.answers) { if (button.text.text == item.translations || button.text.text == item.wordValue) { word = item; break; } } if (word == null) { return; } if (button.text.text == word.translations) { SampleText.text = word.translations + " → " + word.wordValue; } else { SampleText.text = word.wordValue + " → " + word.translations; } }
private static void FillAnswers(QuestionLeo questionLeo, Stack <WordLeo> answers) { int[] numAnswers = { 0, 1, 2, 3, 4 }; int indexOfQuestWord = URandom.Range(0, ANSWER_COUNT); questionLeo.answers = new List <WordLeo>(ANSWER_COUNT); foreach (var item in numAnswers) { // номер совпал с индексом для ответа if (item == indexOfQuestWord) { questionLeo.answers.Add(questionLeo.questWord); continue; } // пропустить повтор ответа для задания if (answers.Count != 0 && answers.Peek() == questionLeo.questWord) { answers.Pop(); } //TODO: заполнять варианты ответов из общего словаря if (answers.Count != 0) { questionLeo.answers.Add(answers.Pop()); } } }
private void Core_DrawTask() { Debug.Log("Core_DrawTask"); QuestionLeo questionLeo = core.GetCurrentQuest(); translateText.text = core.GetCurrentWord().translations; core.SetSound(questionLeo.questWord.soundURL); SetImage(questionLeo.questWord.pictureURL); HideImage(); HideQuestion(); HideRepeatWordButton(); AnswerInputField.text = string.Empty; SetupEnterButton(CheckAnswerClick); WordProgressUpdate(); ProgeressBarUpdate(); GameObject.FindObjectOfType <DebugUI>().FillPanel(core.tasks); //передать фокус полю ввода AnswerInputField.ActivateInputField(); // выбор элемента как активного EventSystem.current.SetSelectedGameObject(AnswerInputField.gameObject); GameManager.Notifications.PostNotification(this, GAME_EVENTS.BuildTask); }
/// <summary> /// Заполнить кнопки вариантами ответов /// </summary> /// <param name="questionLeo"></param> /// <param name="questionWord"></param> private void SetButtons(QuestionLeo questionLeo, WordLeo questionWord) { List <string> answers = new List <string>(Workout.ANSWER_COUNT); foreach (WordLeo item in questionLeo.answers) { answers.Add(item.translations); } core.SetButtons(answers, questionWord.translations); }
private void Core_DrawTask() { QuestionLeo questionLeo = core.GetCurrentQuest(); // добавление слова для перевода SetQuestion(questionLeo.questWord.wordValue); SetButtons(questionLeo, questionLeo.questWord); //Выше заполнить GUI ResetSelection(); }
private void BuildTask(int current) { buttonsHandler.ClearTextInButtons(); if (trainingСompleted || questions.Count == 0) { GameManager.Notifications.PostNotification(this, GAME_EVENTS.WordsEnded); return; } questionID = FindNodeByID(current); if (questionID < 0) { Debug.LogError(this + "отсутствует или указан неверно идентификатор узла."); return; } int toNode = questionID + 1; if (questions.Count <= toNode) { toNode = 0; trainingСompleted = true; } QuestionLeo questionLeo = questions[questionID]; // добавление слова для перевода string questionWord = questionLeo.questWord.wordValue; SetQuestion(questionWord); SetTranscript(questionLeo.questWord.transcription); //TODO: заполнять все кнопки одновременно List <string> answers = new List <string>(ANSWER_COUNT); foreach (WordLeo item in questionLeo.answers) { answers.Add(item.wordValue); } buttonsHandler.FillingButtonsWithOptions(answers, questionWord); buttonsHandler.FillingEnterButton(true); SetImage(questionLeo.questWord.pictureURL); SetSound(questionLeo.questWord.soundURL); SetContext(questionLeo.questWord.highlightedContext); HideContext(); // выбор окна диалога как активного, чтобы снять выделение с кнопок диалога EventSystem.current.SetSelectedGameObject(this.gameObject); GameManager.Notifications.PostNotification(this, GAME_EVENTS.BuildTask); }
/// <summary> /// заполнить варианты ответов /// </summary> /// <param name="questionLeo"></param> private void FillAnswersForQuestion(QuestionLeo questionLeo) { List <WordLeo> words = GameManager.WordManeger.GetWordsWithLicense(); Stack <WordLeo> answers = null; if (words.Count <= ANSWER_COUNT * 2) { words = AddWordsForAnswers(words); //words = GameManager.WordManeger.GetAllWords(); } answers = PrepareAnswers(words, ANSWER_COUNT); FillAnswers(questionLeo, answers); questionLeo.answers = ShuffleList(questionLeo.answers); }
private void LoadTasks() { questions = new List <QuestionLeo>(QUEST_COUNT); untrainedWords = GameManager.WordManeger.GetWordsWithLicense(); for (int i = 0; i < QUEST_COUNT; i++) { QuestionLeo question = GeneratorTask(i, questions); if (question == null) { break; } questions.Add(question); } }
private QuestionLeo GeneratorTask(int id, List <QuestionLeo> exceptWords) { QuestionLeo questionLeo = new QuestionLeo(); questionLeo.id = id; questionLeo.questWord = GetNewWord(exceptWords, untrainedWords); if (questionLeo.questWord == null) { Debug.LogWarning("Уникальных слов нет"); return(null); } questionLeo.FillInAnswers(ANSWER_COUNT); return(questionLeo); }
private QuestionLeo GeneratorTask(int id, List <QuestionLeo> exceptWords) { QuestionLeo questionLeo = new QuestionLeo(); questionLeo.id = id; //if (words.GroupExist()) untrainedWords = ShuffleList(untrainedWords); questionLeo.questWord = GetNewWord(exceptWords, untrainedWords); if (questionLeo.questWord == null) { Debug.LogWarning("Уникальных слов нет"); return(null); } FillAnswersForQuestion(questionLeo); return(questionLeo); }
/// <summary> /// Перевод-Слово /// </summary> private void BuildUiToTranslateWord() { QuestionLeo questionLeo = core.GetCurrentQuest(); // добавление слова для перевода string translations = questionLeo.questWord.translations; string questionWord = translations.Split(',')[0]; SetQuestion(questionWord); SetTranscript(questionLeo.questWord.transcription); SetButtons(questionLeo, questionLeo.questWord); SetImage(questionLeo.questWord.pictureURL); core.SetSound(questionLeo.questWord.soundURL); SetContext(questionLeo.questWord.highlightedContext); HideImage(); //ShowImage(); HideContext(); HideTranscript(); HideRepeatWordButton(); }
/// <summary> /// Слово-Перевод /// </summary> private void BuildUiToWordTranslate() { QuestionLeo questionLeo = core.GetCurrentQuest(); // добавление слова для перевода SetQuestion(questionLeo.questWord.wordValue); SetTranscript(questionLeo.questWord.transcription); SetButtons(questionLeo, questionLeo.questWord); SetImage(questionLeo.questWord.pictureURL); HideImage(); core.SetSound(questionLeo.questWord.soundURL); if (sayToggle.isOn) { GameManager.AudioPlayer.SayWord(); } SetContext(questionLeo.questWord.highlightedContext); HideContext(); }
private List <QuestionLeo> LoadTasks() { List <QuestionLeo> questionsTemp = new List <QuestionLeo>(maxQuestCount); untrainedWords = GameManager.WordManeger.GetUntrainedGroupWords(workoutName); if (untrainedWords.Count == 0) { return(questionsTemp); } untrainedWords = Utilities.ShuffleList(untrainedWords); untrainedWords = Utilities.SortWordsByProgress(untrainedWords); for (int i = 0; i < maxQuestCount; i++) { QuestionLeo question = GeneratorTask(i, questionsTemp); if (question == null) { break; } questionsTemp.Add(question); } return(questionsTemp); }