예제 #1
0
    public IEnumerator UpdatePath()
    {
        if (Time.timeSinceLevelLoad < 0.3f)
        {
            Debug.Log("Waiting for level load");
            yield return(new WaitForSeconds(0.3f));
        }

        PathRequestController.RequestPath((Vector2)transform.position, (Vector2)player.transform.position, OnPathFound);

        float sqrMoveThreshold = pathUpdateMoveThreshold * pathUpdateMoveThreshold;

        while (true)
        {
            Vector3 targetPosOld = player.transform.position;
            yield return(new WaitForSeconds(minPathUpdateTime));

            // if ((player.transform.position - targetPosOld).sqrMagnitude > sqrMoveThreshold) {
            PathRequestController.RequestPath((Vector2)transform.position, (Vector2)player.transform.position, OnPathFound);
            targetPosOld = player.transform.position;
            // }
            if (distance < 2)
            {
                // Debug.Log("chasing");
                currentWaypoint = player.transform.position;
            }
        }
    }
예제 #2
0
    void Start()
    {
        requestManager = GetComponent <PathRequestController>();
        var mapObject = GameObject.Find("MapGridObject");

        tilemap      = mapObject.transform.GetChild(0).gameObject.GetComponent <Tilemap>();
        mapGenerator = mapObject.GetComponent <MapGenerator>();
        map          = mapObject.GetComponent <Map>();
        tileTools    = GameObject.Find("TileTools").GetComponent <TileTools>();
    }
예제 #3
0
    public IEnumerator PathToLocation(Vector2 location)
    {
        if (Time.timeSinceLevelLoad < 0.3f)
        {
            Debug.Log("Waiting for level load");
            yield return(new WaitForSeconds(0.3f));
        }

        PathRequestController.RequestPath((Vector2)transform.position, location, OnPathFound);
    }
예제 #4
0
 void Awake()
 {
     instance = this;
     a = GetComponent<A_Pathfinding>();
 }
 void Awake()
 {
     instance    = this;
     pathfinding = GetComponent <Pathfinding>();
 }
예제 #6
0
 void FindPath()
 {
     PathRequestController.RequestPath(transform.position, player.position, OnPathFound);
 }
예제 #7
0
 void Awake()
 {
     request = GetComponent <PathRequestController>();
     grid    = GetComponent <Grid>();
 }
예제 #8
0
 void Awake()
 {
     request = GetComponent<PathRequestController>();
     grid = GetComponent<Grid>();
 }
예제 #9
0
 //Moves the unit from one point to another
 public void MoveUnit(Vector3 from, Vector3 to)
 {
     PathRequestController.RequestPath(from, to, OnPathFound);
     TargetReached = false;
 }
예제 #10
0
 void Awake()
 {
     instance = this;
     a        = GetComponent <A_Pathfinding>();
 }