Пример #1
0
    private IEnumerator Start()
    {
        players = FindObjectsOfType <Player>().Where(x => x != this).ToList();
        yield return(new WaitForSeconds(1f));

        var sw = new System.Diagnostics.Stopwatch();

        sw.Start();
        if (aStar)
        {
            var aNodePath = APathfinding.FindPath(transform.position, target.position);
            sw.Stop();
            if (aNodePath != null)
            {
                path = aNodePath.Select(x => x.worldPosition).ToList();
            }
        }
        else
        {
            var dNodePath = DPathfinding.FindPath(transform.position, target.position);
            sw.Stop();
            if (dNodePath != null)
            {
                path = dNodePath.Select(x => x.worldPosition).ToList();
            }
        }
        Debug.Log(sw.Elapsed.Milliseconds);
        if (path != null)
        {
            currentIdx = 0;
            isMoving   = true;
        }
    }
Пример #2
0
 void Awake()
 {
     instance    = this;
     pathfinding = GetComponent <APathfinding>();
 }