Exemplo n.º 1
0
        public void GetNeighbours_ShouldGetCorrectNeighbors()
        {
            var graph = GraphFactory.CreateRectangularGraph(6, 7, MovementTypesFixture.GetMovementTypes(),
                                                            MovementTypesFixture.Ground);

            // Column 2, row 1
            var offsetTarget = new Coordinate2D(2, 1, OffsetTypes.OddRowsRight);
            var cubeTarget   = offsetTarget.To3D();
            var neighbors    = graph.GetNeighbors(cubeTarget, false).ToList();
            // Neighbors for cube coordinates should be:
            // Cube(+1, -1, 0), Cube(+1, 0, -1), Cube(0, +1, -1), Cube(-1, +1, 0), Cube(-1, 0, +1), Cube(0, -1, +1),
            var expectedNeighbors = new List <Coordinate3D>
            {
                new Coordinate3D(2, -2, 0),
                new Coordinate3D(3, -3, 0),
                new Coordinate3D(3, -4, 1),
                new Coordinate3D(2, -4, 2),
                new Coordinate3D(1, -3, 2),
                new Coordinate3D(1, -2, 1)
            };

            Assert.That(neighbors, Is.EqualTo(expectedNeighbors));

            Assert.That(
                graph.GetNeighbors(offsetTarget, false).ToList(),
                Is.EquivalentTo(Coordinate3D.To2D(expectedNeighbors, OffsetTypes.OddRowsRight))
                );
        }
Exemplo n.º 2
0
        public void To2D_ShouldConvertTo2DEvenColumnsDown()
        {
            var coordinate3D         = new Coordinate3D(1, -2, 1);
            var actualCoordinate2D   = coordinate3D.To2D(OffsetTypes.EvenColumnsDown);
            var expectedCoordinate2D = new Coordinate2D(1, 2, OffsetTypes.EvenColumnsDown);

            Assert.That(actualCoordinate2D, Is.EqualTo(expectedCoordinate2D));
        }
Exemplo n.º 3
0
        public void To2D_ShouldConvertTo2DOddRowsRight()
        {
            var coordinate3D         = new Coordinate3D(1, -2, 1);
            var actualCoordinate2D   = coordinate3D.To2D(OffsetTypes.OddRowsRight);
            var expectedCoordinate2D = new Coordinate2D(1, 1, OffsetTypes.OddRowsRight);

            Assert.That(actualCoordinate2D, Is.EqualTo(expectedCoordinate2D));
        }