本文整理汇总了C#中PathNode.IsVisited方法的典型用法代码示例。如果您正苦于以下问题:C# PathNode.IsVisited方法的具体用法?C# PathNode.IsVisited怎么用?C# PathNode.IsVisited使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathNode
的用法示例。
在下文中一共展示了PathNode.IsVisited方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNewPath
void GetNewPath(PathNode pathNode)
{
//if we're trying to get a new path at a visited node that isn't the last one we visited, we're trying to crossover and should stop.
if (pathNode.IsVisited() && travelPath.Count > 0 && travelPath.Peek() != pathNode)
{
Debug.Log("Flashing!");
puzzle.lineWarning.Flash();
return;
}
//pop the node we're at off the travel stack if it's on it (gets readded later so long as we're not doubling back)
if (travelPath.Count > 0 && travelPath.Peek() == pathNode) travelPath.Pop();
//determine best neighbor to path to next based on mouse delta
Vector3 mouseDelta = MouseScreenToWorldPoint() - mousePosLast;
List<PathNode> neighbors = puzzle.GetNeighborsOf(pathNode);
PathNode bestNeighbor = neighbors[0];
float mouseDeltaDotBest = -2f;
foreach (PathNode neighbor in neighbors)
{
float curDotPath = Vector2.Dot(mouseDelta.normalized, (neighbor.transform.position - pathNode.transform.position).normalized);
if (curDotPath > mouseDeltaDotBest)
{
bestNeighbor = neighbor;
mouseDeltaDotBest = curDotPath;
}
}
//set node's visited status
//if best neighbor isn't part of travel path then add this node to travel path and set as traveled
if (!(travelPath.Count > 0 && travelPath.Peek() == bestNeighbor))
{
pathNode.SetVisted(true);
if (travelPath.Count > 0)
{
Edge e = puzzle.GetEdge(pathNode, travelPath.Peek());
e.line.GetComponent<MeshRenderer>().material = puzzle.lineVisitedMat;
}
nearTrail.startAnchor = pathNode.gameObject;
travelPath.Push(pathNode);
}
//if best neighbor is part of travel path then we're backtracking.
else
{
pathNode.SetVisted(false);
if (travelPath.Count > 0)
{
Edge e = puzzle.GetEdge(pathNode, travelPath.Peek());
e.line.GetComponent<MeshRenderer>().material = puzzle.lineUnvisitedMat;
nearTrail.startAnchor = travelPath.Peek().gameObject;
}
else nearTrail.startAnchor = gameObject;
}
nearTrail.Refresh();
//set new path anchors
anchorA = pathNode.gameObject.transform;
anchorB = bestNeighbor.gameObject.transform;
if (lerpDist > pathNode.snapRadius / Vector2.Distance(anchorA.position, anchorB.position)) lerpDist = 0f;
}