コード例 #1
0
 public PathRequest(Vector3 _start, Vector3 _end, Action <Vector3[], bool> _successCbk, PathFinding _pathFinding)
 {
     pathStart   = _start;
     pathEnd     = _end;
     callback    = _successCbk;
     pathfinding = _pathFinding;
 }
コード例 #2
0
        //特定區域要求路徑
        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);
        }
コード例 #3
0
 void Awake()
 {
     instance    = this;
     pathFinding = GetComponent <PathFinding>();
 }