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


C# NavGraph.getEdge方法代码示例

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


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

示例1: g_func

    protected override float g_func(ref NavGraph para_graph, ref NavNode para_node1, ref NavNode para_node2)
    {
        NavEdge reqEdge = para_graph.getEdge(para_node1.getNodeID(),para_node2.getNodeID());

        float retGVal = 0;
        if(reqEdge == null)
        {
            retGVal = float.PositiveInfinity;
        }
        else
        {
            retGVal = reqEdge.getCost();
        }
        return retGVal;
    }
开发者ID:TAPeri,项目名称:WordsMatter,代码行数:15,代码来源:WorldAStarSearch.cs

示例2: renderNavGraph

    public static GameObject renderNavGraph(string para_renderName, NavGraph para_graph, Transform para_graphNodePrefab)
    {
        GameObject navGraphRenderObj = new GameObject(para_renderName);

        // Extract color info if needed.
        Color defaultColor = Color.white;
        Dictionary<int,Color> nodeTypeIDToColorMap = null;
        if(para_graph is ColoredNavGraph)
        {
            ColoredNavGraph castGraph = (ColoredNavGraph) para_graph;
            nodeTypeIDToColorMap = castGraph.createTypeIDToColorMap();
        }

        // Render Nodes:
        GameObject navNodesObj = new GameObject("Nodes");

        List<int> nodeKeys = para_graph.getAllNodeKeys();
        for(int i=0; i<nodeKeys.Count; i++)
        {
            WorldNode reqNode = (WorldNode) para_graph.getNode(nodeKeys[i]);
            int reqNodeType = reqNode.getNodeType();
            /*int[] imgLocPt = reqNode.get2DLocationPt();

            Vector3 nodeWorldPt = new Vector3((gPropMapWorldBounds.x + (gPropMapWorldBounds.cellWidth/2f)) + (gPropMapWorldBounds.cellWidth * (imgLocPt[0] * 1.0f)),
                                              (gPropMapWorldBounds.y - (gPropMapWorldBounds.cellHeight/2f)) - (gPropMapWorldBounds.cellHeight * (imgLocPt[1] * 1.0f)),
                                              gPropMapWorldBounds.z);*/

            Vector3 nodeWorldPt = reqNode.getWorldPt();

            Transform nwNodePt = (Transform) Transform.Instantiate(para_graphNodePrefab,nodeWorldPt,Quaternion.identity);
            nwNodePt.name = "Node-"+reqNode.getNodeID();
            nwNodePt.parent = navNodesObj.transform;

            Color paintColor = defaultColor;
            if((nodeTypeIDToColorMap != null)
            &&(nodeTypeIDToColorMap.ContainsKey(reqNodeType)))
            {
                paintColor = nodeTypeIDToColorMap[reqNodeType];
            }
            nwNodePt.renderer.material.color = paintColor;
        }

        // Render Edges:
        GameObject navEdgesObj = new GameObject("Edges");

        List<string> edgeKeys = para_graph.getAllEdgeKeys();
        for(int i=0; i<edgeKeys.Count; i++)
        {
            NavEdge reqEdge = para_graph.getEdge(edgeKeys[i]);
            int[] nodesOnEdge = reqEdge.getNodeIDs();

            Vector3 node1Pt = (GameObject.Find("Node-"+nodesOnEdge[0])).transform.position;
            Vector3 node2Pt = (GameObject.Find("Node-"+nodesOnEdge[1])).transform.position;

            GameObject nwEdge = new GameObject("Edge:"+nodesOnEdge[0]+"-"+nodesOnEdge[1]);
            LineRenderer lRend = nwEdge.AddComponent<LineRenderer>();

            lRend.castShadows = false;
            lRend.receiveShadows = false;
            lRend.SetVertexCount(2);
            lRend.SetWidth(0.1f,0.1f);
            lRend.SetPosition(0,node1Pt);
            lRend.SetPosition(1,node2Pt);
            lRend.SetColors(Color.yellow,Color.yellow);
            lRend.material = new Material(Shader.Find("Diffuse"));//"Particles/Additive"));

            nwEdge.transform.parent = navEdgesObj.transform;
        }

        // Finish Object.
        navNodesObj.transform.parent = navGraphRenderObj.transform;
        navEdgesObj.transform.parent = navGraphRenderObj.transform;

        return navGraphRenderObj;
    }
开发者ID:TAPeri,项目名称:WordsMatter,代码行数:75,代码来源:NavGraphUnityUtils.cs


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