コード例 #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);
 }
コード例 #2
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);
        }
コード例 #3
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"));
        }
コード例 #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);
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
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);
        }
コード例 #9
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"));
        }
コード例 #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);
        }
コード例 #11
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);
        }
コード例 #12
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"));
        }
コード例 #13
0
        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);
        }
コード例 #15
0
        /// <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);
        }
コード例 #16
0
        /// <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;
                }
            }
        }
コード例 #17
0
        /// <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"));
        }
コード例 #20
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);
 }
コード例 #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"));
        }
コード例 #22
0
        /// <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);
 }