Beispiel #1
0
        public bool Update(float deltaTime)
        {
            time += deltaTime;
            if (keyframes.Count <= 1)
            {
                return(true);
            }
            if (time >= keyframes.ElementAt(keyframes.Count - 2).time)
            {
                keyframes.RemoveAt(keyframes.Count - 1);
            }
            if (keyframes.Count <= 1)
            {
                return(true);
            }
            float value = AnimationKeyframe.Lerp(keyframes[keyframes.Count - 1], keyframes[keyframes.Count - 2], time);

            switch (type)
            {
            case Type.RawImageOpacity:
                ((RawImage)reference).opacity = value;
                break;

            case Type.RawImageRotation:
                ((RawImage)reference).rotation = value;
                break;

            case Type.RawImageX:
                ((RawImage)reference).location.X = (int)value;
                break;

            case Type.RawImageY:
                ((RawImage)reference).location.Y = (int)value;
                break;

            case Type.TextBoxX:
                ((TextBox)reference).location.X = (int)value;
                break;

            case Type.TextBoxY:
                ((TextBox)reference).location.Y = (int)value;
                break;

            case Type.InputBoxX:
                ((InputBox)reference).location.X = (int)value;
                break;

            case Type.InputBoxY:
                ((InputBox)reference).location.Y = (int)value;
                break;
            }
            return(false);
        }
Beispiel #2
0
 public static float Lerp(AnimationKeyframe a, AnimationKeyframe b, float t)
 {
     return(a.value + (b.value - a.value) * (t - a.time) / (b.time - a.time));
 }