Example #1
0
        private void AddPoint(Map.Point point, TimelinePoint prefab, Dictionary <Map.Point, TimelinePoint> dict, float songLength)
        {
            float timePercentage     = point.time / songLength;
            float positionOnTimeline = timePercentage * space.localScale.x * 10 / zoom;

            if (prefab != null && space != null)
            {
                if (dict == null)
                {
                    dict = new Dictionary <Map.Point, TimelinePoint>();
                }
                if (dict.ContainsKey(point) && dict[point] == null)
                {
                    dict.Remove(point);
                }
                if (!dict.ContainsKey(point))
                {
                    TimelinePoint timelinePoint = Instantiate(prefab, transform);
                    timelinePoint.SetPoint(positionOnTimeline);
                    dict.Add(point, timelinePoint);
                }
            }
            else
            {
                if (prefab == null)
                {
                    Debug.LogError(Logger.NotAssigned(typeof(TimelinePoint), GetType(), name));
                }
                if (space == null)
                {
                    Debug.LogError(Logger.NotAssigned(typeof(RectTransform), GetType(), name));
                }
            }
        }
Example #2
0
        private void DeleteUnnecesaryPoints(List <Map.Point> mapPoints)
        {
            if (points == null)
            {
                points = new Dictionary <Map.Point, TimelinePoint>();
            }
            if (mapPoints != null)
            {
                List <Map.Point> pointsToRemove = new List <Map.Point>();
                foreach (Map.Point point in points.Keys)
                {
                    if (!mapPoints.Contains(point))
                    {
                        TimelinePoint pointToDelete = points[point];
                        pointsToRemove.Add(point);
                        pointToDelete.DeletePoint();
                    }
                }
                foreach (Map.Point point in pointsToRemove)
                {
                    points.Remove(point);
                }
                TimelinePoint[] childs = transform.GetComponentsInChildren <TimelinePoint>();

                if (childs.Length > points.Count)
                {
                    points.Clear();
                    foreach (TimelinePoint point in childs)
                    {
                        point.DeletePoint();
                    }
                }
            }
            else
            {
                Debug.LogWarning(Logger.ReceivedNull(typeof(List <Map.Point>)));
            }
        }