Пример #1
0
        public Game(IPlayer player)
        {
            this.player = player;
            State       = GameState.IN_PROCESS;
            var generator = new BoardGenerator();

            Board = generator.Generate(4, 4);
        }
Пример #2
0
        public Game()
        {
            player = null;
            State  = GameState.IN_PROCESS;
            var generator = new BoardGenerator();

            Board = generator.Generate(4, 4);
        }
Пример #3
0
 public void BeginGame()
 {
     currentMaze = Instantiate(mazePrefab);
     currentMaze.Generate();
     SpawnCharacter(0);
     SpawnCharacter(1);
     myPlayer = 0;
     FakeNetworkController.instance.SendTurnChange(0);
 }
Пример #4
0
        static void TestMinesweeper()
        {
            BoardGenerator boardGenerator = new BoardGenerator(1234);
            Board          board          = boardGenerator.Generate(10, 10, 10);

            ShowBoardDisplay(board);
            ShowCell(board, 0, 0);
            ShowBoardDisplay(board);
            ShowCell(board, 9, 0);
            ShowBoardDisplay(board);
            throw new Exception("END");
        }
Пример #5
0
        public void Generate_ShipsDontOverlap()
        {
            var boardGenerator = new BoardGenerator(_validColumns, _validRows);

            var board       = boardGenerator.Generate();
            var coordinates = board.Ships
                              .SelectMany(ship => ship.Position)
                              .ToList();

            var uniqueCoordinates = new HashSet <Coordinates>(coordinates);

            uniqueCoordinates.Count.Should().Be(coordinates.Count);
        }
Пример #6
0
        public void BoardGeneratorTest()
        {
            const int size = 5;

            char[,] expected = new char[size, size]
            {
                { ' ', ' ', ' ', ' ', ' ' },
                { ' ', ' ', ' ', ' ', ' ' },
                { ' ', ' ', ' ', ' ', ' ' },
                { ' ', ' ', ' ', ' ', ' ' },
                { ' ', ' ', ' ', ' ', ' ' }
            };

            CollectionAssert.AreEqual(expected, BoardGenerator.Generate(size, ' '));
        }
Пример #7
0
        public void Generate_CreatesBoardWithCorrectShips()
        {
            var boardGenerator = new BoardGenerator(_validColumns, _validRows);

            var board = boardGenerator.Generate();

            board.Ships.Count.Should().Be(3);

            board.Ships
            .Count(ship => ship.Name == "Battleship" && ship.Position.Count == 5)
            .Should()
            .Be(1);

            board.Ships
            .Count(ship => ship.Name == "Destroyer" && ship.Position.Count == 4)
            .Should()
            .Be(2);
        }
 // Start is called before the first frame update
 void Start()
 {
     boardGenerator.Generate(size);
     camera.AdjustPosition(size);
 }