Пример #1
0
 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 ManagerShouldRegisterFinishedAnimationAsFinished()
        {
            KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 1, 1f);

            KeyframeAnimationManager.Instance.PerformTickForEntityAnimation(entityGuidAsGuid, animation, 1500);
            Assert.Contains(new Guid(createdEntityGuid), KeyframeAnimationManager.Instance.FinishedAnimations.Keys);
            Assert.True(KeyframeAnimationManager.Instance.FinishedAnimations[entityGuidAsGuid].Contains("testAnimation"));
        }
Пример #4
0
        public void ManagerShouldRegisterFinishedAnimationAsFinished()
        {
            KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 1, 1f);

            plugin.Manager.PerformTickForEntityAnimation(entityGuidAsGuid, animation, 1500);
            Assert.True(plugin.Manager.FinishedAnimations.ContainsKey(entityGuidAsGuid));
            Assert.True(plugin.Manager.FinishedAnimations[entityGuidAsGuid].Contains("testAnimation"));
        }
Пример #5
0
        /// <summary>
        /// SINFONI Service method handler that initiates a server side animation playback for an entity
        /// </summary>
        /// <param name="entityGuid">Guid of entity for which animation should be played</param>
        /// <param name="name">Name of animation that should be played</param>
        /// <param name="startFrame">Keyframe at which animation playback should start</param>
        /// <param name="endFrame">Keyframe at which animation playback should end</param>
        /// <param name="cycles">Number of cycles the animation should be played (-1 for infinite playback)</param>
        /// <param param name="speed">Speed in which animation should be played</param>
        internal void StartServersideAnimation(string entityGuid,
                                               string animationName,
                                               float startFrame, float endFrame,
                                               int cycles, float speed)
        {
            KeyframeAnimation newAnimation = new KeyframeAnimation(animationName, startFrame, endFrame, cycles, speed);

            KeyframeAnimationManager.Instance.StartAnimation(new Guid(entityGuid), newAnimation);
        }
        public void ManagerShouldRemoveFinishedAnimatedEntities()
        {
            KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 1, 1f);

            KeyframeAnimationManager.Instance.StartAnimation(entityGuidAsGuid, animation);
            KeyframeAnimationManager.Instance.PerformTickForEntityAnimation(entityGuidAsGuid, animation, 1500);
            KeyframeAnimationManager.Instance.FinalizeFinishedAnimations();
            Assert.IsEmpty(KeyframeAnimationManager.Instance.RunningAnimationsForEntities);
        }
        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 ManagerShouldStopAnimationsAfterHavingSkippedTotalNumberOfCycles()
        {
            KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 3, 1f);

            KeyframeAnimationManager.Instance.PerformTickForEntityAnimation(entityGuidAsGuid, animation, 4500);

            Assert.AreEqual(animation.CurrentFrame, animation.EndFrame);
            Assert.True(KeyframeAnimationManager.Instance.FinishedAnimations.ContainsKey(entityGuidAsGuid));
            Assert.True(KeyframeAnimationManager.Instance.FinishedAnimations[entityGuidAsGuid].Contains("testAnimation"));
        }
Пример #10
0
        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);
        }
        public void ManagerShouldRemoveFinishedAnimations()
        {
            KeyframeAnimation animation1 = new KeyframeAnimation("testAnimation1", 0f, 1f, 1, 1f);
            KeyframeAnimation animation2 = new KeyframeAnimation("testAnimation2", 0f, 1f, 1, 1f);

            KeyframeAnimationManager.Instance.StartAnimation(entityGuidAsGuid, animation1);
            KeyframeAnimationManager.Instance.StartAnimation(entityGuidAsGuid, animation2);
            KeyframeAnimationManager.Instance.PerformTickForEntityAnimation(entityGuidAsGuid, animation1, 1500);
            KeyframeAnimationManager.Instance.FinalizeFinishedAnimations();
            Assert.Contains("testAnimation2", KeyframeAnimationManager.Instance.RunningAnimationsForEntities[entityGuidAsGuid].Keys);
            Assert.False(KeyframeAnimationManager.Instance.RunningAnimationsForEntities[entityGuidAsGuid].Keys.Contains("testAnimation1"));
        }
        public void ManagerShouldReplaceValuesOnNewAnimationStart()
        {
            plugin.StartServersideAnimation(createdEntityGuid, "testAnimation", 0f, 1f, 1, 1f);
            plugin.StartServersideAnimation(createdEntityGuid, "testAnimation", 0.5f, 1.5f, 2, 2f);

            KeyframeAnimation testAnimation = KeyframeAnimationManager.Instance.RunningAnimationsForEntities[entityGuidAsGuid]["testAnimation"];

            Assert.AreEqual(1, KeyframeAnimationManager.Instance.RunningAnimationsForEntities[entityGuidAsGuid].Keys.Count);

            Assert.AreEqual(testAnimation.StartFrame, 0.5f);
            Assert.AreEqual(testAnimation.EndFrame, 1.5f);
            Assert.AreEqual(testAnimation.Cycles, 2);
            Assert.AreEqual(testAnimation.Speed, 2f);
        }
