本文整理汇总了C#中Path.HasNext方法的典型用法代码示例。如果您正苦于以下问题:C# Path.HasNext方法的具体用法?C# Path.HasNext怎么用?C# Path.HasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.HasNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectOnPath
private void SelectOnPath()
{
Ray ray;
if (!GetRayToCursor(out ray))
{
// Outside of current map
return;
}
WVector3 v = new WVector3(float.MinValue, float.MinValue, float.MinValue);
IShape found = null;
foreach (var shape in Shapes)
{
if (shape.IntersectFirstTriangle(ray, out v) == -1) continue;
found = shape;
break;
}
if (found == null)
return;
selectedPoints.Add(new RegionalPoint
{
Shape = found,
Point = v
});
if (selectedPoints.Count <= 1) return;
// highlight corridor and visited fringe
var start = selectedPoints[0];
if (!(start.Shape is NavMesh)) return;
var dest = selectedPoints[1];
if (!(dest.Shape is NavMesh)) return;
var visited = new HashSet<int>();
var path = new Path();
var corridor = (start.Shape as NavMesh).Tile.Pathfinder.FindCorridor(start.Point, dest.Point, out visited);
if (corridor.IsNull) return;
// highlight fringe
/*foreach (var tri in visited)
{
SelectTriangle(tri, true, new Color(120, 10, 10, 128));
}*/
// highlight corridor
var current = corridor;
while (!current.IsNull)
{
// TODO: manage paths that cross tile boundaries.
SelectTriangle(start.Shape, current.Triangle, true);
current = current.Previous;
}
// draw line to along the path
(start.Shape as NavMesh).Tile.Pathfinder.FindPathStringPull(start.Point, dest.Point, corridor, path);
var p = start.Point;
LineSelectionRenderer.SelectPoint(start.Point, Color.Black);
while (path.HasNext())
{
var q = path.Next();
LineSelectionRenderer.SelectLine(p, q, Color.Green);
LineSelectionRenderer.SelectPoint(q, Color.Black);
p = q;
}
// highlight corners
/*current = corridor;
while (!current.IsNull)
{
//var tri = Tile.NavMesh.FindFirstTriangleUnderneath(curren);
SelectTriangle(current.Triangle, true);
if (current.Edge != -1 && current.Previous != null)
{
WVector3 left, right, apex;
Tile.NavMesh.GetOutsideOrderedEdgePointsPlusApex(current.Previous.Triangle, current.Edge, out left, out right, out apex);
LineSelectionRenderer.SelectPoint(left, Color.LimeGreen);
LineSelectionRenderer.SelectPoint(right, Color.Red);
LineSelectionRenderer.SelectPoint(apex, Color.Azure);
}
current = current.Previous;
}*/
}
示例2: SelectOnPath
private void SelectOnPath()
{
Ray ray;
if (!GetRayToCursor(out ray))
{
// Outside of current map
return;
}
WCell.Util.Graphics.Vector3 v;
if (Shape.IntersectFirstTriangle(ray, out v) == -1) return;
selectedPoints.Add(v);
if (selectedPoints.Count > 1)
{
// highlight corridor and visited fringe
var start = selectedPoints[0];
var dest = selectedPoints[1];
var visited = new HashSet<int>();
var path = new Path();
var corridor = Tile.Pathfinder.FindCorridor(start, dest, out visited);
if (corridor.IsNull) return;
// highlight fringe
foreach (var tri in visited)
{
SelectTriangle(tri, true, new Color(120, 10, 10));
}
// highlight corridor
var current = corridor;
while (!current.IsNull)
{
//var tri = Tile.NavMesh.FindFirstTriangleUnderneath(curren);
SelectTriangle(current.Triangle, true);
current = current.Previous;
}
// draw line to along the path
Tile.Pathfinder.FindPath(dest, corridor, path);
var last = start;
while (path.HasNext())
{
var p = path.Next();
LineSelectionRenderer.SelectLine(last, p, Color.Green);
last = p;
}
// highlight corners
current = corridor;
while (!current.IsNull)
{
//var tri = Tile.NavMesh.FindFirstTriangleUnderneath(curren);
SelectTriangle(current.Triangle, true);
if (current.Edge != -1 && current.Previous != null)
{
WVector3 left, right;
Tile.NavMesh.GetEdgePoints(current.Previous.Triangle, current.Edge, out left, out right);
LineSelectionRenderer.SelectPoint(left, Color.Purple);
LineSelectionRenderer.SelectPoint(right, Color.Blue);
}
current = current.Previous;
}
}
}