Ejemplo n.º 1
0
        public IAnimationState ToItem(AGSSerializationContext context)
        {
            AGSAnimationState state = new AGSAnimationState();

            state.RunningBackwards = RunningBackwards;
            state.CurrentFrame     = CurrentFrame;
            state.CurrentLoop      = CurrentLoop;
            state.TimeToNextFrame  = TimeToNextFrame;
            state.IsPaused         = IsPaused;

            return(state);
        }
Ejemplo n.º 2
0
        private AGSAnimation getAnimation(string samplePath, IAnimationConfiguration animationConfig, int resourcesCount)
        {
            if (resourcesCount == 0 && samplePath != null)
            {
                throw new InvalidOperationException($"Failed to load animation from: {samplePath}");
            }
            animationConfig = animationConfig ?? new AGSAnimationConfiguration();
            AGSAnimationState state     = new AGSAnimationState();
            AGSAnimation      animation = new AGSAnimation(animationConfig, state, resourcesCount);

            return(animation);
        }
Ejemplo n.º 3
0
		public void SetupAnimationTest(LoopingStyle looping, int expectedFrame, bool expectedBackwards)
		{
            AGSAnimationConfiguration config = new AGSAnimationConfiguration { Looping = looping, DelayBetweenFrames = 0 };
			AGSAnimationState state = new AGSAnimationState ();
			AGSAnimation animation = new AGSAnimation (config, state);
			for (int i = 0; i < 5; i++)
			{
				animation.Frames.Add(getFrame(i * 2));
			}

			animation.Setup();

			Assert.AreEqual(expectedFrame, state.CurrentFrame);
			Assert.AreEqual(0, state.CurrentLoop);
			Assert.AreEqual(expectedBackwards, state.RunningBackwards);
			Assert.AreEqual(expectedFrame * 2, state.TimeToNextFrame);
		}
Ejemplo n.º 4
0
		public void NextFrameTest(LoopingStyle looping, int loops, int currentFrame, int currentLoop, bool runningBackwards, int expectedFrame, int expectedLoop, bool expectedBackwards)
		{
            AGSAnimationConfiguration config = new AGSAnimationConfiguration { Looping = looping, Loops = loops, DelayBetweenFrames = 0 };
			AGSAnimationState state = new AGSAnimationState {
				CurrentFrame = currentFrame,
				CurrentLoop = currentLoop,
				RunningBackwards = runningBackwards,
				TimeToNextFrame = currentFrame * 2
			};
			AGSAnimation animation = new AGSAnimation (config, state);
			for (int i = 0; i < 5; i++)
			{
				animation.Frames.Add(getFrame(i * 2));
			}

			animation.NextFrame();

			Assert.AreEqual(expectedFrame, state.CurrentFrame);
			Assert.AreEqual(expectedLoop, state.CurrentLoop);
			Assert.AreEqual(expectedBackwards, state.RunningBackwards);
			Assert.AreEqual(expectedFrame * 2, state.TimeToNextFrame);
		}
Ejemplo n.º 5
0
		private AGSAnimation getAnimation (IAnimationConfiguration animationConfig, int resourcesCount)
		{
			animationConfig = animationConfig ?? new AGSAnimationConfiguration ();
			AGSAnimationState state = new AGSAnimationState ();
			AGSAnimation animation = new AGSAnimation (animationConfig, state, resourcesCount);
			return animation;
		}