示例#1
0
 public override void OnInspectorGUI()
 {
     if (WordList.Words.Count == 0)
     {
         WordList.Load();
     }
     _tgt = (WordPuzzle)target;
     if (GUILayout.Button("Refresh wordlist"))
     {
         WordList.Load();
     }
     if (_selectedWord != null)
     {
         _selectedWord = _tgt.Word;
     }
     GUILayout.BeginHorizontal();
     _selectedWordIndex = EditorGUILayout.Popup(_selectedWordIndex, WordList.GetArray());
     if (GUILayout.Button("Set"))
     {
         _selectedWord             = WordList.Words[_selectedWordIndex];
         ((WordPuzzle)target).Word = _selectedWord;
     }
     ((WordPuzzle)target).RandomWord = GUILayout.Toggle(_tgt.RandomWord, "Random");
     GUILayout.EndHorizontal();
     if (_tgt.Word != null)
     {
         GUILayout.Label("Selected word: " + _tgt.Word.ToString());
     }
     base.OnInspectorGUI();
 }
示例#2
0
        public void NotFindsPositionOfBWordInOneLetterMatrixWithACharacter()
        {
            WordPuzzle wordPuzzle = new WordPuzzle(new char[, ] {
                { 'a' }
            });

            Assert.AreEqual(null, wordPuzzle.SearchWord("b"));
        }
示例#3
0
    void StartPuzzle()
    {
        WordPuzzle p = GetComponent <WordPuzzle>();

        if (p != null)
        {
            p.Begin(transform);
        }
    }
示例#4
0
 void RevealPuzzle()
 {
     if (Hidden)
     {
         Hidden = false;
         WordPuzzle p = GetComponent <WordPuzzle>();
         p.Begin(transform);
     }
 }
示例#5
0
        public void Solve_WordTooShort()
        {
            WordPuzzle wordPuzzle = new WordPuzzle("bomen");
            var        result     = wordPuzzle.Solve("bome");

            char[] expectedLetters = "bome.".ToCharArray();

            CollectionAssert.AreEqual(expectedLetters, result.LetterEntries.Select(x => x.Letter));
            Assert.IsTrue(result.LetterEntries.All(x => x.State == LetterState.DoesNotExistInWord));
        }
示例#6
0
        public void FindsPositionOfHojInFirstColumn()
        {
            var wordPuzzle = new WordPuzzle(new[, ] {
                { 'a' }, { 'h' }, { 'o' }, { 'j' }
            });

            Assert.AreEqual(new Vector {
                First = new Point {
                    X = 0, Y = 1
                }, Last = new Point {
                    X = 0, Y = 3
                }
            }, wordPuzzle.SearchWord("hoj"));
        }
示例#7
0
        public void FindsPositionOfHojWordInMatrixWithMultipleLines()
        {
            var wordPuzzle = new WordPuzzle(new[, ] {
                { 'a', 'h', 'o', 's' }, { 'a', 'h', 'o', 'j' }
            });

            Assert.AreEqual(new Vector {
                First = new Point {
                    X = 1, Y = 1
                }, Last = new Point {
                    X = 3, Y = 1
                }
            }, wordPuzzle.SearchWord("hoj"));
        }
示例#8
0
        public void FindsPositionOfAWordInOneLetterMatrixWithACharacter()
        {
            WordPuzzle wordPuzzle = new WordPuzzle(new char[, ] {
                { 'a' }
            });

            Assert.AreEqual(new Vector()
            {
                First = new Point()
                {
                    X = 0, Y = 0
                }, Last = new Point()
                {
                    X = 0, Y = 0
                },
            }
                            , wordPuzzle.SearchWord("a"));
        }
示例#9
0
        public void Solve_LetterInIncorrectLocationIsOnlySetToIncorrectLocationNTimesItExistsInTheWord()
        {
            WordPuzzle wordPuzzle = new WordPuzzle("yxxyy");
            var        result     = wordPuzzle.Solve("zzxxx");

            char[]        expectedLetters = "zzxxx".ToCharArray();
            LetterState[] expectedStates  = new LetterState[]
            {
                LetterState.DoesNotExistInWord,
                LetterState.DoesNotExistInWord,
                LetterState.CorrectLocation,
                LetterState.IncorrectLocation,
                LetterState.DoesNotExistInWord,
            };

            CollectionAssert.AreEqual(expectedLetters, result.LetterEntries.Select(x => x.Letter));
            CollectionAssert.AreEqual(expectedStates, result.LetterEntries.Select(x => x.State));
        }
示例#10
0
        public void Solve_InCorrectWord()
        {
            WordPuzzle wordPuzzle = new WordPuzzle("bomen");
            var        result     = wordPuzzle.Solve("clown");

            char[]        expectedLetters = "clown".ToCharArray();
            LetterState[] expectedStates  = new LetterState[]
            {
                LetterState.DoesNotExistInWord,
                LetterState.DoesNotExistInWord,
                LetterState.IncorrectLocation,
                LetterState.DoesNotExistInWord,
                LetterState.CorrectLocation,
            };

            CollectionAssert.AreEqual(expectedLetters, result.LetterEntries.Select(x => x.Letter));
            CollectionAssert.AreEqual(expectedStates, result.LetterEntries.Select(x => x.State));
        }
示例#11
0
 public GameBoard(string playerName, WordPuzzle p)
 {
     this.puzzle = p;
     this.Player = playerName;
 }