本文整理汇总了C#中Path.Last方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Last方法的具体用法?C# Path.Last怎么用?C# Path.Last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.Last方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
_arrivalEvent = UnitNavigationEventMessage.Event.DestinationReached;
_manualReplan = onReplan;
int pathCount = path.count - 1;
for (int i = 0; i < pathCount; i++)
{
var node = path[i];
if (node is Waypoint)
{
_wayPoints.AddWaypoint(node.position);
}
}
_wayPoints.AddWaypoint(path.Last().position, true);
SetPath(path, false);
_lastPathRequestTime = Time.time;
}
示例3: 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;
}
示例4: GetFile
public IFile GetFile(string filePath)
{
var resolvedFilePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(CurrentDirectory, filePath));
var pathSegments = new Path(resolvedFilePath).Segments;
var ownerFolder = pathSegments
.Skip(1).Take(pathSegments.Count()-2)
.Aggregate((IDirectory)GetRoot(pathSegments.First()),
(current, segment) => current.GetDirectory(segment));
return ownerFolder.GetFile(pathSegments.Last());
}
示例5: 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;
}