Example #1
0
        /// <summary>
        /// Changes the direction of the current animation in the pipeline (the last one) to backward.
        /// </summary>
        /// <returns>The pipeline.</returns>
        /// <param name="pipeline">Pipeline.</param>
        /// <typeparam name="TOwner">The 1st type parameter.</typeparam>
        public static IAnimationPipeline <TOwner> OnlyBackward <TOwner>(this IAnimationPipeline <TOwner> pipeline)
            where TOwner : IComponent
        {
            pipeline.GetLast().Direction = AnimationDirection.Backward;

            return(pipeline);
        }
Example #2
0
 /// <summary>
 /// Disables the component after duration seconds.
 /// </summary>
 /// <returns>The animation pipeline.</returns>
 /// <param name="pipeline">The animation pipeline.</param>
 /// <param name="duration">Duration.</param>
 public static IAnimationPipeline <TOwner> Disable <TOwner>(this IAnimationPipeline <TOwner> pipeline, float duration)
     where TOwner : IComponent
 {
     return(pipeline.Delay(duration, () =>
     {
         pipeline.Owner.Enabled = false;
     }));
 }
Example #3
0
 /// <summary>
 /// Animates the boolean values using the start value.
 /// </summary>
 /// <returns>The animation pipeline.</returns>
 /// <param name="pipeline">The animation pipeline.</param>
 /// <param name="start">If set to <c>true</c> start.</param>
 /// <param name="duration">Duration.</param>
 /// <param name="easing">Easing.</param>
 /// <param name="callback">Callback.</param>
 public static IAnimationPipeline <TOwner> Toogle <TOwner>(this IAnimationPipeline <TOwner> pipeline, bool start, float duration, IEasing easing, Action <bool> callback)
     where TOwner : IComponent
 {
     return(pipeline.To(0f, 1f, duration, easing, v =>
     {
         callback(start == v < 0.5f);
     }));
 }
Example #4
0
 /// <summary>
 /// Disables the component after duration seconds.
 /// </summary>
 /// <returns>The animation pipeline.</returns>
 /// <param name="pipeline">The animation pipeline.</param>
 public static IAnimationPipeline <TOwner> Disable <TOwner>(this IAnimationPipeline <TOwner> pipeline)
     where TOwner : IComponent
 {
     return(pipeline.Do(() =>
     {
         pipeline.Owner.Enabled = false;
     }));
 }
Example #5
0
 /// <summary>
 /// Enables the component.
 /// </summary>
 /// <returns>The animation pipeline.</returns>
 /// <param name="pipeline">The animation pipeline.</param>
 public static IAnimationPipeline <TComponent> Enable <TComponent>(this IAnimationPipeline <TComponent> pipeline)
     where TComponent : IComponent
 {
     return(pipeline.Do(() =>
     {
         pipeline.Owner.Enabled = true;
     }));
 }
Example #6
0
        /// <summary>
        /// Adds a delay animation to the pipeline.
        /// </summary>
        /// <typeparam name="TOwner">The type of the owner.</typeparam>
        /// <param name="pipeline">The animation pipeline.</param>
        /// <param name="seconds">The duration seconds.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>The animation pipeline.</returns>
        public static IAnimationPipeline <TOwner> Delay <TOwner>(this IAnimationPipeline <TOwner> pipeline, float seconds, Action callback = null)
            where TOwner : IComponent
        {
            var delayAnimation = new DelayAnimation <TOwner>(pipeline.Owner, seconds, callback);

            pipeline.Add(delayAnimation);

            return(pipeline);
        }
Example #7
0
        /// <summary>
        /// Adds a callback to the pipeline.
        /// </summary>
        /// <typeparam name="TOwner">The type of the owner.</typeparam>
        /// <param name="pipeline">The animation pipeline.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>The animation pipeline controller.</returns>
        public static IAnimationPipeline <TOwner> Do <TOwner>(this IAnimationPipeline <TOwner> pipeline, Action callback)
            where TOwner : IComponent
        {
            var animation = new DelayAnimation <TOwner>(pipeline.Owner, 0, callback);

            pipeline.Add(animation);

            return(pipeline);
        }
Example #8
0
        /// <summary>
        /// Animates the floot value between the values defined in to and from arguments.
        /// </summary>
        /// <returns>The animation pipeline.</returns>
        /// <param name="pipeline">The animation pipeline.</param>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="easing">Easing.</param>
        /// <param name="callback">Callback.</param>
        public static IAnimationPipeline <TOwner> To <TOwner>(this IAnimationPipeline <TOwner> pipeline, float from, float to, float duration, IEasing easing, Action <float> callback)
            where TOwner : IComponent
        {
            var animation = new FloatAnimation <TOwner>(pipeline.Owner, from, to, duration, callback);

            animation.Easing = easing;
            pipeline.Add(animation);

            return(pipeline);
        }
