Beispiel #1
0
 public NodeStatusIcon(Texture2D texture, RenderedNode node, Func <Vector2> position, double timeUntilDisposal)
 {
     Node                   = node;
     Texture                = texture;
     this.position          = position;
     this.timeUntilDisposal = timeUntilDisposal;
 }
Beispiel #2
0
 public TriggeredNodeCover(Texture2D texture, RenderedNode node, Func <Vector2> position, double timeUntilDisposal, Color color)
 {
     Texture                = texture;
     Node                   = node;
     this.position          = position;
     this.timeUntilDisposal = timeUntilDisposal;
     this.color             = color;
 }
Beispiel #3
0
        private void DrawNodeContent(RenderedNode node, Vector2 nodePosition, SpriteBatch batch)
        {
            string nodeName = node.Name;
            string nodeType = node.BehaviorType;

            var nodeNameSize = StringSize(nodeName);
            var nodeTypeSize = StringSize(nodeType);

            DrawString(batch, nodePosition - new Vector2(nodeTypeSize.X / 2, -rowHeight / 2), nodeType, painter.NodeBehaviorType);
            DrawNodeBackground(batch, nodePosition, painter.NodeTitleBackground, (int)nodeWidth, (int)nodeTypeSize.Y, 0.11f);
            DrawString(batch, nodePosition - new Vector2(nodeNameSize.X / 2, 0), nodeName, painter.NodeName);
        }
Beispiel #4
0
        private int CountLargestNameCharacters(RenderedNode node, int currentLargest)
        {
            int largestCharacterCount = currentLargest;

            if (node != null)
            {
                largestCharacterCount = Math.Max(
                    Math.Max(node.Name.Count(), currentLargest),
                    node.BehaviorType.Count());
            }
            return(largestCharacterCount);
        }
Beispiel #5
0
        private void AddBehaviorCover(RenderedNode node, EventArgs args)
        {
            var alreadyRegisteredNode = virtualizationItems.Where(x => x.Node == node).FirstOrDefault();

            if (alreadyRegisteredNode != null)
            {
                alreadyRegisteredNode.Reset();
                return;
            }

            var triggeredNode = new TriggeredNodeCover(
                nodeBackgroundTexture,
                node,
                () => new Vector2(node.PositionX, ((node.Row * rowStep) + initialRow) * rowHeight),
                2.0d,
                painter.Triggered);

            virtualizationItems.Add(triggeredNode);
        }
Beispiel #6
0
        private void AddNode(IBehaviorNode <AIContext> node, Func <float> rowWidth, Func <float> nodeWidth, Func <float> linkX, int nodeCount, int column, int depth)
        {
            string nodeType = node.GetType().Name;
            var    nodeInfo = new RenderedNode(
                nodeType.Substring(0, nodeType.Count() - 2),
                depth,
                node.Name,
                () => AlignRelativeTo(() => linkX(), nodeWidth(), nodeCount, column, depth));

            onAddAction(nodeInfo, node);
            nodeVisualizationInfo[depth].Add(nodeInfo);

            var          subNodes      = node.SubNodes.ToArray();
            Func <float> linkPositionX = () => nodeInfo.PositionX;

            for (int nodeIndex = 0; nodeIndex < subNodes.Count(); nodeIndex++)
            {
                if (nodeIndex == 0)
                {
                    var newLink = new LinkBase(nodeInfo, linkPositionX, subNodes.Count());
                    if (nodeVisualizationInfo.ContainsKey(depth + 1))
                    {
                        nodeVisualizationInfo[depth + 1].Add(newLink);
                    }
                    else
                    {
                        nodeVisualizationInfo.Add(depth + 1,
                                                  new List <IBehaviorVirtualizationPiece>(new[] {
                            newLink as IBehaviorVirtualizationPiece,
                        }));
                    }
                }
                AddNode(subNodes[nodeIndex],
                        () => NodeWidth() * (subNodes.Count()),
                        () => NodeWidth(),
                        linkPositionX,
                        subNodes.Count() + 1,
                        nodeIndex,
                        depth + 1);
            }
        }
Beispiel #7
0
        public TreeAnalyzer(Action <IBehaviorVirtualizationPiece, IBehaviorNode <AIContext> > onAddAction,
                            IBehaviorNode <AIContext> root)
        {
            this.onAddAction = onAddAction;
            string nodeType = root.GetType().Name;
            var    rootInfo = new RenderedNode(
                nodeType.Substring(0, nodeType.Count() - 2),
                0,
                root.Name,
                () => AlignRelativeTo(() => TreeWidth() / 2, NodeWidth(), 1, 0, 0));

            onAddAction(rootInfo, root);

            nodeVisualizationInfo.Add(0,
                                      new List <IBehaviorVirtualizationPiece>(new[] { rootInfo }));

            var          subNodes      = root.SubNodes.ToArray();
            Func <float> linkPositionX = () => rootInfo.PositionX;

            LinkBase link = new LinkBase(
                rootInfo,
                linkPositionX,
                subNodes.Count());

            nodeVisualizationInfo.Add(1,
                                      new List <IBehaviorVirtualizationPiece>(new[] {
                link as IBehaviorVirtualizationPiece,
            }));
            for (int nodeIndex = 0; nodeIndex < subNodes.Count(); nodeIndex++)
            {
                AddNode(subNodes[nodeIndex],
                        () => TreeWidth(),
                        () => NodeWidth(),
                        linkPositionX,
                        subNodes.Count() + 1,
                        nodeIndex,
                        1);
            }
        }
Beispiel #8
0
        private void AddIcon(RenderedNode node, BehaviorResult?result)
        {
            if (result == null)
            {
                return;
            }

            var texture = BehaviorTextures[result.Value];

            var registeredItem = virtualizationItems
                                 .Where(item => item is NodeStatusIcon)
                                 .Where(x => x.Node == node)
                                 .FirstOrDefault();

            if (registeredItem != null)
            {
                virtualizationItems.Remove(registeredItem);
            }

            virtualizationItems.Add(new NodeStatusIcon(texture,
                                                       node,
                                                       () => new Vector2(node.PositionX, ((node.Row * rowStep) + initialRow) * rowHeight),
                                                       2.0f));
        }
Beispiel #9
0
 public LinkBase(RenderedNode linkedNode, Func <float> position, int nodeCount)
 {
     NodeCount     = nodeCount;
     LinkedNode    = linkedNode;
     this.position = position;
 }