private Question CreateQuestion() { // 問題の生成. checker.Question = generator.Generate(); return(checker.Question); }
private void newExQuestion() { Question q = QuestionGenerator.Generate(null, ExqList); QuestionCard card = new QuestionCard(); card.Question = q; card.QuestionNo = exQuestionNo; exQuestionNo++; card.Dock = DockStyle.Right; card.BackColor = Color.Transparent; card.OnAnswered += ExCard_OnAnswered; card.OnClosed += ExCard_OnClosed; panelExQuestionAlign.Controls.Add(card); }
private void newQuestion() { Question q = QuestionGenerator.Generate(null, qList); QuestionCard card = new QuestionCard(); card.Question = q; card.QuestionNo = questionNo; questionNo++; card.Dock = DockStyle.Bottom; card.BackColor = Color.Transparent; card.OnAnswered += Card_OnAnswered; card.OnClosed += Card_OnClosed; panelQuestionAlign.Controls.Add(card); }
public void GenerateQuestions(string topic) { topic = topic.Replace(" ", "_"); var outputJsonPath = DirectoryManager.GetOutputJsonPath(topic); var tpr = new TextProcessing(); var resultList = tpr.GetSentencesInformationFromJson(outputJsonPath); var questionList = new List <TopicQuestion>(); foreach (var sentence in resultList) { var dependencies = GetSentenceDependency(sentence); var words = GetSentenceWords(sentence); var sentenceInfo = new SentenceInformationDto(sentence.SentenceText, dependencies, words); if (MustContinue(sentence, sentenceInfo)) { continue; } GeneratedQuestion generatedQuestion; try { generatedQuestion = QuestionGenerator.Generate(sentenceInfo); } catch { continue; } if (string.IsNullOrEmpty(generatedQuestion?.Question)) { continue; } var cleanQuestion = QuestionCleaner.RemovePunctuationFromEnd(generatedQuestion.Question); cleanQuestion = $"{cleanQuestion}?"; var question = new TopicQuestion { Topic = topic, InitialSentence = sentence.SentenceText, Question = cleanQuestion, Answer = generatedQuestion.Answer }; questionList.Add(question); } DirectoryManager.WriteQuestionsToFile(questionList, topic); }
void Update() { // Check if the sound is muted bool sound = DataPersistence.GetMute(); if (isMuted != sound) { isMuted = sound; bgm.SetActive(!isMuted); } // Disable or enable the sound accordingly correctPanel.SetActive(isCorrectPanelActive); incorrectPanel.SetActive(isIncorrectPanelActive); correctAudio.SetActive(isCorrectAudioActive); incorrectAudio.SetActive(isIncorrectAudioActive); // Update the score score.UpdateScore(); // Update the highscore if necessary if (score.GetScore() > currentHighscore) { highscoreText.text = "Highscore: " + score.GetScore(); } // Triggers when player goes over a question spawnpoint if ((nextSpawnpoint = FindNextSpawnpoint()) != prevSpawnpoint) { // Instantiate the answer prefabs prevSpawnpoint = nextSpawnpoint; GameObject ago = Instantiate((GameObject)Resources.Load("Prefabs/Answer"), nextSpawnpoint.transform.position, Quaternion.identity); // Generate the questions answers = FindGameObjectsWithTag(ago, ANSWER_TAG); question = questionGenerator.Generate(); // Populate the answers into the map for (int i = 0; i < answers.Length; i++) { answers[i].transform.Find("text").GetComponent <TextMesh>().text = question.answers[i].Item1.ToString(); } // Update the text in the game questionText.text = question.question; } // Triggers when player goes over a life spawnpoint if ((nextLifeSpawnpoint = FindNextLifeSpawnpoint()) != prevLifeSpawnpoint) { prevLifeSpawnpoint = nextLifeSpawnpoint; // 10% chance of generating a life if (random.NextDouble() > 0.9) { // Instantiate a new life and add it into the game GameObject life = new GameObject("Life"); SpriteRenderer renderer = life.AddComponent <SpriteRenderer>(); renderer.sprite = Resources.Load <Sprite>("Images/love shape"); life.transform.position = nextLifeSpawnpoint.transform.position; life.tag = "Life"; BoxCollider boxCollider = life.AddComponent <BoxCollider>(); boxCollider.isTrigger = true; } } }