public void UnloadConnectionNode(Model.Connection.Connection connection) { var nodeObject = GraphController.Graph.ConnectionNodes[connection]; GraphController.Graph.ConnectionNodes.Remove(connection); AnimScaleConnectionNodeSize(nodeObject, -1, 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)); }
public void LoadConnection(Model.Connection.Connection connection, ConnectionDistributionService distributionService) { if (connection == null || graph.ConnectionObjectMap.ContainsKey(connection)) { return; } InitConnection(connection, distributionService); controller.OnConnectionLoaded?.Invoke(connection); }
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); }
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); }
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); }
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); } }
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)); }
public void SetConnectionLineColor(Model.Connection.Connection connection) { graph.ConnectionObjectMap[connection].GetComponent <LineRenderer>().material.color = GetConnectionLineColor(connection); }