Exemplo n.º 1
0
        private void initMaze()
        {
            Node start = maze == null ? new StartNode(1, 0) : new StartNode(_startNode.x, _startNode.y);
            Node end   = maze == null ? new EndNode(width - 2, height - 1) : new EndNode(_endNode.x, _endNode.y);

            solved = false;
            maze   = new Node[width, height];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    if (i == start.x && j == start.y)
                    {
                        maze[i, j] = new StartNode(i, j);
                        _startNode = maze[i, j];
                    }
                    else if (i == end.x && j == end.y)
                    {
                        maze[i, j] = new EndNode(i, j);
                        _endNode   = maze[i, j];
                    }
                    else if (i == 0 || j == 0 || i == width - 1 || j == height - 1)
                    {
                        maze[i, j] = new Wall(i, j);
                    }
                    else
                    {
                        maze[i, j] = new Path(i, j, 1);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void MoveStartNode(int x, int y)
        {
            //if ((x % 2 == 0 || y % 2 == 0) && !(x == 0 || x == width - 1 || y == 0 || y == height - 1))
            //    return;

            if (_startNode.x == 0 || _startNode.x == width - 1 || _startNode.y == 0 || _startNode.y == height - 1)
            {
                maze[_startNode.x, _startNode.y] = new Wall(_startNode.x, _startNode.y);
            }
            else
            {
                maze[_startNode.x, _startNode.y] = new Path(_startNode.x, _startNode.y, 1);
            }

            _startNode = maze[x, y] = new StartNode(x, y);
        }