상속: ANode
예제 #1
0
파일: AiTree.cs 프로젝트: marekdaniluk/lab
 /// <summary>
 /// Creates connection between one node to another. The connection is one one-way and tries to prevent circular to prevent infinity loops.
 /// </summary>
 /// <param name="from">A node that is higher in hierarchy.</param>
 /// <param name="to">A node that is lower in hierarchy.</param>
 /// <returns>True if connection succeed. Otherwise false.</returns>
 public bool ConnectNodes(AFlowNode from, ANode to)
 {
     if (_nodes.Contains(from) && _nodes.Contains(to) && to != Root) {
         var n = to as AFlowNode;
         if (n != null) {
             //check nodes recursive to prevent circular trees
             if (IsConnected(from, n)) {
                 return false;
             }
         }
         return from.AddNode(to);
     }
     return false;
 }
예제 #2
0
 private bool IsConnected(AFlowNode from, AFlowNode to)
 {
     for (int i = 0; i < to.NodeCount; ++i)
     {
         var n = to.GetNode(i) as AFlowNode;
         if (n != null)
         {
             if (from == n || IsConnected(from, n))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
예제 #3
0
 /// <summary>
 /// Creates connection between one node to another. The connection is one one-way and tries to prevent circular to prevent infinity loops.
 /// </summary>
 /// <param name="from">A node that is higher in hierarchy.</param>
 /// <param name="to">A node that is lower in hierarchy.</param>
 /// <returns>True if connection succeed. Otherwise false.</returns>
 public bool ConnectNodes(AFlowNode from, ANode to)
 {
     if (_nodes.Contains(from) && _nodes.Contains(to) && to != Root)
     {
         var n = to as AFlowNode;
         if (n != null)
         {
             //check nodes recursive to prevent circular trees
             if (IsConnected(from, n))
             {
                 return(false);
             }
         }
         return(from.AddNode(to));
     }
     return(false);
 }
예제 #4
0
파일: AiTree.cs 프로젝트: marekdaniluk/lab
 private bool IsConnected(AFlowNode from, AFlowNode to)
 {
     for (int i = 0; i < to.NodeCount; ++i) {
         var n = to.GetNode(i) as AFlowNode;
         if (n != null) {
             if (from == n || IsConnected(from, n)) {
                 return true;
             }
         }
     }
     return false;
 }
예제 #5
0
 private void ConnectCallback(object obj)
 {
     var n = obj as AFlowNode;
     if (n != null) {
         _startConnection = n;
     }
 }
예제 #6
0
 private void NodeLeftClicked(ANode node)
 {
     if (_tree == null || !_tree.Nodes.Contains(node)) {
         return;
     }
     Selection.activeObject = node;
     if(_startConnection != null) {
         if(_startConnection != node && _tree.ConnectNodes(_startConnection, node)) {
             AssetDatabase.SaveAssets();
         }
         _startConnection = null;
     }
 }