示例#1
0
        public void UnloadConnectionNode(Model.Connection.Connection connection)
        {
            var nodeObject = GraphController.Graph.ConnectionNodes[connection];

            GraphController.Graph.ConnectionNodes.Remove(connection);
            AnimScaleConnectionNodeSize(nodeObject, -1, 0);
        }
示例#2
0
        private void StartConnectionAnimation(Model.Connection.Connection connection, AnimationDirection direction)
        {
            var connectionObject = graph.ConnectionObjectMap[connection];
            var function         = AnimateConnection(connectionObject, connection, direction);

            StartAnimation(connectionObject, new ConnectionAnimation(function, direction));
        }
示例#3
0
 public void LoadConnection(Model.Connection.Connection connection, ConnectionDistributionService distributionService)
 {
     if (connection == null || graph.ConnectionObjectMap.ContainsKey(connection))
     {
         return;
     }
     InitConnection(connection, distributionService);
     controller.OnConnectionLoaded?.Invoke(connection);
 }
示例#4
0
 private Color GetConnectionLineColor(Model.Connection.Connection connection)
 {
     if (!connection.Ends.Contains(controller.NodeController.SelectedNode))
     {
         return(controller.Colors.DisabledColor);
     }
     if (controller.GraphController.ConnectionMode.Value == ConnectionMode.CHILDREN && (connection.Item1.Type == NodeType.CATEGORY || connection.Item2.Type == NodeType.CATEGORY))
     {
         return(controller.Colors.CategoryColor);
     }
     return(controller.GraphController.ConnectionMode.Value == ConnectionMode.PARENTS ? controller.Colors.ParentColor : controller.Colors.ChildColor);
 }
示例#5
0
        public void UnloadConnection(Model.Connection.Connection connection)
        {
            if (!graph.ConnectionObjectMap.ContainsKey(connection))
            {
                return;
            }
            StartConnectionAnimation(connection, AnimationDirection.IN);
            graph.ConnectionObjectMap.Remove(connection);

            if (graph.ConnectionNodes.ContainsKey(connection))
            {
                controller.NodeController.NodeLoadManager.UnloadConnectionNode(connection);
            }

            controller.OnConnectionUnloaded?.Invoke(connection);
        }
示例#6
0
        private IEnumerator AnimateConnection(GameObject connectionObject, Model.Connection.Connection connection, AnimationDirection direction)
        {
            var line          = connectionObject.GetComponent <LineRenderer>();
            var segmentPoints = connection.ConnectionRoute.SegmentPoints;
            int currentCount  = line.positionCount;
            int dir           = (direction == AnimationDirection.OUT ? 1 : -1) * controller.ConnectionLoadSpeed;

            while (direction == AnimationDirection.OUT ? currentCount < segmentPoints.Length : currentCount > 0)
            {
                currentCount       = Mathf.Clamp(currentCount + dir, 0, segmentPoints.Length);
                line.positionCount = currentCount;
                if (direction == AnimationDirection.OUT)
                {
                    for (int i = 1; i <= dir; i++)
                    {
                        line.SetPosition(currentCount - i, segmentPoints[currentCount - i]);
                    }
                }
                yield return(new WaitForSeconds(.02f));
            }
            AnimationEndAction(connectionObject, direction);
        }
示例#7
0
        private void InitConnection(Model.Connection.Connection connection, ConnectionDistributionService distributionService)
        {
            if (!(Connected(connection.Item1, connection.Item2) || Connected(connection.Item2, connection.Item1)) && controller.NetworkController.IsServer())
            {
                logger.Warning("Attempting to create connection that does not exist");
            }

            GameObject connectionObject = controller.Connections.Pool.Spawn();
            Node       otherNode        = connection.OtherEnd(distributionService.CentralNode);

            distributionService.GenerateRoute(connection, otherNode);
            var centerNode = graph.NodeObjectMap[distributionService.CentralNode];

            InitConnectionObject(ref connectionObject, centerNode,
                                 graph.NodeObjectMap[otherNode], GetConnectionLineColor(connection));
            graph.ConnectionObjectMap.Add(connection, connectionObject);
            StartConnectionAnimation(connection, AnimationDirection.OUT);

            if (distributionService.CentralNode == controller.NodeController.SelectedNode)
            {
                GameObject conNode = controller.NodeController.NodeLoadManager.LoadConnectionNode(otherNode, centerNode.transform.position + connection.ConnectionRoute.SpherePoint);
                graph.ConnectionNodes.Add(connection, conNode);
            }
        }
示例#8
0
        public Model.Connection.Connection GetConnectionBetween(Node one, Node two)
        {
            var compareCon = new Model.Connection.Connection(one, two);

            return(ConnectionObjectMap.Keys.ToList().FirstOrDefault(con => con == compareCon));
        }
示例#9
0
 public void SetConnectionLineColor(Model.Connection.Connection connection)
 {
     graph.ConnectionObjectMap[connection].GetComponent <LineRenderer>().material.color = GetConnectionLineColor(connection);
 }