Пример #1
0
        private void GenerateNodeGrid()
        {
            _grid = new Node.Node[_width, _height];
            for (var x = 0; x < _width; x++)
            {
                for (var y = 0; y < _height; y++)
                {
                    var node = new Node.Node
                    {
                        X       = x,
                        Y       = y,
                        Visited = false,
                        Walls   = NodeWalls.Initial
                    };

                    _grid[x, y] = node;
                }
            }
        }
Пример #2
0
        private List <NeighborNode> GetNeighbor(Node.Node node)
        {
            var nodes = new List <NeighborNode>();

            if (node.X > 0)
            {
                nodes.Add(new NeighborNode()
                {
                    Node = _grid[node.X - 1, node.Y],
                    Wall = NodeWalls.Left
                });
            }
            if (node.X < _width - 1)
            {
                nodes.Add(new NeighborNode()
                {
                    Node = _grid[node.X + 1, node.Y],
                    Wall = NodeWalls.Right
                });
            }
            if (node.Y > 0)
            {
                nodes.Add(new NeighborNode()
                {
                    Node = _grid[node.X, node.Y - 1],
                    Wall = NodeWalls.Top
                });
            }
            if (node.Y < _height - 1)
            {
                nodes.Add(new NeighborNode()
                {
                    Node = _grid[node.X, node.Y + 1],
                    Wall = NodeWalls.Bottom
                });
            }

            return(nodes);
        }