Beispiel #1
0
        public void OnEndDependency(UpgradeDependencyMode mode)
        {
            if (startNode != null)
            {
                if (lastNode != null)
                {
                    var success = NodeDependencies.CreateDependency(startNode, lastNode, config.techConfig, mode);
                    if (success)
                    {
                        UpdateContents();
                    }
                    lastNode.ActivatingLinkEnd();
                }
                startNode.ActivatingLinkEnd();
                startNode = null;
            }

            if (depLine != null)
            {
                if (nodeRoot.Contains(depLine))
                {
                    nodeRoot.Remove(depLine);
                }
                depLine = null;
            }
        }
Beispiel #2
0
 private void CreateDependencyLinks(Node node, List <Node> dependencies)
 {
     dependencies.ForEach(d =>
     {
         var line = new ConnectionElement(d, node, new Color(1f, 0.86f, 0.61f), 1.5f, true);
         dependencyLinks.Add(line);
     });
 }
Beispiel #3
0
 public void OnStartDependency(Vector2 mousePos)
 {
     if (lastNode != null)
     {
         startNode = lastNode;
         startNode.ActivatingLinkStart();
         depLine = new ConnectionElement(this, mousePos, Color.yellow, 2f, true);
         nodeRoot.Add(depLine);
     }
 }
        public override TreeElement GetElement()
        {
            if (Element.VisualElement != null)
            {
                return(Element);
            }

            var element = new VisualElement();

            element.AddToClassList("node-group");

            var linkChildrenButton = new Button();

            linkChildrenButton.AddToClassList("node-group-link-trigger");
            SetupChildLinkVisuals(element, linkChildrenButton);
            linkChildrenButton.clicked += () =>
            {
                ToggleChildrenLinked();
                SetupChildLinkVisuals(element, linkChildrenButton);
            };

            element.Add(new Label(action.name));
            element.AddToClassList("node-upgrade");

            element.style.top  = position.y;
            element.style.left = position.x;

            element.AddManipulator(this);
            element.Add(linkChildrenButton);

            Element.VisualElement = element;
            Element.SortOrder     = SortOrder;

            Element.Children = new List <TreeElement>();
            foreach (var subNode in subNodes)
            {
                var subElement = subNode.GetElement();
                Element.Children.Add(new TreeElement()
                {
                    Parent        = element,
                    VisualElement = subElement.VisualElement,
                    SortOrder     = subElement.SortOrder,
                });
                subNode.SetMoveWithParent(isChildrenLinked);

                var ce = new ConnectionElement(this, subNode, new Color(1f, 0f, 1f, 0.29f), 5f, true);
                ce.style.visibility = new StyleEnum <Visibility>(Visibility.Hidden);
                Element.Children.Add(new TreeElement()
                {
                    Parent = element, SortOrder = 1, VisualElement = ce
                });
            }

            return(Element);
        }
Beispiel #5
0
        private void ProcessCell(HexCell cell, Node node)
        {
            foreach (var action in cell.Actions)
            {
                if (action is UnitAction)
                {
                    continue;
                }

                var actionNode = data.techTreeData.GetNode(action);
                var line       = new ConnectionElement(node, actionNode, new Color(0.35f, 0.59f, 1f), 2f, true);
                nodeRoot.Add(line);
            }

            var buildAction = GetBuildActionForCell(cell);

            if (buildAction != null)
            {
                ProcessAction(buildAction, node);
            }
        }