Example #1
0
        public BehaviorTreePrinter(IBehaviorTree tree, Vector2 windowSize)
        {
            StatusIcons  = new StatusIcons();
            SharedStyles = new GuiStyleCollection();

            var container = new GraphContainerVertical();

            container.SetGlobalPosition(SCROLL_PADDING, SCROLL_PADDING);
            _root = new VisualTask(tree.Root, container);
            container.CenterAlignChildren();

            _containerSize = new Rect(0, 0,
                                      container.Width + SCROLL_PADDING * 2,
                                      container.Height + SCROLL_PADDING * 2);

            CenterScrollView(windowSize, container);
        }
        public void Root_should_push_down_the_next_node()
        {
            var tree = new GraphContainerVertical();

            tree.SetGlobalPosition(300, 0);
            var nodeWrapper = new GraphContainerVertical();
            var box         = new GraphBox();

            box.SetSize(50, 50);
            var childrenContainer = new GraphContainerHorizontal();

            var childWrapper = new GraphContainerVertical();
            var childBox     = new GraphBox();

            childBox.SetSize(50, 50);

            nodeWrapper.AddBox(box);
            Assert.AreEqual(50, nodeWrapper.Height);
            Assert.AreEqual(50, nodeWrapper.Width);
            Assert.AreEqual(0, box.GlobalPositionY);

            childWrapper.AddBox(childBox);
            Assert.AreEqual(50, nodeWrapper.Height);
            Assert.AreEqual(50, nodeWrapper.Width);

            childrenContainer.AddBox(childWrapper);
            Assert.AreEqual(50, nodeWrapper.Height);
            Assert.AreEqual(50, nodeWrapper.Width);
            Assert.AreEqual(0, childrenContainer.GlobalPositionY);

            nodeWrapper.AddBox(childrenContainer);
            Assert.AreEqual(100, nodeWrapper.Height);
            Assert.AreEqual(50, nodeWrapper.Width);
            Assert.AreEqual(50, childrenContainer.GlobalPositionY);

            tree.AddBox(nodeWrapper);
            Assert.AreEqual(0, nodeWrapper.LocalPositionY);
            Assert.AreEqual(0, nodeWrapper.GlobalPositionY);
            Assert.AreEqual(50, childrenContainer.GlobalPositionY);
            Assert.AreEqual(0, box.GlobalPositionY);
        }