public void AnimationShouldIncreaseByNumberOfSkippedCycles() { float newFrame; KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 5, 1f); animation.Tick(4500, out newFrame); Assert.AreEqual(animation.CurrentCycle, 5); }
public void AnimationShouldIncreaseByNumberOfSkippedCycles() { float newFrame; KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 5, 1f); animation.Tick(4500, out newFrame); Assert.AreEqual(animation.CurrentCycle, 5); }
public void AnimationShouldStayInFrameRangeForMultipleSkippedCycles() { float newFrame; KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 5, 1f); animation.Tick(4500, out newFrame); Assert.AreEqual(animation.CurrentFrame, 0.5f); Assert.AreEqual(newFrame, animation.CurrentFrame); }
public void AnimationShouldPerformCorrectAnimationTick() { float newFrame; KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 1, 1f); animation.Tick(500, out newFrame); Assert.AreEqual(animation.CurrentFrame, 0.5f); Assert.AreEqual(newFrame, animation.CurrentFrame); }
public void AnimationShouldIncreaseCycle() { float newFrame; KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 2, 1f); animation.Tick(1500, out newFrame); Assert.AreEqual(animation.CurrentFrame, 0.5f); Assert.AreEqual(newFrame, animation.CurrentFrame); Assert.AreEqual(animation.CurrentCycle, 2); }
public void AnimationShouldIncreaseCycle() { float newFrame; KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 2, 1f); animation.Tick(1500, out newFrame); Assert.AreEqual(animation.CurrentFrame, 0.5f); Assert.AreEqual(newFrame, animation.CurrentFrame); Assert.AreEqual(animation.CurrentCycle, 2); }
/// <summary> /// Computes the next frame for an animation of an entity. Stops the animation or increases cycle if /// frame range of animation is exceeded /// </summary> /// <param name="entityGuid">Guid of the entity for which the animation is computed</param> /// <param name="animation">Animation that is currently playing</param> /// <param name="frameDuration">Duration of the last frame in milliseconds</param> /// <returns>New Keyframe of the animation</returns> internal float PerformTickForEntityAnimation(Guid entityGuid, KeyframeAnimation animation, double frameDuration) { float newKey = 0f; // Perform next keyframe computation and stop animation if number of cycles reached the end if (!animation.Tick(frameDuration, out newKey)) { if (!FinishedAnimations.ContainsKey(entityGuid)) { FinishedAnimations.Add(entityGuid, new HashSet <string>()); } FinishedAnimations[entityGuid].Add(animation.Name); } return(newKey); }
/// <summary> /// Computes the next frame for an animation of an entity. Stops the animation or increases cycle if /// frame range of animation is exceeded /// </summary> /// <param name="entityGuid">Guid of the entity for which the animation is computed</param> /// <param name="animation">Animation that is currently playing</param> /// <param name="frameDuration">Duration of the last frame in milliseconds</param> /// <returns>New Keyframe of the animation</returns> internal float PerformTickForEntityAnimation(Guid entityGuid, KeyframeAnimation animation, double frameDuration) { float newKey = 0f; // Perform next keyframe computation and stop animation if number of cycles reached the end if (!animation.Tick(frameDuration, out newKey)) { if (!FinishedAnimations.ContainsKey(entityGuid)) FinishedAnimations.Add(entityGuid, new HashSet<string>()); FinishedAnimations[entityGuid].Add(animation.Name); } return newKey; }
public void AnimationShouldPerformCorrectAnimationTick() { float newFrame; KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 1, 1f); animation.Tick(500, out newFrame); Assert.AreEqual(animation.CurrentFrame, 0.5f); Assert.AreEqual(newFrame, animation.CurrentFrame); }
public void AnimationShouldStayInFrameRangeForMultipleSkippedCycles() { float newFrame; KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 5, 1f); animation.Tick(4500, out newFrame); Assert.AreEqual(animation.CurrentFrame, 0.5f); Assert.AreEqual(newFrame, animation.CurrentFrame); }