Пример #1
0
        private void InitNeighbours()
        {
            HexBoardNeighbours neighboursCalc = new HexBoardNeighbours(this.Size);

            // init the cached neighbours arrays
            this.neighbours         = new Cell[this.Size, this.Size][];
            this.neighbours2        = new Cell[this.Size, this.Size][][];
            this.playerXBetweenEdge = new Cell[this.Size, this.Size][];
            this.playerYBetweenEdge = new Cell[this.Size, this.Size][];

            foreach (Cell cell in this.cells)
            {
                Location[] neigbourLocations = neighboursCalc.Neighbours(cell.Location);
                this.neighbours[cell.X, cell.Y] = this.GetCellAt(neigbourLocations);

                Location[][] neighbour2Locations = neighboursCalc.Neighbours2(cell.Location);
                this.neighbours2[cell.X, cell.Y] = this.GetCellsAt(neighbour2Locations);

                Location[] localPlayerXBetweenEdge = neighboursCalc.BetweenEdge(cell.Location, true);
                this.playerXBetweenEdge[cell.X, cell.Y] = this.GetCellAt(localPlayerXBetweenEdge);

                Location[] localPlayerYBetweenEdge = neighboursCalc.BetweenEdge(cell.Location, false);
                this.playerYBetweenEdge[cell.X, cell.Y] = this.GetCellAt(localPlayerYBetweenEdge);
            }
        }
Пример #2
0
        public void NeighboursNearOriginTest()
        {
            HexBoardNeighbours testBoard = new HexBoardNeighbours(10);
            Location inValue = new Location(1, 1);

            Location[][] outValue = testBoard.Neighbours2(inValue);

            Assert.IsNotNull(outValue);
            Assert.AreEqual(4, outValue.Length);
            TestNeighbours(testBoard, inValue, outValue);
        }
Пример #3
0
        public void NeighboursMiddleTest()
        {
            HexBoardNeighbours testBoard = new HexBoardNeighbours(10);
            Location inValue = new Location(5, 5);

            Location[][] outValue = testBoard.Neighbours2(inValue);

            Assert.IsNotNull(outValue);
            Assert.AreEqual(6, outValue.Length);
            TestNeighbours(testBoard, inValue, outValue);
        }
Пример #4
0
        public void NeighboursOffTest()
        {
            HexBoardNeighbours testBoard = new HexBoardNeighbours(5);
            Location inValue = new Location(5, 0);

            Location[][] outValue = testBoard.Neighbours2(inValue);

            Assert.IsNotNull(outValue);
            Assert.AreEqual(0, outValue.Length);
        }
Пример #5
0
        private void InitNeighbours()
        {
            HexBoardNeighbours neighboursCalc = new HexBoardNeighbours(this.Size);

            // init the cached neighbours arrays
            this.neighbours = new Cell[this.Size, this.Size][];
            this.neighbours2 = new Cell[this.Size, this.Size][][];
            this.playerXBetweenEdge = new Cell[this.Size, this.Size][];
            this.playerYBetweenEdge = new Cell[this.Size, this.Size][];

            foreach (Cell cell in this.cells)
            {
                Location[] neigbourLocations = neighboursCalc.Neighbours(cell.Location);
                this.neighbours[cell.X, cell.Y] = this.GetCellAt(neigbourLocations);

                Location[][] neighbour2Locations = neighboursCalc.Neighbours2(cell.Location);
                this.neighbours2[cell.X, cell.Y] = this.GetCellsAt(neighbour2Locations);

                Location[] localPlayerXBetweenEdge = neighboursCalc.BetweenEdge(cell.Location, true);
                this.playerXBetweenEdge[cell.X, cell.Y] = this.GetCellAt(localPlayerXBetweenEdge);

                Location[] localPlayerYBetweenEdge = neighboursCalc.BetweenEdge(cell.Location, false);
                this.playerYBetweenEdge[cell.X, cell.Y] = this.GetCellAt(localPlayerYBetweenEdge);
            }
        }