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