예제 #1
0
    private void WanderAround()
    {
        AStar.OnBlockedPath -= OnBlockedPath;
        AStar.OnFoundPath   -= OnFoundPath;

        AStar.OnBlockedPath += OnBlockedPath;
        AStar.OnFoundPath   += OnFoundPath;

        finalPath = AStar.FindPath(new Vector2(transform.position.x, transform.position.z), map.FindUnblockedSpace());
        if (finalPath != null)
        {
            finalPathArray = new Node[finalPath.Count];
            finalPath.CopyTo(finalPathArray);
        }
    }
예제 #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        cAmStar myScript = (cAmStar)target;

        if (GUILayout.Button("Random start/target"))
        {
            myScript.RandomlyPositionStartAndTarget();
        }
        if (GUILayout.Button("Find path"))
        {
            myScript.ClearMap();
            myScript.FindPath();
        }
    }
예제 #3
0
    private void WanderAround()
    {
        AStar.OnBlockedPath -= OnBlockedPath;
        AStar.OnFoundPath   -= OnFoundPath;

        AStar.OnBlockedPath += OnBlockedPath;
        AStar.OnFoundPath   += OnFoundPath;


        // Coroutine visualise
        AStar.FindPath(new Vector2(transform.position.x, transform.position.z), map.FindUnblockedSpace());

        // Instant
        // finalPath = AStar.FindPath(new Vector2(transform.position.x, transform.position.z), map.FindUnblockedSpace());
        // finalPathArray = new Node[finalPath.Count];
        // finalPath.CopyTo(finalPathArray);
    }