Esempio n. 1
0
    void Start()
    {
        UpdatePathStartNTarget(nearStart, nearEnd, ref start, ref target);
        Debug.Log(start + " , " + target);
        finalPath = DijkstraAlgorithim.Dijkstra(RepresentGraph2D_Array.instance.grapRepresentation, start, target);

        noedI = RepresentGraph2D_Array.instance.allNodes[finalPath.Peek()].transform.position;
        Debug.Log(finalPath.Peek());
        finalPath.Pop();
    }
Esempio n. 2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E) && finalPath.Count == 0)
        {
            UpdatePathStartNTarget(nearStart, nearEnd, ref start, ref target);
            Debug.Log(start + " , " + target);
            finalPath = DijkstraAlgorithim.Dijkstra(RepresentGraph2D_Array.instance.grapRepresentation, start, target);

            noedI = RepresentGraph2D_Array.instance.allNodes[finalPath.Peek()].transform.position;
            Debug.Log(finalPath.Peek());
            finalPath.Pop();
        }

        while (finalPath.Count > 0)
        {
            nodeJ = RepresentGraph2D_Array.instance.allNodes[finalPath.Peek()].transform.position;
            Debug.DrawLine(noedI, nodeJ, Color.blue, Mathf.Infinity);
            noedI = nodeJ;
            Debug.Log(finalPath.Peek());
            finalPath.Pop();
        }
    }