Example #1
0
        public static void CreateEngine()
        {
            // The pipeline processors for our application.
            // These are responsible for consuming frames
            // created by the engine class.
            events    = new EventPipeline();
            physics   = new PhysicsPipeline();
            animation = new AnimationPipeline();
            rendering = new RenderPipeline();

            events.Subscribe <QuitEvent>(OnQuit);

            var actions = new Action <FrameState>[]
            {
                events.ProcessFrame,
                physics.ProcessFrame,
                animation.ProcessFrame,
                rendering.ProcessFrame
            };

            inputStates = new InputStateContainer();
            events.Subscribe <InputDeviceEvent>(inputStates.HandleInput);

            var sequence = new SequentialPipeline(actions);

            // create our engine.
            engine           = new Engine();
            engine.action    = events.ProcessFrame;
            engine.generator = new FrameGenerator();
        }
Example #2
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);
        }
Example #3
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();
        }
Example #4
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));
        }
Example #5
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));
        }
Example #6
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();
        }
Example #7
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)));
 }