Ejemplo n.º 1
0
        private void Start()
        {
            if (mapData != null && graph != null)
            {
                var mapInstance = mapData.MakeMap();
                graph.Construct(mapInstance);

                var graphView = graph.GetComponent <GraphView>();

                if (graphView != null)
                {
                    graphView.Construct(graph);
                }

                if (GraphUtility.IsWithinBounds(startX, startY, graph.Width, graph.Height) &&
                    GraphUtility.IsWithinBounds(goalX, goalY, graph.Width, graph.Height) &&
                    pathfinder != null)
                {
                    Debug.Log($"Passing condition");
                    var startNode = graph.nodes[startX, startY];
                    var goalNode  = graph.nodes[goalX, goalY];
                    pathfinder.Construct(graph, graphView, startNode, goalNode);

                    StartCoroutine(pathfinder.SearchRoutine(timeStep));
                }
            }
        }
Ejemplo n.º 2
0
 private List <Node> GetNeighbors(int x, int y)
 {
     return(GraphUtility.GetNeighbors(x, y, _width, _height, nodes, GraphUtility.AllDirections));
 }