protected override void OnAwake() { base.OnAwake(); m_Controller = GetComponentInParent <WordGame>(); m_Text = GetComponentInChildren <TextMesh>(); GetComponentInChildren <MeshRenderer>().sortingLayerName = "Text"; }
public void Timeout_NoCorrectGuess_StateSetToSwitchTeamAndAddBonusLetter() { var puzzleEntry = new WordPuzzleEntry(new[] { new WordPuzzleLetterEntry('a', LetterState.CorrectLocation), new WordPuzzleLetterEntry('a', LetterState.CorrectLocation), new WordPuzzleLetterEntry('a', LetterState.CorrectLocation), new WordPuzzleLetterEntry('b', LetterState.IncorrectLocation), new WordPuzzleLetterEntry('b', LetterState.IncorrectLocation), }); var wordPuzzleMock = new Mock <WordPuzzle>("aaaaa"); wordPuzzleMock.Setup(x => x.Solve(It.IsAny <string>())).Returns(puzzleEntry); WordGame wordGame = new WordGame(wordPuzzleMock.Object, 0); wordGame.Solve("aaabb"); wordGame.TimeOut(); Assert.AreEqual(1, wordGame.ActiveTeamIndex); Assert.AreEqual(1, wordGame.AttemptIndex); Assert.AreEqual(WordGameState.SwitchTeam, wordGame.State.State); Assert.IsTrue((wordGame.State.Flags & SwitchTeamFlags.AddRow) != SwitchTeamFlags.AddRow); Assert.IsTrue((wordGame.State.Flags & SwitchTeamFlags.AddBonusLetter) == SwitchTeamFlags.AddBonusLetter); }
public void Timeout_WordAlmostGuessed_StateSetToSwitchTeam() { var puzzleEntry = new WordPuzzleEntry(new[] { new WordPuzzleLetterEntry('a', LetterState.CorrectLocation), new WordPuzzleLetterEntry('a', LetterState.CorrectLocation), new WordPuzzleLetterEntry('a', LetterState.CorrectLocation), new WordPuzzleLetterEntry('a', LetterState.CorrectLocation), new WordPuzzleLetterEntry('b', LetterState.IncorrectLocation), }); var wordPuzzleMock = new Mock <WordPuzzle>("aaaaa"); wordPuzzleMock.Setup(x => x.Solve(It.IsAny <string>())).Returns(puzzleEntry); WordGame wordGame = new WordGame(wordPuzzleMock.Object, 0); wordGame.Solve("aaaab"); wordGame.TimeOut(); Assert.AreEqual(1, wordGame.ActiveTeamIndex); Assert.AreEqual(1, wordGame.AttemptIndex); Assert.AreEqual(WordGameState.SwitchTeam, wordGame.State.State); Assert.AreEqual(SwitchTeamFlags.ClearRow, wordGame.State.Flags); }
public void PlayIncorrectPlay() { var tableScore = Substitute.For <ITableScore>(); var reels = Substitute.For <IReels>(); var dispatcher = Substitute.For <IDomainEventDispatcher>(); reels.Play("word").Returns(new IReels.PlayResult(false, new List <string> { "word" })); reels.Get().Returns("other"); tableScore.CorrectPlay(Arg.Any <string[]>()).Returns(5d); tableScore.Get().Returns(5d); var game = new WordGame(tableScore, reels, dispatcher); Assert.False(game.IsPlaying); game.Init(); Assert.True(game.IsPlaying); game.Play("word"); tableScore.Received(1).WrongPlay(); tableScore.DidNotReceive().CorrectPlay(Arg.Any <IEnumerable <string> >()); dispatcher.Received(1).Send(Arg.Is(new OnUserStartedGame())); dispatcher.Received(2).Send(Arg.Any <OnUserStartedNextPlay>()); dispatcher.Received(1).Send(Arg.Any <OnUserFinishedPlay>()); }
void TaskOnClick() { levelCount++; WordGame.CLEARALL(); WordGame.START(); print(levelCount); }
public async Task StartWordGame(string word) { _wordSize = word.Length; _wordGame = new WordGame(new WordPuzzle(word), _state.Team1.IsActiveTeam ? 0 : 1); BoardViewModel = new BoardViewModel(word.Length, _audioPlaybackEngine); _audioPlaybackEngine.PlaySound(_newLetterAppearsSound); await BoardViewModel.StartNextAttempt(_wordGame.KnownLetters); }
public void Ctor_IntializedCorrectly() { var wordPuzzleMock = new Mock <WordPuzzle>("aaaa"); WordGame wordGame = new WordGame(wordPuzzleMock.Object, 0); Assert.AreEqual(0, wordGame.ActiveTeamIndex); Assert.AreEqual(0, wordGame.AttemptIndex); Assert.AreEqual(WordGameState.NotStarted, wordGame.State.State); }
void TaskOnClick2() { WordGame.CLEARALL(); gameOver.text = "GAME OVER"; restartButtonImage.gameObject.SetActive(true); Button restartbtn = restart.GetComponent <Button>(); restartbtn.onClick.AddListener(TaskOnClick3); }
public void GameOver_AfterXGuesses(int guesses, int max, bool expected) { Game = new WordGame(MockSecretWord.Object, max); for (int i = 0; i < guesses; i++) { Game.MakeAGuess((char)('a' + i)); } var result = Game.GameOver; Assert.That(result, Is.EqualTo(expected)); }
public void Solve_InCorrectAnswer_StateIsSetToOnGoing() { var puzzleEntry = new WordPuzzleEntry(Enumerable.Repeat(new WordPuzzleLetterEntry('a', LetterState.IncorrectLocation), 5).ToArray()); var wordPuzzleMock = new Mock <WordPuzzle>("aaaaa"); wordPuzzleMock.Setup(x => x.Solve(It.IsAny <string>())).Returns(puzzleEntry); WordGame wordGame = new WordGame(wordPuzzleMock.Object, 0); wordGame.Solve("bbbbb"); Assert.AreEqual(0, wordGame.ActiveTeamIndex); Assert.AreEqual(1, wordGame.AttemptIndex); Assert.AreEqual(WordGameState.Ongoing, wordGame.State.State); }
public void Reject_KeepsIndexButSwitchesTeam() { var puzzleEntry = new WordPuzzleEntry(Enumerable.Repeat(new WordPuzzleLetterEntry('a', LetterState.IncorrectLocation), 5).ToArray()); var wordPuzzleMock = new Mock <WordPuzzle>("aaaa"); wordPuzzleMock.Setup(x => x.Solve(It.IsAny <string>())).Returns(puzzleEntry); WordGame wordGame = new WordGame(wordPuzzleMock.Object, 0); wordGame.Reject(); Assert.AreEqual(1, wordGame.ActiveTeamIndex); Assert.AreEqual(0, wordGame.AttemptIndex); Assert.AreEqual(WordGameState.SwitchTeam, wordGame.State.State); Assert.IsTrue((wordGame.State.Flags & SwitchTeamFlags.ClearRow) == SwitchTeamFlags.ClearRow); Assert.IsTrue((wordGame.State.Flags & SwitchTeamFlags.AddBonusLetter) == SwitchTeamFlags.AddBonusLetter); }
public void Solve_6IncorrectAnswers_GameIsLostAndOtherTeamIsStillActive() { var puzzleEntry = new WordPuzzleEntry(Enumerable.Repeat(new WordPuzzleLetterEntry('a', LetterState.IncorrectLocation), 5).ToArray()); var wordPuzzleMock = new Mock <WordPuzzle>("aaaa"); wordPuzzleMock.Setup(x => x.Solve(It.IsAny <string>())).Returns(puzzleEntry); WordGame wordGame = new WordGame(wordPuzzleMock.Object, 0); wordGame.Solve("aaaaa"); wordGame.Solve("aaaaa"); wordGame.Solve("aaaaa"); wordGame.Solve("aaaaa"); wordGame.Solve("aaaaa"); wordGame.Solve("aaaaa"); Assert.AreEqual(1, wordGame.ActiveTeamIndex); Assert.AreEqual(6, wordGame.AttemptIndex); Assert.AreEqual(WordGameState.Lost, wordGame.State.State); }
void Awake(){ S = this; }
void Awake() { S = this; letterAnchor = new GameObject("LetterAnchor").transform; bigLetterAnchor = new GameObject("BigLetterAnchor").transform; }
void Awake() { S = this; // Assign the singleton }
private void Start() { wordGame = GameObject.Find("WordGame").GetComponent <WordGame>(); }
void Awake(){ S = this; }//end of Awake()
void Awake() { S = this; // Assign the singleton letterAnchor = new GameObject("LetterAnchor").transform; bigLetterAnchor = new GameObject("BigLetterAnchor").transform; }
public void SetUp() { MockSecretWord = new Mock <ISecretWord>(); Game = new WordGame(MockSecretWord.Object, 10); }