Ejemplo n.º 1
0
        public void FilteredNeighbors_Unconstrained_EightWayNeighbors()
        {
            Vec2            vec2            = new Vec2(5, 5);
            PathfindingGrid grid            = new PathfindingGrid(vec2);
            Vec2            tileCoordinates = new Vec2(3, 3);

            Motility        agentMotility = Motility.Unconstrained | Motility.EightWayNeighbors;
            List <GridNode> nodes         = new List <GridNode>();

            grid.Fill(position => new GridNode(Tiles.Stone, position, grid));
            nodes.Add(new GridNode(Tiles.Stone, new Vec2(2, 2), grid));
            nodes.Add(new GridNode(Tiles.Stone, new Vec2(3, 2), grid));
            nodes.Add(new GridNode(Tiles.Stone, new Vec2(4, 2), grid));

            nodes.Add(new GridNode(Tiles.Stone, new Vec2(2, 3), grid));
            nodes.Add(new GridNode(Tiles.Stone, new Vec2(4, 3), grid));

            nodes.Add(new GridNode(Tiles.Stone, new Vec2(2, 4), grid));
            nodes.Add(new GridNode(Tiles.Stone, new Vec2(3, 4), grid));
            nodes.Add(new GridNode(Tiles.Stone, new Vec2(4, 4), grid));

            IReadOnlyCollection <GridNode> filteredNeighbors = grid.FilteredNeighbors(grid[tileCoordinates], agentMotility);

            CollectionAssert.AreEquivalent(nodes.AsReadOnly(), filteredNeighbors);
        }
Ejemplo n.º 2
0
        public void FilteredNeighbors_LandMotility_FourWayNeighbors()
        {
            Vec2            vec2            = new Vec2(5, 5);
            PathfindingGrid grid            = new PathfindingGrid(vec2);
            Vec2            tileCoordinates = new Vec2(3, 3);

            Motility        agentMotility = Motility.Land | Motility.FourWayNeighbors;
            List <GridNode> nodes         = new List <GridNode>();

            grid.Fill(position => new GridNode(Tiles.Stone, position, grid));
            grid[2, 3] = new GridNode(Tiles.Floor, new Vec2(2, 3), grid);
            grid[3, 4] = new GridNode(Tiles.Floor, new Vec2(3, 4), grid);

            nodes.Add(new GridNode(Tiles.Floor, new Vec2(2, 3), grid));
            nodes.Add(new GridNode(Tiles.Floor, new Vec2(3, 4), grid));

            CollectionAssert.AreEquivalent(nodes.AsReadOnly(), grid.FilteredNeighbors(grid[tileCoordinates], agentMotility));
        }