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); }
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); }
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); }
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); }
private AGSAnimation getAnimation (IAnimationConfiguration animationConfig, int resourcesCount) { animationConfig = animationConfig ?? new AGSAnimationConfiguration (); AGSAnimationState state = new AGSAnimationState (); AGSAnimation animation = new AGSAnimation (animationConfig, state, resourcesCount); return animation; }