private void Start() { var unit = this.GetUnitFacade(); //The radius should of course be taken off the unit type that is doing the pick-up, but keeping it simple... var req = new BasicPathRequest() { from = unit.position, to = this.target.position, requester = this, requesterProperties = unit, pathFinderOptions = unit.pathFinderOptions }; GameServices.pathService.QueueRequest(req); }
public void RequestPath(Vector3 PathTo) { IUnitFacade unit = this.GetUnitFacade(); BasicPathRequest _pendingPathRequest = new BasicPathRequest { from = this.transform.position, to = PathTo, requester = this, requesterProperties = unit, pathFinderOptions = unit.pathFinderOptions, timeStamp = Time.time }; GameServices.pathService.QueueRequest(_pendingPathRequest, unit.pathFinderOptions.pathingPriority); }
private void Init() { if (unit == null) { Debug.LogWarning("The Path Finder Visualizer must have a unit set."); return; } _unit = this.unit.GetUnitFacade(); var g = GridManager.instance.GetGrid(_unit.position); _cellSize = g.cellSize; _gizmoSize = new Vector3(_cellSize, 0.2f, _cellSize); IMoveCost moveCostProvider; if (this.moveCost == CostProviderType.Custom) { var moveCostProviderFactory = this.As <IMoveCostFactory>(); if (moveCostProviderFactory == null) { moveCostProvider = new DiagonalDistance(10); Debug.LogWarning("Path Service Component: Cost Provider set to Custom but no Cost Provider Factory found!."); } else { moveCostProvider = moveCostProviderFactory.CreateMoveCostProvider(); } } else { switch (this.moveCost) { case CostProviderType.Euclidean: { moveCostProvider = new EuclideanDistance(10); break; } case CostProviderType.Cardinal: { moveCostProvider = new CardinalDistance(10); break; } case CostProviderType.Manhattan: { moveCostProvider = new ManhattanDistance(10); break; } default: { moveCostProvider = new DiagonalDistance(10); break; } } } var preProcessors = this.GetComponents(typeof(IRequestPreProcessor)).Cast <IRequestPreProcessor>().OrderByDescending(p => p.priority).ToArray(); //Setup the pathing engine to use if (this.engineType == PathingEngineType.Astar) { _engine = new VisualizedAStar(this.initialHeapSize, moveCostProvider, GameServices.cellCostStrategy, new PathSmoother(), preProcessors); } else { _engine = new VisualizedJPS(this.initialHeapSize, moveCostProvider, GameServices.cellCostStrategy, new PathSmoother(), preProcessors); } var tmp = new BasicPathRequest { requester = this, requesterProperties = _unit, pathFinderOptions = _unit.pathFinderOptions }; if (_req != null) { tmp.from = _req.from; tmp.to = _req.to; } _req = tmp; }