Пример #1
0
    private bool gavePlayerScoreForJump;     //only 1 score increase per platform

    // Use this for initialization
    void Start()
    {
        spawnPointXPos = Random.Range(1, 9);
        if (isInitialPlatform)
        {
            int platformsToSpawn = 8;
            while (platformsToSpawn > 0)
            {
                while (spawnPointXPos == lastSpawnedPlatformPosition)
                {
                    spawnPointXPos = Random.Range(1, 9);
                }
                Instantiate(platformPrefab, new Vector3(spawnPointXPos, transform.position.y + (float)(9 - platformsToSpawn), transform.position.z), Quaternion.identity);
                lastSpawnedPlatformPosition = spawnPointXPos;
                platformsToSpawn           -= 1;
            }
        }
        else
        {
            if (!winPortalSpawned)
            {
                HandleResourceSpawns();
            }
        }
        scoreKeeper = FindObjectOfType <ScoreKeeper>();
        winDetector = FindObjectOfType <WinDetector>();
        camera      = FindObjectOfType <CameraController>();
        //each spawn point has a random horizontal position but a static vertical distance from the current platform
        spawnPoint = transform.GetChild(0);
        while (spawnPointXPos == lastSpawnedPlatformPosition || Mathf.Abs(spawnPointXPos - lastSpawnedPlatformPosition) > 2f)     //ensures that no two consecutive platforms are at the same horizontal position and that consecutive platforms are not too far apart
        {
            spawnPointXPos = Random.Range(1, 9);
        }
        spawnPoint.transform.position = new Vector3(spawnPointXPos, spawnPoint.transform.position.y, spawnPoint.transform.position.z);
    }
    private void InitWinDetector(ConfigScript configScript)
    {
        var boardSize = configScript.GetBoardSize();
        var board     = new Board(boardSize);

        m_winDetector = new WinDetector(board);
    }
Пример #3
0
        public void IsWonShouldBeFalseForBlankGrid()
        {
            var board = new TicTacToeBoard();

            var winStatus = WinDetector.GetWinStatus(board);

            winStatus.IsWon.Should().BeFalse();
        }
    WinDetector GetWinDetector()
    {
        const int boardSize   = 3;
        var       board       = new Board(boardSize);
        var       winDetector = new WinDetector(board);

        return(winDetector);
    }
Пример #5
0
        public void IsWonShouldBeTrueForVerticalWin(
            int x,
            TicTacToeCellValue cellValue)
        {
            var board = new TicTacToeBoard();

            board.SetCellValue(x, 0, cellValue);
            board.SetCellValue(x, 1, cellValue);
            board.SetCellValue(x, 2, cellValue);

            var winStatus = WinDetector.GetWinStatus(board);

            winStatus.IsWon.Should().BeTrue();
            winStatus.WinMessage.Should().Be($"Column win for {cellValue} on column {x + 1}");
        }
Пример #6
0
        public void IsWonShouldBeTrueForHorizonalWin(
            int y,
            TicTacToeCellValue cellValue)
        {
            var board = new TicTacToeBoard();

            board.SetCellValue(0, y, cellValue);
            board.SetCellValue(1, y, cellValue);
            board.SetCellValue(2, y, cellValue);

            var winStatus = WinDetector.GetWinStatus(board);

            winStatus.IsWon.Should().BeTrue();
            winStatus.WinMessage.Should().Be($"Row win for {cellValue} on row {y + 1}");
        }
Пример #7
0
        public void IsWonShouldBeFalseForNoWinningMoves()
        {
            var grid = new string[]
            {
                "X--",
                "-O-",
                "O-X",
            };

            var board = new TicTacToeBoard(grid);

            var winStatus = WinDetector.GetWinStatus(board);

            winStatus.IsWon.Should().BeFalse();
        }
Пример #8
0
 void Start()
 {
     decreasing = true;
     bar.SetActive(true);
     LoseDetector.lost = false;
     messager          = FindObjectOfType <GUIMessageManager>();
     winDetector       = FindObjectOfType <WinDetector>();
     loseDetector      = FindObjectOfType <LoseDetector>();
     centerBar.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, d);
     emptyTopPos = centerBar.transform.localPosition;
     if (color.Length > 0 && color.Length < 4)
     {
         SetColor(color[0]);
     }
 }
Пример #9
0
        public void GetWinner_Test()
        {
            var state = new State?[3, 3];

            state[0, 0] = State.Cross;
            state[0, 1] = State.Zero;

            var game = new Mock <IGameInfo>();

            game.Setup(g => g.Size).Returns(3);
            game.Setup(g => g.CurrentState).Returns(state);

            var winDetector = new WinDetector();
            var result      = winDetector.GetWinner(game.Object);

            Assert.IsNull(result);
        }
Пример #10
0
        public void GetWinner_Test_AI4()
        {
            var state = new State?[4, 4];

            state[1, 3] = State.Cross;
            state[2, 2] = State.Cross;
            state[3, 1] = State.Cross;

            var game = new Mock <IGameInfo>();

            game.Setup(g => g.Size).Returns(4);
            game.Setup(g => g.CurrentState).Returns(state);

            var winDetector = new WinDetector();
            var result      = winDetector.GetWinner(game.Object);

            Assert.AreEqual(Player.Human, result);
        }
Пример #11
0
        public void GetWinner_Test_Diagonal3()
        {
            var state = new State?[3, 3];

            state[0, 1] = State.Cross;
            state[1, 2] = State.Cross;


            var game = new Mock <IGameInfo>();

            game.Setup(g => g.Size).Returns(3);
            game.Setup(g => g.CurrentState).Returns(state);

            var winDetector = new WinDetector();
            var result      = winDetector.GetWinner(game.Object);

            Assert.AreEqual(null, result);
        }
Пример #12
0
        public void GetWinner_Test_Vertical()
        {
            var state = new State?[3, 3];

            state[2, 0] = State.Zero;
            state[2, 1] = State.Zero;
            state[2, 2] = State.Zero;


            var game = new Mock <IGameInfo>();

            game.Setup(g => g.Size).Returns(3);
            game.Setup(g => g.CurrentState).Returns(state);

            var winDetector = new WinDetector();
            var result      = winDetector.GetWinner(game.Object);

            Assert.AreEqual(Player.Computer, result);
        }
Пример #13
0
        public void GetWinner_Test_AI2()
        {
            var state = new State?[5, 5];

            state[0, 4] = State.Cross;
            state[1, 3] = State.Cross;
            state[2, 2] = null;
            state[3, 1] = State.Cross;
            state[4, 0] = State.Cross;

            var game = new Mock <IGameInfo>();

            game.Setup(g => g.Size).Returns(5);
            game.Setup(g => g.CurrentState).Returns(state);

            var winDetector = new WinDetector();
            var result      = winDetector.GetWinner(game.Object);

            Assert.AreEqual(null, result);
        }
Пример #14
0
 void Start()
 {
     headWinDetector = GameObject.Find("GirafController").GetComponent <WinDetector>();
 }