当前位置: 首页>>代码示例>>C#>>正文


C# PathNode.IsVisited方法代码示例

本文整理汇总了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;
    }
开发者ID:Bekwnn,项目名称:The-Witness-Puzzles,代码行数:65,代码来源:LineMovement.cs


注:本文中的PathNode.IsVisited方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。