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


C# GridGraph.GetNodesInArea方法代码示例

本文整理汇总了C#中Pathfinding.GridGraph.GetNodesInArea方法的典型用法代码示例。如果您正苦于以下问题:C# GridGraph.GetNodesInArea方法的具体用法?C# GridGraph.GetNodesInArea怎么用?C# GridGraph.GetNodesInArea使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pathfinding.GridGraph的用法示例。


在下文中一共展示了GridGraph.GetNodesInArea方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: mohogonyGrid

        // this is the optimized version. Other graphs cannot be optimised this way because they have irregular structures unfortunately. Still, we shouldn't miss on the advantages of this specific graph type, so I included it specifically.
        void mohogonyGrid()
        {
            nodes = new List<Node>();
            nodes.Add(node as Node);
            graph = AstarPath.active.graphs[node.graphIndex] as GridGraph;

            GraphUpdateShape gus = new GraphUpdateShape();
            if (useRealCollider.Value)
            {

                if(go.collider.GetType() == typeof(BoxCollider)) // take render bounds, then turn them into world coordinates
                {
                    Debug.Log("It's a box collider");
                    bounds.center = (go.collider as BoxCollider).center;
                    bounds.size = (go.collider as BoxCollider).size;

                    calculateBox(gus);

                }
                else if(go.collider.GetType() == typeof(MeshCollider))
                {
                    gus.points = (go.collider as MeshCollider).sharedMesh.vertices;
                    for(var i=0; i < gus.points.Count(); i++ )
                    {
                        gus.points[i] = go.transform.TransformPoint((go.collider as MeshCollider).sharedMesh.vertices[i]);
                    }
                    Debug.Log("It's a mesh collider!");
                }
                else // any other collider
                {
                    calculateBox(gus);
                    Debug.Log("This type of collider is not specifically supported. Using bounds instead...");
                }

            }

            else // get the points of the render bounds
            {
                bounds = (go.renderer.GetComponent<MeshFilter>()).sharedMesh.bounds;
                calculateBox(gus);
            }

            //gus.convex = true;
            nodes = graph.GetNodesInArea(gus);

            if(getWalkableOnly.Value)
            {
                connected = new List<Node>();
                for(var i=0; i < nodes.Count(); i++ )
                {
                    if(nodes[i].walkable)
                    {
                        connected.Add(nodes[i]); // connected is a substitute for a better named one :D There is no real sense behind the name here.
                    }
                }
                nodesOutput.Value = SetNodes(connected);
            }

            else
            {
                nodesOutput.Value = SetNodes(nodes);
            }

            Debug.Log("i" + nodes.Count);

            return;
        }
开发者ID:kiriri,项目名称:playmaker-astar-actions,代码行数:68,代码来源:GetNodesInArea.cs


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