public PathRequest(Vector3 _start, Vector3 _end, Action <Vector3[], bool> _successCbk, PathFinding _pathFinding) { pathStart = _start; pathEnd = _end; callback = _successCbk; pathfinding = _pathFinding; }
//特定區域要求路徑 public static PathRequest RequestPath(PathFinding pathfinding, PathRequest oldRequest, Vector3 pathStart, Vector3 pathEnd, Action <Vector3[], bool> _successCbk) { PathRequest newRequest = new PathRequest(pathStart, pathEnd, _successCbk, pathfinding); if (instance.CheckProcessingRequest(oldRequest)) //如果目前正在搜尋且跟舊的一樣回傳null { return(null); } if (oldRequest != null && instance.pathRequestList.Contains(oldRequest)) //有在排隊中更新為新的request { instance.pathRequestList[instance.pathRequestList.IndexOf(oldRequest)] = newRequest; } else { instance.pathRequestList.Add(newRequest); } instance.TryProcessNext(); return(newRequest); }
void Awake() { instance = this; pathFinding = GetComponent <PathFinding>(); }