Пример #1
0
 protected override void OnAwake()
 {
     base.OnAwake();
     m_Controller = GetComponentInParent <WordGame>();
     m_Text       = GetComponentInChildren <TextMesh>();
     GetComponentInChildren <MeshRenderer>().sortingLayerName = "Text";
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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>());
        }
Пример #5
0
    void TaskOnClick()
    {
        levelCount++;

        WordGame.CLEARALL();
        WordGame.START();
        print(levelCount);
    }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
    void TaskOnClick2()
    {
        WordGame.CLEARALL();
        gameOver.text = "GAME OVER";

        restartButtonImage.gameObject.SetActive(true);
        Button restartbtn = restart.GetComponent <Button>();

        restartbtn.onClick.AddListener(TaskOnClick3);
    }
Пример #9
0
        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));
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
	void Awake(){
		S = this;
	}
Пример #14
0
 void Awake()
 {
     S               = this;
     letterAnchor    = new GameObject("LetterAnchor").transform;
     bigLetterAnchor = new GameObject("BigLetterAnchor").transform;
 }
Пример #15
0
 void Awake()
 {
     S = this;                 // Assign the singleton
 }
Пример #16
0
 private void Start()
 {
     wordGame = GameObject.Find("WordGame").GetComponent <WordGame>();
 }
Пример #17
0
	void Awake(){
		S = this;
	}//end of Awake()
Пример #18
0
 void Awake()
 {
     S               = this; // Assign the singleton
     letterAnchor    = new GameObject("LetterAnchor").transform;
     bigLetterAnchor = new GameObject("BigLetterAnchor").transform;
 }
Пример #19
0
 public void SetUp()
 {
     MockSecretWord = new Mock <ISecretWord>();
     Game           = new WordGame(MockSecretWord.Object, 10);
 }