/// <summary>
        /// Plays the specified animation.
        /// </summary>
        /// <param name="mode">The animation mode.</param>
        /// <param name="animation">The animation to play.</param>
        /// <param name="speedMultiplier">The relative speed at which to play the animation.</param>
        /// <param name="easeInFunction">The easing function to apply when easing in the animation.</param>
        /// <param name="easeInDuration">The number of seconds over which to ease in the animation.</param>
        /// <param name="easeOutFunction">The easing function to apply when easing out the animation.</param>
        /// <param name="easeOutDuration">The number of seconds over which to ease out the animation.</param>
        /// <param name="callbacks">The set of callbacks to invoke for this animation.</param>
        public void Play(SkinnedAnimationMode mode, SkinnedAnimation animation, Single speedMultiplier,
                         EasingFunction easeInFunction, Double easeInDuration, EasingFunction easeOutFunction, Double easeOutDuration, SkinnedAnimationCallbacks?callbacks = null)
        {
            Contract.Require(animation, nameof(animation));
            Contract.Require(easeInFunction, nameof(easeInFunction));
            Contract.EnsureRange(easeInDuration >= 0, nameof(easeInDuration));
            Contract.Require(easeOutFunction, nameof(easeOutFunction));
            Contract.EnsureRange(easeOutDuration >= 0, nameof(easeOutDuration));

            this.currentAnimationMode = mode;
            this.CurrentAnimation     = animation;
            this.currentAnimationTime = 0.0;
            this.SpeedMultiplier      = speedMultiplier;

            if (mode != SkinnedAnimationMode.Manual)
            {
                this.easeInFunction  = easeInFunction;
                this.easeInDuration  = easeInDuration;
                this.easeOutFunction = easeOutFunction;
                this.easeOutDuration = easeOutDuration;
            }
            else
            {
                this.easeInFunction  = null;
                this.easeInDuration  = 0;
                this.easeOutFunction = null;
                this.easeOutDuration = 0;
            }

            this.easeInElasped  = 0;
            this.easeOutElapsed = 0;
            this.BlendingWeight = 1f;

            this.callbacks = callbacks;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Plays the specified animation. If the animation is already playing,
        /// it will be restarted using the specified mode.
        /// </summary>
        /// <param name="mode">A <see cref="SkinnedAnimationMode"/> value which describes the animation mode.</param>
        /// <param name="animation">The animation to play.</param>
        /// <param name="speedMultiplier">The relative speed at which to play the animation.</param>
        /// <param name="callbacks">The set of callbacks to invoke for this animation.</param>
        /// <returns>The <see cref="SkinnedAnimationTrack"/> which is playing the animation, or <see langword="null"/> if the animation could not be played.</returns>
        public SkinnedAnimationTrack PlayAnimation(SkinnedAnimationMode mode, SkinnedAnimation animation, Single speedMultiplier = 1f, SkinnedAnimationCallbacks?callbacks = null)
        {
            var controllerAllocation = AllocateTrack(animation);
            var controller           = controllerAllocation.Value;

            controller.Play(mode, animation, speedMultiplier, callbacks);
            ordering[controllerAllocation.Key] = ++orderingCounter;
            UpdateAnimationState();

            return(controller);
        }
        /// <summary>
        /// Plays the specified animation on this instance, if it exists. If the animation is already playing,
        /// it will be restarted using the specified mode.
        /// </summary>
        /// <param name="mode">A <see cref="SkinnedAnimationMode"/> value which describes the animation mode.</param>
        /// <param name="animationName">The name of the animation to play.</param>
        /// <param name="speedMultiplier">The relative speed at which to play the animation.</param>
        /// <param name="callbacks">The set of callbacks to invoke for this animation.</param>
        /// <returns>The <see cref="SkinnedAnimationTrack"/> which is playing the animation, or <see langword="null"/> if the animation could not be played.</returns>
        public SkinnedAnimationTrack PlayAnimation(SkinnedAnimationMode mode, String animationName, Single speedMultiplier = 1.0f, SkinnedAnimationCallbacks?callbacks = null)
        {
            Contract.Require(animationName, nameof(animationName));

            var animation = Template.Animations.TryGetAnimationByName(animationName);

            if (animation == null)
            {
                return(null);
            }

            return(controller.PlayAnimation(mode, animation, speedMultiplier, callbacks));
        }
        /// <summary>
        /// Plays the specified animation on this instance, if it exists. If the animation is already playing,
        /// it will be restarted using the specified mode.
        /// </summary>
        /// <param name="mode">A <see cref="SkinnedAnimationMode"/> value which describes the animation mode.</param>
        /// <param name="animationIndex">The index of the animation to play.</param>
        /// <param name="speedMultiplier">The relative speed at which to play the animation.</param>
        /// <param name="callbacks">The set of callbacks to invoke for this animation.</param>
        /// <returns>The <see cref="SkinnedAnimationTrack"/> which is playing the animation, or <see langword="null"/> if the animation could not be played.</returns>
        public SkinnedAnimationTrack PlayAnimation(SkinnedAnimationMode mode, Int32 animationIndex, Single speedMultiplier = 1.0f, SkinnedAnimationCallbacks?callbacks = null)
        {
            Contract.EnsureRange(animationIndex >= 0, nameof(animationIndex));

            if (animationIndex >= Template.Animations.Count)
            {
                return(null);
            }

            var animation = Template.Animations[animationIndex];

            return(controller.PlayAnimation(mode, animation, speedMultiplier, callbacks));
        }
        /// <summary>
        /// Plays the specified animation on this instance, if it exists. If the animation is already playing,
        /// it will be restarted using the specified mode.
        /// </summary>
        /// <param name="mode">A <see cref="SkinnedAnimationMode"/> value which describes the animation mode.</param>
        /// <param name="animationIndex">The index of the animation to play.</param>
        /// <param name="speedMultiplier">The relative speed at which to play the animation.</param>
        /// <param name="easeInFunction">The easing function to apply when easing in the animation.</param>
        /// <param name="easeInDuration">The number of seconds over which to ease in the animation.</param>
        /// <param name="easeOutFunction">The easing function to apply when easing out the animation.</param>
        /// <param name="easeOutDuration">The number of seconds over which to ease out the animation.</param>
        /// <param name="callbacks">The set of callbacks to invoke for this animation.</param>
        /// <returns>The <see cref="SkinnedAnimationTrack"/> which is playing the animation, or <see langword="null"/> if the animation could not be played.</returns>
        public SkinnedAnimationTrack PlayAnimation(SkinnedAnimationMode mode, Int32 animationIndex, Single speedMultiplier,
                                                   EasingFunction easeInFunction, Double easeInDuration, EasingFunction easeOutFunction, Double easeOutDuration, SkinnedAnimationCallbacks?callbacks = null)
        {
            Contract.EnsureRange(animationIndex >= 0, nameof(animationIndex));

            if (animationIndex >= Template.Animations.Count)
            {
                return(null);
            }

            var animation = Template.Animations[animationIndex];

            return(controller.PlayAnimation(mode, animation, speedMultiplier,
                                            easeInFunction, easeInDuration, easeOutFunction, easeOutDuration, callbacks));
        }
        /// <summary>
        /// Plays the specified animation on this instance, if it exists. If the animation is already playing,
        /// it will be restarted using the specified mode.
        /// </summary>
        /// <param name="mode">A <see cref="SkinnedAnimationMode"/> value which describes the animation mode.</param>
        /// <param name="animationName">The name of the animation to play.</param>
        /// <param name="speedMultiplier">The relative speed at which to play the animation.</param>
        /// <param name="easeInFunction">The easing function to apply when easing in the animation.</param>
        /// <param name="easeInDuration">The number of seconds over which to ease in the animation.</param>
        /// <param name="easeOutFunction">The easing function to apply when easing out the animation.</param>
        /// <param name="easeOutDuration">The number of seconds over which to ease out the animation.</param>
        /// <param name="callbacks">The set of callbacks to invoke for this animation.</param>
        /// <returns>The <see cref="SkinnedAnimationTrack"/> which is playing the animation, or <see langword="null"/> if the animation could not be played.</returns>
        public SkinnedAnimationTrack PlayAnimation(SkinnedAnimationMode mode, String animationName, Single speedMultiplier,
                                                   EasingFunction easeInFunction, Double easeInDuration, EasingFunction easeOutFunction, Double easeOutDuration, SkinnedAnimationCallbacks?callbacks = null)
        {
            Contract.Require(animationName, nameof(animationName));

            var animation = Template.Animations.TryGetAnimationByName(animationName);

            if (animation == null)
            {
                return(null);
            }

            return(controller.PlayAnimation(mode, animation, speedMultiplier,
                                            easeInFunction, easeInDuration, easeOutFunction, easeOutDuration, callbacks));
        }
 /// <summary>
 /// Plays the specified animation.
 /// </summary>
 /// <param name="mode">The animation mode.</param>
 /// <param name="animation">The animation to play.</param>
 /// <param name="speedMultiplier">The relative speed at which to play the animation.</param>
 /// <param name="callbacks">The set of callbacks to invoke for this animation.</param>
 public void Play(SkinnedAnimationMode mode, SkinnedAnimation animation, Single speedMultiplier = 1f, SkinnedAnimationCallbacks?callbacks = null)
 {
     Play(mode, animation, speedMultiplier, Easings.EaseInLinear, 0.0, Easings.EaseOutLinear, 0.0, callbacks);
 }