Exemplo n.º 1
0
            public Space(AgentMeeting.Node agentNode, Rect rect) : this()
            {
                AgentNode  = agentNode;
                ChildCount = agentNode.Size();

                Rect = rect;

                const float heightMargin    = 0.1f;
                const float availableHeight = 1f - 2f * heightMargin;
                const float widthMargin     = 0.1f;
                const float availableWidth  = 1f - 2f * widthMargin;

                Position = new Vector2(
                    widthMargin + rect.x + rect.width / 2f,
                    heightMargin + availableHeight * (rect.y + rect.height / 2f)
                    );

                Radius = 0.036f + Mathf.Pow(agentNode.Size() * 0.00002f, 0.36f);
            }
Exemplo n.º 2
0
        private List <Space> CalculateSpacing(AgentMeeting.Node agentNode, Rect rect)
        {
            var totalChildAgentCount = agentNode.Size();

            if (totalChildAgentCount == 0)
            {
                return(null);
            }

            var spaces = new List <Space>(totalChildAgentCount);

            spaces.Add(new Space(agentNode, rect));

            if (totalChildAgentCount == 1)
            {
                return(spaces);
            }

            var childAgentCount = agentNode.Children.Count;

            const float heightGap       = 0.1f;
            var         availableHeight = rect.height - (childAgentCount - 1) * heightGap;
            var         perAgentHeight  = availableHeight / totalChildAgentCount;

            var childSpace = new Rect(rect);

            childSpace.x += rect.width;

            for (var i = 0; i < childAgentCount; i++)
            {
                childSpace.height = perAgentHeight * agentNode.Children[i].Size();

                spaces.AddRange(
                    CalculateSpacing(agentNode.Children[i], childSpace)
                    );

                childSpace.y += childSpace.height + heightGap;
            }

            return(spaces);
        }