public UIMotion(Widget widget, string filePath) { base.Widget = widget; this.propertyValues = new float[Enum.GetValues(typeof(PropertyType)).Length]; if (filePath != null && !filePath.Equals("")) { UIMotionData uIMotionData = new UIMotionData(); uIMotionData.Read(filePath); this.SetMotionData(uIMotionData); } }
public void Read(FileStream fs) { this.header = (UIMotionData.Property.PropertyHeader)UIMotionData.ReadObject(fs, typeof(UIMotionData.Property.PropertyHeader)); int num = 0; while ((long)num < (long)((ulong)this.header.keyframeNum)) { UIMotionData.Property.Keyframe keyframe = (UIMotionData.Property.Keyframe)UIMotionData.ReadObject(fs, typeof(UIMotionData.Property.Keyframe)); this.keyframes.Add(keyframe); num++; } }
public void Read(FileStream fs) { this.header = (UIMotionData.TimeMap.TimeMapHeader)UIMotionData.ReadObject(fs, typeof(UIMotionData.TimeMap.TimeMapHeader)); if (this.header.easeType == EaseType.Custom) { int num = 0; while ((long)num < (long)((ulong)this.header.customPointNum)) { UIMotionData.TimeMap.CustomPoint customPoint = (UIMotionData.TimeMap.CustomPoint)UIMotionData.ReadObject(fs, typeof(UIMotionData.TimeMap.CustomPoint)); this.customPoints.Add(customPoint); num++; } } }
public void Read(FileStream fs) { this.header = (UIAnimationPlayer.UIAnimationData.Frame.FrameHeader)UIAnimationPlayer.UIAnimationData.ReadObject(fs, typeof(UIAnimationPlayer.UIAnimationData.Frame.FrameHeader)); if (this.header.nameByteSize > 0u) { byte[] array = new byte[this.header.nameByteSize]; if (fs.Read(array, 0, array.Length) == array.Length) { this.name = Encoding.Unicode.GetString(array); } } if (this.header.hasMotion) { this.motion = new UIMotionData(); this.motion.Read(fs); } if (this.header.hasInstance) { this.instance = new UIAnimationPlayer.UIAnimationData.Instance(); this.instance.Read(fs); } }
private void ReadHeader(FileStream fs) { this.header = (UIMotionData.Header)UIMotionData.ReadObject(fs, typeof(UIMotionData.Header)); }
private void SetMotionData(UIMotionData data) { float timeScale = data.header.timeScale; Func <float, float> func = (float timeValue) => timeValue / timeScale * 1000f; this.duration = func.Invoke(data.header.duration); using (List <UIMotionData.Property> .Enumerator enumerator = data.properties.GetEnumerator()) { while (enumerator.MoveNext()) { UIMotionData.Property current = enumerator.Current; AnimationInterpolator easingCurve; if (current.header.useTimeMap) { int strength = data.timeMaps[(int)current.header.timeMapIndex].header.strength; switch (data.timeMaps[(int)current.header.timeMapIndex].header.easeType) { case EaseType.Quadratic: easingCurve = AnimationUtility.GetQuadInterpolator(strength); break; case EaseType.Cubic: easingCurve = AnimationUtility.GetCubicInterpolator(strength); break; case EaseType.Quartic: easingCurve = AnimationUtility.GetQuarticInterpolator(strength); break; case EaseType.Quintic: easingCurve = AnimationUtility.GetQuinticInterpolator(strength); break; case EaseType.DualQuadratic: easingCurve = AnimationUtility.GetDualQuadInterpolator(strength); break; case EaseType.DualCubic: easingCurve = AnimationUtility.GetDualCubicInterpolator(strength); break; case EaseType.DualQuartic: easingCurve = AnimationUtility.GetDualQuarticInterpolator(strength); break; case EaseType.DualQuintic: easingCurve = AnimationUtility.GetDualQuinticInterpolator(strength); break; case EaseType.Bounce: easingCurve = AnimationUtility.GetBounceInterpolator(strength); break; case EaseType.BounceIn: easingCurve = AnimationUtility.GetBounceInInterpolator(strength); break; case EaseType.Spring: easingCurve = AnimationUtility.GetSpringInterpolator(strength); break; case EaseType.SineWave: easingCurve = AnimationUtility.GetSineWaveInterpolator(strength); break; case EaseType.SawtoothWave: easingCurve = AnimationUtility.GetSawtoothWaveInterpolator(strength); break; case EaseType.SquareWave: easingCurve = AnimationUtility.GetSquareWaveInterpolator(strength); break; case EaseType.RandomSquareWave: easingCurve = AnimationUtility.GetRandomSquareWaveInterpolator(strength); break; case EaseType.DampedWave: easingCurve = AnimationUtility.GetDampedWaveInterpolator(strength); break; default: easingCurve = new AnimationInterpolator(AnimationUtility.LinearInterpolator); break; } } else { easingCurve = new AnimationInterpolator(AnimationUtility.LinearInterpolator); } if (current.keyframes.Count > 0) { UIMotionData.Property.Keyframe keyframe = current.keyframes[0]; AnimationUtility.CubicBezierCurveSequence cubicBezierCurveSequence = new AnimationUtility.CubicBezierCurveSequence(func.Invoke(keyframe.time), keyframe.anchorY); cubicBezierCurveSequence.EasingCurve = easingCurve; for (int i = 0; i < current.keyframes.Count - 1; i++) { int num = i; int num2 = i + 1; UIMotionData.Property.Keyframe keyframe2 = current.keyframes[num]; UIMotionData.Property.Keyframe keyframe3 = current.keyframes[num2]; float num3 = keyframe2.time; float num4 = keyframe3.time; float control1X = func.Invoke(keyframe2.nextX + num3); float control1Y = keyframe2.nextY; float control2X = func.Invoke(keyframe3.previousX + num4); float control2Y = keyframe3.previousY; float nextAnchorX = func.Invoke(keyframe3.time); float nextAnchorY = keyframe3.anchorY; cubicBezierCurveSequence.AppendSegment(control1X, control1Y, control2X, control2Y, nextAnchorX, nextAnchorY); } this.timelines.Add(current.header.propertyType, cubicBezierCurveSequence); } } } }
internal UIMotion(Widget widget, UIMotionData data) : this((Widget)widget, (string)null) { this.SetMotionData(data); }