コード例 #1
0
 public void Hint()
 {
     if (PromptModel.ShowNextLetter(promptAndAnswers))
     {
         AddScore(scorePerHint);
     }
 }
コード例 #2
0
        public static bool ShowNextLetter(PromptModel[] prompts)
        {
            bool isNow     = false;
            int  letterMax = DataUtil.Length(prompts[0].answerTexts);

            for (int letter = 0; !isNow && letter < letterMax; letter++)
            {
                for (int row = 0; !isNow && row < DataUtil.Length(prompts); row++)
                {
                    PromptModel prompt = prompts[row];
                    int         length = DataUtil.Length(prompt.answerText);
                    if (empty == prompt.answerTexts[letter] &&
                        letter < length)
                    {
                        if (letter == length - 1)
                        {
                            prompt.ShowAnswer(true);
                        }
                        else
                        {
                            prompt.ShowLetter(letter, true);
                        }
                        isNow = true;
                    }
                }
            }
            return(isNow);
        }
コード例 #3
0
        public void UpdateAnswer()
        {
            var model = new SpellingModel();

            model.table = SpellingController.Load("test_words.csv");
            model.Setup();
            model.Populate();
            model.UpdateAnswer();
            PromptModel prompt = model.promptAndAnswers[0];

            Assert.AreEqual(model.empty, prompt.answerTexts[0]);
            Assert.AreEqual("PART", prompt.answerText);
            model.selected.answerText = "PAR";
            model.isLetterSelects[0]  = true;
            model.isLetterSelects[3]  = true;
            model.UpdateAnswer();
            Assert.AreEqual(model.empty, prompt.answerTexts[0]);
            Assert.AreEqual(true, model.isLetterSelects[0]);
            Assert.AreEqual(true, model.isLetterSelects[3]);
            Assert.AreEqual(false, prompt.isAnswerVisible);
            model.selected.answerText = "PART";
            model.UpdateAnswer();
            Assert.AreEqual("PART", prompt.answerText);
            Assert.AreEqual("P", prompt.answerTexts[0]);
            Assert.AreEqual("A", prompt.answerTexts[1]);
            Assert.AreEqual("R", prompt.answerTexts[2]);
            Assert.AreEqual("T", prompt.answerTexts[3]);
            Assert.AreEqual(false, model.isLetterSelects[0], "Clear selected letters.");
            Assert.AreEqual(false, model.isLetterSelects[3], "Clear selected letters.");
            Assert.AreEqual(model.empty, model.selected.answerText);
            Assert.AreEqual(true, prompt.isAnswerVisible);
        }
コード例 #4
0
 private void ReferTo(SpellingModel content)
 {
     answerCount           = content.answerCount;
     isLetterSelects       = content.isLetterSelects;
     letterButtonTexts     = content.letterButtonTexts;
     letterButtonsSelected = content.letterButtonsSelected;
     promptAndAnswers      = content.promptAndAnswers;
     selected  = content.selected;
     topicText = content.topicText;
 }
コード例 #5
0
 private void ViewPrompt(PromptModel prompt, PromptView promptView)
 {
     TextView.SetText(promptView.promptText, prompt.promptText);
     for (int letter = 0; letter < DataUtil.Length(prompt.answerTexts); letter++)
     {
         string a = prompt.answerTexts[letter];
         TextView.SetText(promptView.answerTexts[letter], a);
         bool isVisible = letter < DataUtil.Length(prompt.answerText);
         SceneNodeView.SetVisible(promptView.answers[letter], isVisible);
     }
 }
コード例 #6
0
 private void PopulatePrompts(string[] row)
 {
     answerCount = 0;
     for (int p = 0; p < DataUtil.Length(promptAndAnswers); p++)
     {
         var prompt = new PromptModel();
         int index  = p * 2 + promptColumn;
         if (index < DataUtil.Length(row))
         {
             prompt.promptText = row[index];
             string answer = row[index + 1];
             prompt.PopulateAnswer(answer, letterMax);
         }
         promptAndAnswers[p] = prompt;
     }
 }
コード例 #7
0
 public void Setup()
 {
     letterButtonTexts    = new string[letterMax];
     promptAndAnswers     = new PromptModel[promptMax];
     selected             = new PromptModel();
     selected.answerTexts = new string[letterMax];
     if (null != table)
     {
         contentCount = DataUtil.Length(table) - 1;
         contents     = new SpellingModel[contentCount];
         for (int index = 0; index < contentCount; index++)
         {
             var content = new SpellingModel();
             content.Setup();
             content.PopulateRow(GetRow(index));
             contents[index] = content;
         }
     }
 }