Beispiel #1
0
    private void Start()
    {
        // Using Dijkstra
        if (behaviorNum == 13)
        {
            //myRotateType = new LWYG();
            //myRotateType.character = this;
            //myRotateType.target = myTarget;

            Graph myGraph = new Graph();
            myGraph.Build();
            List <Connection> path = Dijkstra.pathfind(myGraph, startNode, goalNode);
            // path is a list of connections - convert this to gameobjects for the FollowPath steering behavior
            pathToFollow = new GameObject[path.Count + 1];
            int i = 0;
            foreach (Connection c in path)
            {
                Debug.Log("from " + c.getFromNode() + " to " + c.getToNode() + " @" + c.getCost());
                pathToFollow[i] = c.getFromNode().gameObject;
                i++;
            }
            pathToFollow[i] = goalNode.gameObject;

            myMoveType           = new pathFollow();
            myMoveType.character = this;
            myMoveType.path      = pathToFollow;
        }
    }