示例#1
0
 private Node AddConnectionInDirection(Node node, Vector3 direcion)
 {
     Node nearestNode = finder.GetNearsetNodeInDirection(node, direcion);
     if (nearestNode != null) {
         Connection newConnection = new Connection(node, nearestNode, 1);
         _connections.Add(newConnection);
         node.AddConnection(newConnection);
     }
     return nearestNode;
 }
        private List<Connection> CreatePath(Connection connection, List<Connection> markedConnections)
        {
            List<Connection> path = new List<Connection> ();
            if (!path.Contains (connection) && !markedConnections.Contains (connection))
            {
                markedConnections.Add (connection);
                path.Add (connection);
            }

            if (connection.ToNode.Id != reachPoint)
            {
                List<Connection> alternativePaths = pathInfo.Connections.FindAll (c => c.FromNode.Id == connection.ToNode.Id && c.ToNode.Id != connection.FromNode.Id && !markedConnections.Contains (c));
                bool hasAlternativePaths = alternativePaths.Count > 0;
                if (hasAlternativePaths)
                    path.AddRange (AddAlternativePaths (alternativePaths, markedConnections));
            }

            return path;
        }