Esempio n. 1
0
        public static BTNode CreateNode(BTNodeData btNodeData, BTree bTree, BTNode parent)
        {
            if (btNodeData is BTActionNodeData)
            {
                return(BTActionNode.CreateActionNode(btNodeData, bTree, parent));
            }
            else if (btNodeData is BTDecoratorNodeData)
            {
                return(BTDecoratorNode.CreateDecoratorNode(btNodeData, bTree, parent));
            }
            else if (btNodeData is BTCompositeNodeData)
            {
                return(BTCompositeNode.CreateCompositeNode(btNodeData, bTree, parent));
            }

            return(null);
        }
Esempio n. 2
0
        internal void AdjustChildrenSequence(BTEditorRectangle _rectangle, Point _worldPos)
        {
            BTCompositeNode node = m_node as BTCompositeNode;

            if (node.Children != null)
            {
                node.Children.Remove(_rectangle.Node);
                int targetIndex = 0;
                foreach (BTNode child in node.Children)
                {
                    if (m_treeViewer.GetRectangle(child).GetPosition().Y >
                        _worldPos.Y)
                    {
                        break;
                    }
                    ++targetIndex;
                }
                node.Children.Insert(targetIndex, _rectangle.Node);
            }
        }
Esempio n. 3
0
 internal override int AutoRecursivelyLayout(Dictionary <string, BTEditorSprite> _sprites, Point _leftTop)
 {
     if (m_node != null)
     {
         // children
         BTCompositeNode node = m_node as BTCompositeNode;
         int             x    = _leftTop.X + m_bound.Width + HorizontalInterval;
         int             y    = _leftTop.Y;
         if (node.Children != null)
         {
             foreach (BTNode child in node.Children)
             {
                 string key = GetKey(child);
                 if (_sprites.ContainsKey(key))
                 {
                     BTEditorRectangle childNode = _sprites[key] as BTEditorRectangle;
                     int height = childNode.AutoRecursivelyLayout(_sprites, new Point(x, y));
                     y += height + VerticalInterval;
                 }
                 else
                 {
                     Debug.Assert(false, "Cannot find sprite for node");
                 }
             }
         }
         // self
         if (y != _leftTop.Y)
         {
             y -= VerticalInterval;
         }
         int needHeight = (m_bound.Height > (y - _leftTop.Y)) ? (m_bound.Height) : (y - _leftTop.Y);
         m_bound.X = _leftTop.X;
         m_bound.Y = _leftTop.Y + (needHeight - m_bound.Height) / 2;
         return(needHeight);
     }
     else
     {
         Debug.Assert(false, "Cannot find corresponding node");
         return(0);
     }
 }
Esempio n. 4
0
 protected override void RecursivelyCreatChildren(Dictionary <string, BTEditorSprite> _sprites)
 {
     if (m_node != null)
     {
         BTCompositeNode node = m_node as BTCompositeNode;
         if (node.Children != null)
         {
             foreach (BTNode child in node.Children)
             {
                 string lineKey = BTEditorLine.GetKey(m_node, child);
                 if (!_sprites.ContainsKey(lineKey))
                 {
                     // create link
                     BTEditorLine line = new BTEditorLine(m_treeViewer);
                     line.ParentNode = m_node;
                     line.ChildNode  = child;
                     _sprites.Add(line.GetKey(), line);
                 }
                 // do for children
                 RecursivelyCreateSprites(_sprites, child, m_treeViewer);
             }
         }
     }
 }