Example #1
0
        /// <summary>
        /// Used to add an D2SkeletalAnimation to this
        /// D2SkeletalAnimationPlayer's rooster.
        /// </summary>
        /// <param name="animation">The D2SkeletalAnimation to be added.</param>
        public void AddAnimation(D2SkeletalAnimation animation)
        {
            D2SkeletalAnimation ani = null;

            ani = (from a in animations
                   where a.Name == animation.Name
                   select a).FirstOrDefault();

            if (ani == null)
            {
                animations.Add(animation);
            }
        }
        /// <summary>
        /// Used to add an D2SkeletalAnimation to this
        /// D2SkeletalAnimationPlayer's rooster.
        /// </summary>
        /// <param name="animation">The D2SkeletalAnimation to be added.</param>
        public void AddAnimation(D2SkeletalAnimation animation)
        {
            D2SkeletalAnimation ani = null;

            ani = (from a in animations
                   where a.Name == animation.Name
                   select a).FirstOrDefault();

            if (ani == null)
            {
                if (Common.PreviousScreenResolution != Vector2.One)
                {
                    ani.ScreenResolutionChanged();
                }

                animations.Add(animation);
            }
        }
        /// <summary>
        /// Used to apply a D2SkeletalAnimation to
        /// the given skeleton.
        /// </summary>
        /// <param name="animationName">The name of the
        /// D2SkeletalAnimation to be played.</param>
        public void PlayAnimation(string animationName)
        {
            for (int i = 0; i < animations.Count; i++)
            {
                if (animations[i].Name == animationName)
                {
                    if (currentAnimation != null)
                    {
                        prevAnimation = currentAnimation;
                    }

                    currentAnimation = animations[i];
                    currentAnimation.Initialize();

                    currentAnimation.OnFinished += new HasFinishedEvent(AnimiationFinished);

                    if (prevAnimation != null)
                    {
                        if (blender == null)
                        {
                            blender = new Blender(prevAnimation.BlendingTime,
                                                  prevAnimation._LimbAnimations, currentAnimation._LimbAnimations);

                            blender.OnFinished += new HasFinishedEvent(FinishedBlending);

                            blending = true;
                        }
                        else
                        {
                            blender.Reset(prevAnimation.BlendingTime,
                                          prevAnimation._LimbAnimations, currentAnimation._LimbAnimations);

                            blending = true;
                        }
                    }
                    else
                    {
                        currentAnimation.Play();
                    }
                }
            }
        }