當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。