Пример #14
0
        public void ManagerShouldRegisterAnimationForServersideAnimation()
        {
            plugin.StartServersideAnimation(createdEntityGuid, "testAnimation", 0f, 1f, 1, 1f);
            Dictionary <string, KeyframeAnimation> animations = plugin.Manager
                                                                .RunningAnimationsForEntities[entityGuidAsGuid];

            Assert.Contains("testAnimation", animations.Keys);

            KeyframeAnimation registeredAnimation = animations["testAnimation"];

            Assert.AreEqual(registeredAnimation.StartFrame, 0f);
            Assert.AreEqual(registeredAnimation.EndFrame, 1f);
            Assert.AreEqual(registeredAnimation.Cycles, 1);
            Assert.AreEqual(registeredAnimation.Speed, 1f);
        }
        /// <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>
        /// Starts an animation for a given entity
        /// </summary>
        /// <param name="entityGuid">Guid of entity for which animation should be played</param>
        /// <param name="animation">Keyframe animation that should be played for the entity</param>
        public void StartAnimation(Guid entityGuid, KeyframeAnimation animation)
        {
            lock (RunningAnimationsForEntities)
            {
                if (!RunningAnimationsForEntities.ContainsKey(entityGuid))
                {
                    RunningAnimationsForEntities[entityGuid] = new Dictionary <string, KeyframeAnimation>();
                }

                if (!RunningAnimationsForEntities[entityGuid].ContainsKey(animation.Name))
                {
                    RunningAnimationsForEntities[entityGuid].Add(animation.Name, animation);
                }
                else
                {
                    RunningAnimationsForEntities[entityGuid][animation.Name] = animation;
                }
            }
        }
        /// <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;
        }
Пример #18
0
 public void ManagerShouldRemoveFinishedAnimatedEntities()
 {
     KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 1, 1f);
     KeyframeAnimationManager.Instance.StartAnimation(entityGuidAsGuid, animation);
     KeyframeAnimationManager.Instance.PerformTickForEntityAnimation(entityGuidAsGuid, animation, 1500);
     KeyframeAnimationManager.Instance.FinalizeFinishedAnimations();
     Assert.IsEmpty(KeyframeAnimationManager.Instance.RunningAnimationsForEntities);
 }
Пример #19
0
        public void ManagerShouldRemoveFinishedAnimations()
        {
            KeyframeAnimation animation1 = new KeyframeAnimation("testAnimation1", 0f, 1f, 1, 1f);
            KeyframeAnimation animation2 = new KeyframeAnimation("testAnimation2", 0f, 1f, 1, 1f);

            KeyframeAnimationManager.Instance.StartAnimation(entityGuidAsGuid, animation1);
            KeyframeAnimationManager.Instance.StartAnimation(entityGuidAsGuid, animation2);
            KeyframeAnimationManager.Instance.PerformTickForEntityAnimation(entityGuidAsGuid, animation1, 1500);
            KeyframeAnimationManager.Instance.FinalizeFinishedAnimations();
            Assert.Contains("testAnimation2", KeyframeAnimationManager.Instance.RunningAnimationsForEntities[entityGuidAsGuid].Keys);
            Assert.False(KeyframeAnimationManager.Instance.RunningAnimationsForEntities[entityGuidAsGuid].Keys.Contains("testAnimation1"));
        }
 /// <summary>
 /// SINFONI Service method handler that initiates a server side animation playback for an entity
 /// </summary>
 /// <param name="entityGuid">Guid of entity for which animation should be played</param>
 /// <param name="name">Name of animation that should be played</param>
 /// <param name="startFrame">Keyframe at which animation playback should start</param>
 /// <param name="endFrame">Keyframe at which animation playback should end</param>
 /// <param name="cycles">Number of cycles the animation should be played (-1 for infinite playback)</param>
 /// <param param name="speed">Speed in which animation should be played</param>
 internal void StartServersideAnimation(string entityGuid,
                                        string animationName,
                                        float startFrame, float endFrame,
                                        int cycles, float speed)
 {
     KeyframeAnimation newAnimation = new KeyframeAnimation(animationName, startFrame, endFrame, cycles, speed);
     KeyframeAnimationManager.Instance.StartAnimation(new Guid(entityGuid), newAnimation);
 }
Пример #21
0
        public void ManagerShouldRegisterFinishedAnimationAsFinished()
        {
            KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 1, 1f);

            KeyframeAnimationManager.Instance.PerformTickForEntityAnimation(entityGuidAsGuid, animation, 1500);
            Assert.Contains(new Guid(createdEntityGuid), KeyframeAnimationManager.Instance.FinishedAnimations.Keys);
            Assert.True(KeyframeAnimationManager.Instance.FinishedAnimations[entityGuidAsGuid].Contains("testAnimation"));
        }
        /// <summary>
        /// Starts an animation for a given entity
        /// </summary>
        /// <param name="entityGuid">Guid of entity for which animation should be played</param>
        /// <param name="animation">Keyframe animation that should be played for the entity</param>
        public void StartAnimation(Guid entityGuid, KeyframeAnimation animation)
        {
            lock (RunningAnimationsForEntities)
            {
                if (!RunningAnimationsForEntities.ContainsKey(entityGuid))
                    RunningAnimationsForEntities[entityGuid] = new Dictionary<string, KeyframeAnimation>();

                if (!RunningAnimationsForEntities[entityGuid].ContainsKey(animation.Name))
                    RunningAnimationsForEntities[entityGuid].Add(animation.Name, animation);
                else
                    RunningAnimationsForEntities[entityGuid][animation.Name] = animation;
            }
        }
Пример #23
0
        public void ManagerShouldStopAnimationsAfterHavingSkippedTotalNumberOfCycles()
        {
            KeyframeAnimation animation = new KeyframeAnimation("testAnimation", 0f, 1f, 3, 1f);
            KeyframeAnimationManager.Instance.PerformTickForEntityAnimation(entityGuidAsGuid, animation, 4500);

            Assert.AreEqual(animation.CurrentFrame, animation.EndFrame);
            Assert.True(KeyframeAnimationManager.Instance.FinishedAnimations.ContainsKey(entityGuidAsGuid));
            Assert.True(KeyframeAnimationManager.Instance.FinishedAnimations[entityGuidAsGuid].Contains("testAnimation"));
        }
Пример #24
0
        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);
        }
Пример #25
0
 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);
 }