コード例 #1
0
        internal static void StartEventCoroutine(CustomEventData customEventData, EventType eventType)
        {
            NoodleCoroutineEventData noodleData = (NoodleCoroutineEventData)NoodleEventDatas[customEventData];

            if (noodleData == null)
            {
                return;
            }

            float duration = noodleData.Duration;

            duration = 60f * duration / Instance.BeatmapObjectSpawnController.currentBpm; // Convert to real time;

            Functions easing = noodleData.Easing;

            foreach (NoodleCoroutineEventData.CoroutineInfo coroutineInfo in noodleData.CoroutineInfos)
            {
                Property        property  = coroutineInfo.Property;
                PointDefinition pointData = coroutineInfo.PointDefinition;

                if (property.Coroutine != null)
                {
                    Instance.StopCoroutine(property.Coroutine);
                }

                if (pointData == null)
                {
                    switch (eventType)
                    {
                    case EventType.AnimateTrack:
                        property.Value = null;
                        break;

                    case EventType.AssignPathAnimation:
                        ((PointDefinitionInterpolation)property.Value).Init(null);
                        break;
                    }
                }
                else
                {
                    switch (eventType)
                    {
                    case EventType.AnimateTrack:
                        property.Coroutine = Instance.StartCoroutine(AnimateTrack.AnimateTrackCoroutine(pointData, property, duration, customEventData.time, easing));
                        break;

                    case EventType.AssignPathAnimation:
                        ((PointDefinitionInterpolation)property.Value).Init(pointData);
                        property.Coroutine = Instance.StartCoroutine(AssignPathAnimation.AssignPathAnimationCoroutine(property, duration, customEventData.time, easing));
                        break;
                    }
                }
            }
        }
コード例 #2
0
        internal static void StartEventCoroutine(CustomEventData customEventData, EventType eventType)
        {
            Track track = GetTrack(customEventData.data);

            if (track != null)
            {
                float duration = (float?)Trees.at(customEventData.data, DURATION) ?? 0f;
                duration = 60f * duration / Instance.BeatmapObjectSpawnController.currentBpm; // Convert to real time;

                string    easingString = (string)Trees.at(customEventData.data, EASING);
                Functions easing       = Functions.easeLinear;
                if (easingString != null)
                {
                    easing = (Functions)Enum.Parse(typeof(Functions), easingString);
                }

                List <string> excludedStrings = new List <string> {
                    TRACK, DURATION, EASING
                };
                IDictionary <string, object>   eventData  = new Dictionary <string, object>(customEventData.data as IDictionary <string, object>); // Shallow copy
                IDictionary <string, Property> properties = null;
                switch (eventType)
                {
                case EventType.AnimateTrack:
                    properties = track.Properties;
                    break;

                case EventType.AssignPathAnimation:
                    properties = track.PathProperties;
                    break;

                default:
                    return;
                }

                foreach (KeyValuePair <string, object> valuePair in eventData)
                {
                    if (!excludedStrings.Any(n => n == valuePair.Key))
                    {
                        if (!properties.TryGetValue(valuePair.Key, out Property property))
                        {
                            NoodleLogger.Log($"Could not find property {valuePair.Key}!", IPA.Logging.Logger.Level.Error);
                            continue;
                        }

                        TryGetPointData(customEventData.data, valuePair.Key, out PointDefinition pointData);

                        if (property.Coroutine != null)
                        {
                            Instance.StopCoroutine(property.Coroutine);
                        }

                        if (pointData == null)
                        {
                            switch (eventType)
                            {
                            case EventType.AnimateTrack:
                                property.Value = null;
                                break;

                            case EventType.AssignPathAnimation:
                                ((PointDefinitionInterpolation)property.Value).Init(null);
                                break;
                            }
                        }
                        else
                        {
                            switch (eventType)
                            {
                            case EventType.AnimateTrack:
                                property.Coroutine = Instance.StartCoroutine(AnimateTrack.AnimateTrackCoroutine(pointData, property, duration, customEventData.time, easing));
                                break;

                            case EventType.AssignPathAnimation:
                                ((PointDefinitionInterpolation)property.Value).Init(pointData);
                                property.Coroutine = Instance.StartCoroutine(AssignPathAnimation.AssignPathAnimationCoroutine(property, duration, customEventData.time, easing));
                                break;
                            }
                        }
                    }
                }
            }
        }