Beispiel #1
0
        public static dynamic TryGetPathProperty(Track track, string propertyName, float time)
        {
            Property pathProperty = null;

            track?.PathProperties.TryGetValue(propertyName, out pathProperty);
            if (pathProperty == null)
            {
                return(null);
            }

            PointDefinitionInterpolation pointDataInterpolation = (PointDefinitionInterpolation)pathProperty.Value;

            switch (pathProperty.PropertyType)
            {
            case PropertyType.Linear:
                return(pointDataInterpolation.InterpolateLinear(time));

            case PropertyType.Quaternion:
                return(pointDataInterpolation.InterpolateQuaternion(time));

            case PropertyType.Vector3:
                return(pointDataInterpolation.Interpolate(time));

            case PropertyType.Vector4:
                return(pointDataInterpolation.InterpolateVector4(time));

            default:
                return(null);
            }
        }
        public static Quaternion?TryGetQuaternionPathProperty(Track track, string propertyName, float time)
        {
            PointDefinitionInterpolation pointDataInterpolation = GetPathInterpolation(track, propertyName, PropertyType.Quaternion);

            if (pointDataInterpolation != null)
            {
                return(pointDataInterpolation.InterpolateQuaternion(time));
            }

            return(null);
        }
        /*public static dynamic TryGetPathProperty(Track track, string propertyName, float time)
         * {
         *  Property pathProperty = null;
         *  track?.PathProperties.TryGetValue(propertyName, out pathProperty);
         *  if (pathProperty == null)
         *  {
         *      return null;
         *  }
         *
         *  PointDefinitionInterpolation pointDataInterpolation = (PointDefinitionInterpolation)pathProperty.Value;
         *
         *  switch (pathProperty.PropertyType)
         *  {
         *      case PropertyType.Linear:
         *          return pointDataInterpolation.InterpolateLinear(time);
         *
         *      case PropertyType.Quaternion:
         *          return pointDataInterpolation.InterpolateQuaternion(time);
         *
         *      case PropertyType.Vector3:
         *          return pointDataInterpolation.Interpolate(time);
         *
         *      case PropertyType.Vector4:
         *          return pointDataInterpolation.InterpolateVector4(time);
         *
         *      default:
         *          return null;
         *  }
         * }*/

        public static float?TryGetLinearPathProperty(Track track, string propertyName, float time)
        {
            PointDefinitionInterpolation pointDataInterpolation = GetPathInterpolation(track, propertyName, PropertyType.Linear);

            if (pointDataInterpolation != null)
            {
                return(pointDataInterpolation.InterpolateLinear(time));
            }

            return(null);
        }
        public static Vector4?TryGetVector4PathProperty(Track track, string propertyName, float time)
        {
            PointDefinitionInterpolation pointDataInterpolation = GetPathInterpolation(track, propertyName, PropertyType.Vector4);

            if (pointDataInterpolation != null)
            {
                return(pointDataInterpolation.InterpolateVector4(time));
            }

            return(null);
        }
        // End of NE specific
        private static PointDefinitionInterpolation GetPathInterpolation(Track track, string propertyName, PropertyType propertyType)
        {
            Property pathProperty = null;

            track?.PathProperties.TryGetValue(propertyName, out pathProperty);
            if (pathProperty != null)
            {
                PointDefinitionInterpolation pointDataInterpolation = (PointDefinitionInterpolation)pathProperty.Value;

                return(pointDataInterpolation);
            }

            return(null);
        }
        internal static IEnumerator AssignPathAnimationCoroutine(Property property, float duration, float startTime, Functions easing)
        {
            PointDefinitionInterpolation pointDataInterpolation = property.Value as PointDefinitionInterpolation;

            while (true)
            {
                float elapsedTime = Instance.CustomEventCallbackController._audioTimeSource.songTime - startTime;
                pointDataInterpolation.Time = Easings.Interpolate(Mathf.Min(elapsedTime / duration, 1f), easing);

                if (elapsedTime < duration)
                {
                    yield return(null);
                }
                else
                {
                    break;
                }
            }

            pointDataInterpolation.Finish();
        }