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(); }
public void NotFindsPositionOfBWordInOneLetterMatrixWithACharacter() { WordPuzzle wordPuzzle = new WordPuzzle(new char[, ] { { 'a' } }); Assert.AreEqual(null, wordPuzzle.SearchWord("b")); }
void StartPuzzle() { WordPuzzle p = GetComponent <WordPuzzle>(); if (p != null) { p.Begin(transform); } }
void RevealPuzzle() { if (Hidden) { Hidden = false; WordPuzzle p = GetComponent <WordPuzzle>(); p.Begin(transform); } }
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)); }
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")); }
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")); }
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")); }
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)); }
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)); }
public GameBoard(string playerName, WordPuzzle p) { this.puzzle = p; this.Player = playerName; }