Exemplo n.º 1
0
 public PathRequestData(GridCell _startCell, GridCell _endCell, PathfindingComplete _callback, List <string> _ignoreTemplateList)
 {
     startCell          = _startCell;
     endCell            = _endCell;
     callback           = _callback;
     ignoreTemplateList = _ignoreTemplateList;
 }
Exemplo n.º 2
0
        public void FindPath(int requestId, Vector3 startPoint, Vector3 endPoint, PathfindingComplete callback, List <string> ignoreTemplateList = null)
        {
            GridCell startCell = GridManager.Instance.GetCell(startPoint);
            GridCell endCell   = GridManager.Instance.GetCell(endPoint);

            if (startCell == null || endCell == null)
            {
                PathData pathData = new PathData(new Vector3[1] {
                    endPoint
                }, new List <Node>(1)
                {
                    null
                });
                callback(false, pathData);
                return;
            }

            PathRequestData prd = new PathRequestData(startCell, endCell, callback, ignoreTemplateList);

            if (_pathRequestDictionary.ContainsKey(requestId))
            {
                _pathRequestDictionary[requestId] = prd;
            }
            else
            {
                _pathRequestQueue.Enqueue(requestId);
                _pathRequestDictionary.Add(requestId, prd);
            }
        }
Exemplo n.º 3
0
 // constructor for pathfinder object
 public Pathfinder(GridCharacter c, Node start, Node target, PathfindingComplete callback, GridManager gm)
 {
     this.gridManager = gm;
     character        = c;
     startNode        = start;
     endNode          = target;
     completeCallback = callback;
 }
Exemplo n.º 4
0
 public Pathfinder(
     GridCharacter character,
     Node startNode,
     Node targetNode,
     PathfindingComplete callback,
     GridManager gridManager
     )
 {
     this.character        = character;
     this.startNode        = startNode;
     this.endNode          = targetNode;
     this.completeCallback = callback;
     this.gridManager      = gridManager;
 }
Exemplo n.º 5
0
        public bool RequestPathfind(Vector3 start, Vector3 target, AIController pathRequester, PathfindingComplete callback)
        {
            if (!IsPointWithinPlayableArea(target))
            {
                return(false);
            }

            Pathfinder finder = new Pathfinder(start, target, pathRequester, callback);

            _queue.Add(finder);

            return(true);
        }