Example #9
0
        /// <summary>
        /// Adds a rectangle iteration animation.
        /// </summary>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="rectangle">The rectangle.</param>
        /// <param name="filled">If rectangle should be filled.</param>
        /// <param name="duration">The duration seconds.</param>
        /// <param name="easing">The easing.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>The animation pipeline.</returns>
        public static IAnimationPipeline <TOwner> Iterate <TOwner>(this IAnimationPipeline <TOwner> pipeline, Rectangle rectangle, bool filled, float duration, IEasing easing, Action <float, float> callback)
            where TOwner : IComponent
        {
            var animation = new RectangleIterateAnimation <TOwner>(pipeline.Owner, rectangle, filled, duration, callback)
            {
                Easing = easing
            };

            pipeline.Add(animation);

            return(pipeline);
        }
Example #10
0
        /// <summary>
        /// Adds a rectangle iteration animation.
        /// </summary>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="duration">The duration seconds.</param>
        /// <param name="easing">The easing.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>The animation pipeline.</returns>
        public static IAnimationPipeline <RectangleComponent> Iterate(this IAnimationPipeline <RectangleComponent> pipeline, float duration, IEasing easing, Action <float, float> callback)
        {
            var owner     = pipeline.Owner;
            var animation = new RectangleIterateAnimation <RectangleComponent>(owner, owner.Transform.BoundingBox, owner.Filled, duration, callback)
            {
                Easing = easing
            };

            pipeline.Add(animation);

            return(pipeline);
        }
Example #11
0
        /// <summary>
        /// Scale the transfom between current scale to x and y scale using the duration and easing specified.
        /// </summary>
        /// <returns>The animation pipeline.</returns>
        /// <param name="pipeline">The transform.</param>
        /// <param name="to">The target scale.</param>
        /// <param name="duration">the duration.</param>
        /// <param name="easing">The easing.</param>
        public static IAnimationPipeline <Transform> ScaleTo(this IAnimationPipeline <Transform> pipeline, Point to, float duration, IEasing easing = null)
        {
            var owner     = pipeline.Owner;
            var animation = new PointAnimation <Transform>(owner, t => t.Scale, to, duration, (v) =>
            {
                owner.Scale = v;
            });

            animation.Easing = easing;
            pipeline.Add(animation);

            return(pipeline);
        }
Example #12
0
        /// <summary>
        /// Rotate the transfom between current rotation to specified rotation using the duration and easing specified.
        /// </summary>
        /// <returns>The animation pipeline.</returns>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="rotation">The target rotation.</param>
        /// <param name="duration">the duration.</param>
        /// <param name="easing">The easing.</param>
        public static IAnimationPipeline <Transform> RotateTo(this IAnimationPipeline <Transform> pipeline, float rotation, float duration, IEasing easing = null)
        {
            var owner = pipeline.Owner;

            var animation = new FloatAnimation <Transform>(owner, owner.Rotation, rotation, duration, (v) =>
            {
                owner.Rotation = v;
            });

            animation.Easing = easing;

            pipeline.Add(animation);

            return(pipeline);
        }
Example #13
0
 internal static IAnimation <TOwner> GetLast <TOwner>(this IAnimationPipeline <TOwner> pipeline)
     where TOwner : IComponent
 {
     return(pipeline.Get(pipeline.Length - 1));
 }
Example #14
0
 /// <summary>
 /// Scale the transfom between current scale to specified scale using the duration and easing specified.
 /// </summary>
 /// <returns>The animation pipeline.</returns>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="scale">The target scale.</param>
 /// <param name="duration">the duration.</param>
 /// <param name="easing">The easing.</param>
 public static IAnimationPipeline <Transform> ScaleTo(this IAnimationPipeline <Transform> pipeline, float scale, float duration, IEasing easing = null)
 {
     return(pipeline.ScaleTo(new Point(scale), duration, easing));
 }
Example #15
0
 /// <summary>
 /// Move the transfom between the current position to x and y using the duration and easing specified.
 /// </summary>
 /// <returns>The animation pipeline.</returns>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 /// <param name="duration">Duration.</param>
 /// <param name="easing">Easing.</param>
 public static IAnimationPipeline <Transform> MoveTo(this IAnimationPipeline <Transform> pipeline, float x, float y, float duration, IEasing easing = null)
 {
     return(pipeline.MoveTo(new Point(x, y), duration, easing));
 }
Example #16
0
        /// <summary>
        /// Move the transfom between the current position to point using the duration and easing specified.
        /// </summary>
        /// <returns>The animation pipeline.</returns>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="point">The point.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="easing">Easing.</param>
        public static IAnimationPipeline <Transform> MoveTo(this IAnimationPipeline <Transform> pipeline, Point point, float duration, IEasing easing = null)
        {
            pipeline.Add(CreateMoveToAnimation(pipeline.Owner, point.X, point.Y, duration, easing));

            return(pipeline);
        }