示例#1
0
        /// <summary>
        /// Blends progressively a new animation.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="desiredWeight">The desired weight.</param>
        /// <param name="fadeTimeSpan">The fade time span.</param>
        /// <exception cref="ArgumentException">name</exception>
        public void Blend(string name, float desiredWeight, TimeSpan fadeTimeSpan)
        {
            if (!Animations.ContainsKey(name))
                throw new ArgumentException("name");

            var playingAnimation = new PlayingAnimation(this, name) { CurrentTime = TimeSpan.Zero, Weight = 0.0f };
            PlayingAnimations.Add(playingAnimation);

            if (fadeTimeSpan > TimeSpan.Zero)
            {
                playingAnimation.WeightTarget = desiredWeight;
                playingAnimation.RemainingTime = fadeTimeSpan;
            }
            else
            {
                playingAnimation.Weight = desiredWeight;
            }
        }
 /// <summary>
 /// Helper function for playing animation given AgentAnimationKey.
 /// </summary>
 /// <param name="key"></param>
 private void PlayAnimation(AgentAnimationKeys key)
 {
     var animationComponent = Entity.Get<AnimationComponent>();
    
     animationComponent.Play(key.ToString());
     playingAnimation = animationComponent.PlayingAnimations[0];
 }
示例#3
0
 /// <summary>
 /// Plays right away the animation with the specified name, instantly removing all other blended animations.
 /// </summary>
 /// <param name="name">The animation name.</param>
 public PlayingAnimation Play(string name)
 {
     PlayingAnimations.Clear();
     var playingAnimation = new PlayingAnimation(this, name) { CurrentTime = TimeSpan.Zero, Weight = 1.0f };
     PlayingAnimations.Add(playingAnimation);
     return playingAnimation;
 }