本文整理汇总了C#中Path.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Pop方法的具体用法?C# Path.Pop怎么用?C# Path.Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.Pop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPath
private void SetPath(Path path, bool isWaypoint)
{
_endOfResolvedPath = path.Last().position;
_currentGrid = GridManager.instance.GetGrid(path.Peek().position);
if (isWaypoint)
{
_remainingPathDistance += path.CalculateLength();
_currentPath = _currentPath.AppendSegment(path);
}
else
{
if (!TrimPath(path))
{
RequestPath(_transform.position, _wayPoints.desiredEndOfPath, InternalPathRequest.Type.Normal);
_currentPath = null;
return;
}
_currentPath = path;
_remainingPathDistance = path.CalculateLength();
//Pop the first node as our next destination.
_currentDestination = path.Pop();
_curPlannedDirection = _transform.position.DirToXZ(_currentDestination.position);
}
_unit.hasArrivedAtDestination = false;
}
示例2: SetManualPath
private void SetManualPath(Path path, ReplanCallback onReplan)
{
if (path == null || path.count == 0)
{
StopInternal();
return;
}
_stop = false;
_stopped = false;
_onFinalApproach = false;
_manualReplan = onReplan;
_currentPath = path;
_endOfResolvedPath = _currentPath.Last().position;
_currentDestination = path.Pop();
_currentGrid = GridManager.instance.GetGrid(_currentDestination.position);
_endOfPath = _endOfResolvedPath;
_lastPathRequestTime = Time.time;
}
示例3: CompletePathSegment
private bool CompletePathSegment(PathingStatus status)
{
if (status != PathingStatus.Complete)
{
return false;
}
_currentResult.pathCost += _goal.g;
//Fix the actual destination so it does not overlap obstructions
FixupGoal(_segmentRequest);
if (_segmentRequest.type == RequestType.IntelOnly)
{
return true;
}
var maxPathLength = Mathf.CeilToInt(_goal.g / (_goal.parent.cellSize * _costProvider.baseMoveCost));
Path pathSegment;
if (_segmentRequest.pathFinderOptions.usePathSmoothing)
{
pathSegment = _smoother.Smooth(_goal, maxPathLength, _segmentRequest, _cellCostStrategy);
}
else
{
pathSegment = new Path(maxPathLength);
//Push the actual end position as the goal
pathSegment.Push(new Position(_segmentRequest.to));
IPathNode current = _goal.predecessor;
while (current != null)
{
pathSegment.Push(current);
current = current.predecessor;
}
//Instead of testing for it in the while loop, just pop off the start node and replace it with the actual start position
if (pathSegment.count > 1)
{
pathSegment.Pop();
}
pathSegment.Push(new Position(_segmentRequest.from));
}
_segments.Add(pathSegment);
return true;
}
示例4: ConsumeResult
private bool ConsumeResult()
{
//Since result processing may actually repath and consequently a new result may arrive we need to operate on locals and null the pending result
PathResult result;
lock (_syncLock)
{
result = _pendingResult;
_pendingResult = null;
}
var req = result.originalRequest as InternalPathRequest;
//Consume way points if appropriate. This must be done prior to the processing of the result, since if the request was a way point request, the first item in line is the one the result concerns.
if (req.pathType == InternalPathRequest.Type.Waypoint)
{
_wayPoints.Dequeue();
}
else if (req.pathType == InternalPathRequest.Type.PathboundWaypoint)
{
_pathboundWayPoints.Dequeue();
}
//Reset current destination and path no matter what
_previousDestination = _transform.position;
_currentDestination = null;
_currentPath = null;
//Process the result
if (!ProcessAndValidateResult(result))
{
return false;
}
//Consume the result
_onFinalApproach = false;
_currentPath = result.path;
_currentGrid = req.fromGrid;
_remainingSquaredDistance = _currentPath.CalculateSquaredLength();
_endOfResolvedPath = _currentPath.Last().position;
_endOfPath = _endOfResolvedPath;
//Update pending way points
UpdatePathboundWaypoints(result.pendingWaypoints);
//Pop the first node as our next destination.
_unit.hasArrivedAtDestination = false;
_currentDestination = _currentPath.Pop();
return true;
}