Ejemplo n.º 1
0
        public void InitializeTest()
        {
            var ctx = Substitute.For <IWorldContext>();

            ctx.LogSystem.Returns(Substitute.For <ILogSystem>());

            firstAnimationDirection  = AnimationDirection.Any;
            secondAnimationDirection = AnimationDirection.Any;

            firstAnimation = Substitute.For <IAnimation <Transform>, IComponent>();
            var t = new Transform(ctx);

            firstAnimation.Owner.Returns(t);
            firstAnimation.State.Returns(AnimationState.NotPlayed);
            firstAnimation.Direction.Returns(c => firstAnimationDirection);
            target = AnimationPipeline <Transform> .Create(firstAnimation);

            Assert.AreEqual(1, target.Length);

            secondAnimation = Substitute.For <IAnimation <Transform> >();
            secondAnimation.Direction.Returns(c => secondAnimationDirection);
            target.Add(secondAnimation);
            Assert.AreEqual(2, target.Length);

            Assert.AreEqual(AnimationState.NotPlayed, target.State);
        }
Ejemplo n.º 2
0
        public void Resume_Pipeline_Resumed()
        {
            var animation = Substitute.For <IAnimation <Transform> >();
            var pipeline  = AnimationPipeline <Transform> .Create(animation);

            var target = new AnimationPipelineController <Transform>(pipeline);

            target.Resume();

            animation.Received().Resume();
        }
Ejemplo n.º 3
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="owner">The owner.</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 Transform owner, float rotation, float duration, IEasing easing = null)
        {
            var animation = new FloatAnimation <Transform>(owner, owner.Rotation, rotation, duration, (v) =>
            {
                owner.Rotation = v;
            });

            animation.Easing = easing;

            return(AnimationPipeline <Transform> .Create(animation));
        }
Ejemplo n.º 4
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="transform">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 Transform transform, Point to, float duration, IEasing easing = null)
        {
            var animation = new PointAnimation <Transform>(transform, t => t.Scale, to, duration, (v) =>
            {
                transform.Scale = v;
            });

            animation.Easing = easing;

            return(AnimationPipeline <Transform> .Create(animation));
        }
Ejemplo n.º 5
0
        public void Destroy_Pipeline_Destroyed()
        {
            var ctx = Substitute.For <IWorldContext>();

            ctx.LogSystem.Returns(Substitute.For <ILogSystem>());
            var animation = new FloatAnimation <Transform>(new Transform(ctx), 0, 1, 1, v => { });

            var pipeline = AnimationPipeline <Transform> .Create(animation);

            var target = new AnimationPipelineController <Transform>(pipeline);

            target.Destroy();

            Assert.AreEqual(AnimationState.Stopped, pipeline.State);

            target.Pause();
            target.Resume();
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Move the transfom between the current position to x and y using the duration and easing specified.
 /// </summary>
 /// <returns>The to.</returns>
 /// <param name="transform">Transform.</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 Transform transform, float x, float y, float duration, IEasing easing = null)
 {
     return(AnimationPipeline <Transform> .Create(CreateMoveToAnimation(transform, x, y, duration, easing)));
 }