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


C# Edge.MakeConnection方法代码示例

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


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

示例1: GenerateEvenConnections

        /// <summary>
        /// 
        /// </summary>
        private void GenerateEvenConnections()
        {
            List<Node> previousColumn = new List<Node>();
            List<Node> currentColumn = new List<Node>();

            // Make connections along the X coordinate
            foreach (Node node in Milestones.OrderBy(o => o.Y).OrderBy(o => o.X))
            {
                // There are other nodes that we can make connections to
                if (currentColumn.Count != 0)
                {
                    // Now we figure out what near by nodes we need to connect to

                    // If the node is starting a new column
                    if (currentColumn.Last().Y >= node.Y)
                    {
                        // place the "currentColumn" as the previous column and
                        // create a new current column
                        previousColumn = currentColumn;
                        currentColumn = new List<Node>();
                    }
                    else // we are continueing along the same column
                    {
                        // create an edge to the previous node since we are on the same column
                        Edge edge = new Edge(node, currentColumn.Last());
                        if (edge.Link(Obstacles))
                            edge.MakeConnection();
                    }

                    // Make connections to the nodes from the previous column
                    foreach (Node previousNode in previousColumn.
                        Where(o => o.Y == node.Y - 1
                            || o.Y == node.Y
                            || o.Y == node.Y + 1))
                    {
                        Edge previousColumnEdge = new Edge(node, previousNode);
                        if (previousColumnEdge.Link(Obstacles))
                            previousColumnEdge.MakeConnection();
                    }
                }
                // Add the node to the current column list
                currentColumn.Add(node);
            }
        }
开发者ID:testing32,项目名称:AIProjects,代码行数:47,代码来源:Workspace.cs


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