コード例 #1
0
        public void Decode(CfgData data)
        {
            if (this == _dragging)
            {
                _dragging = null;
            }

            SetDirty();

            imageUrl     = "";
            _imageIndex -= 1;
            _coverImage  = null;
            _hideLabel   = false;

            _nodeEnteredVisuals       = new NodeVisualConfig();
            _nodeActiveDefaultVisuals = new NodeVisualConfig
            {
                enabled = true
            };
            _nodeInactiveVisuals = new NodeVisualConfig();

            // base.Decode(data);

            LoadCoverImage();
        }
コード例 #2
0
        public void SetFadeAwayRelation(NodeCircleController previous)
        {
            if (previous)
            {
                if (previous != this)
                {
                    _fadingIntoParent = (CurrentNode?.Contains(previous.myLastLinkedNode) ?? false) &&
                                        myLastLinkedNode.parentNode == previous.myLastLinkedNode;

                    if (_fadingIntoParent)
                    {
                        // _latestParent = previous;
                        _fadingRelation = previous;
                    }
                    else
                    {
                        _fadingRelation = CurrentNode?.visualRepresentation as NodeCircleController;
                    }
                }
                else
                {
                    _fadingIntoParent = false;
                    _fadingRelation   = CurrentNode?.visualRepresentation as NodeCircleController;
                }
            }
            else
            {
                _fadingRelation = null;
            }

            SetDirty();
        }
コード例 #3
0
        public void LinkTo(Base_Node node)
        {
            myLastLinkedNode = node;
            source           = node;

            Decode(source.LinkTo(this));

            NameForPEGI = source.name;
            isFading    = false;
            gameObject.SetActive(true);
            if (circleCollider)
            {
                circleCollider.enabled = true;
            }

            _latestParent = null;

            if (node.parentNode != null)
            {
                var vis = node.parentNode.visualRepresentation as NodeCircleController;
                if (vis != null)
                {
                    _latestParent = vis;
                }
            }
        }
コード例 #4
0
        public void SetStartPositionOn(NodeCircleController previous)
        {
            _canJumpToPosition = false;

            if (previous && previous != this)
            {
                if (source.parentNode == CurrentNode)
                {
                    var vis = CurrentNode.visualRepresentation as NodeCircleController;
                    if (vis)
                    {
                        transform.localPosition = vis.transform.localPosition;
                    }
                    circleRenderer.transform.localScale = Vector3.one;
                }
                else
                {
                    transform.localPosition = ActiveConfig.targetLocalPosition + (ActiveConfig.targetLocalPosition - previous.transform.localPosition).normalized * 10f;

                    circleRenderer.transform.localScale = ActiveConfig.targetSize * 2f;
                }
            }
            else
            {
                _canJumpToPosition = true;
            }

            SetDirty();
        }
コード例 #5
0
        private void UpdateVisibility(Base_Node node, NodeCircleController previous = null)
        {
            if (node == null)
            {
                return;
            }

            bool editingOrGotParent = (Shortcuts.editingNodes ||
                                       ((node.parentNode != null && node.Conditions_isVisible()) ||
                                        !Application.isPlaying));

            var current = Shortcuts.CurrentNode;

            bool currentNodeContains = (current != null && (node == current || current.Contains(node)));

            var shouldBeVisible = editingOrGotParent && currentNodeContains;

            if (node.visualRepresentation == null)
            {
                if (shouldBeVisible)
                {
                    MakeVisible(node, previous);
                }
            }
            else
            if (!shouldBeVisible)
            {
                MakeHidden(node, previous);
            }

            if (node.visualRepresentation != null)
            {
                (node.visualRepresentation as NodeCircleController).SetDirty();
            }
        }
コード例 #6
0
        private void MakeVisible(Base_Node node, NodeCircleController centerNode = null)
        {
            NodeCircleController nnp = null;

            if (!centerNode)
            {
                centerNode = node.parentNode?.visualRepresentation as NodeCircleController;
            }

            var reusing = false;

            if (node.previousVisualRepresentation != null)
            {
                var tmp = node.previousVisualRepresentation as NodeCircleController;
                if (tmp && tmp.isFading && node == tmp.myLastLinkedNode)
                {
                    nnp = tmp;
                    if (tmp.gameObject.activeSelf)
                    {
                        reusing = true;
                    }
                }
            }

            if (!nnp)
            {
                while (_firstFree < NodesPool.Count)
                {
                    var np = NodesPool[_firstFree];

                    if (!np.gameObject.activeSelf)
                    {
                        nnp = np;
                        break;
                    }

                    _firstFree++;
                }
            }

            if (!nnp)
            {
                if (!circlePrefab)
                {
                    return;
                }

                nnp = Instantiate(circlePrefab);
                nnp.IndexForPEGI = NodesPool.Count;
                NodesPool.Add(nnp);
            }

            nnp.LinkTo(node);

            if (!reusing)
            {
                nnp.SetStartPositionOn(centerNode);
            }
        }
コード例 #7
0
        private void Delete(NodeCircleController ctr)
        {
            var ind = NodesPool.IndexOf(ctr);

            NodesPool.RemoveAt(ind);
            _firstFree = Mathf.Min(_firstFree, ind);
            ctr.gameObject.DestroyWhatever();
        }
コード例 #8
0
 public void Deactivate(NodeCircleController n)
 {
     if (isFading)
     {
         Delete(n);
     }
     else
     {
         n.gameObject.SetActive(false);
         _firstFree = Mathf.Min(_firstFree, n.IndexForPEGI);
     }
 }
コード例 #9
0
        public void SetSelected(NodeCircleController node)
        {
            if (selectedNode)
            {
                selectedNode.SetDirty();
            }

            selectedNode = node;

            if (node)
            {
                node.SetDirty();
            }

            if (deleteButton)
            {
                deleteButton.gameObject.SetActive(selectedNode);
            }
        }
コード例 #10
0
        private void MakeHidden(Base_Node node, NodeCircleController previous = null)
        {
            var ncc = node.visualRepresentation as NodeCircleController;

            if (!ncc)
            {
                return;
            }

            ncc.Unlink();

            if (!Application.isPlaying)
            {
                Delete(ncc);
            }
            else
            {
                ncc.SetFadeAwayRelation(previous);
            }
        }
コード例 #11
0
        public void UpdateCurrentNodeGroupVisibilityAround(Node newCenter = null, NodeCircleController previousCenter = null)
        {
            if (!Application.isPlaying)
            {
                return;
            }

            if (newCenter == null)
            {
                return;
            }

            if (previousCenter == null)
            {
                previousCenter = newCenter.visualRepresentation as NodeCircleController;
            }

            UpdateVisibility(newCenter, previousCenter);
            foreach (var sub in newCenter)
            {
                UpdateVisibility(sub, previousCenter);
            }
        }
コード例 #12
0
        public void TryDragAndDrop()
        {
            if (_dragging)
            {
                return;
            }

            if (Input.GetMouseButtonDown(0))
            {
                //var gn = source.AsGameNode;

                // if (gn != null)
                //   Shortcuts.visualLayer.FromNodeToGame(gn);
                //else
                BoxButtons.inst.SetSelected(this);

                Vector3 pos;
                if (UpPlane.MouseToPlane(out pos, MainCamera))
                {
                    _dragging   = this;
                    _dragOffset = transform.position - pos;
                }
            }
        }