Esempio n. 1
0
 public void SetAnimationSpeedFactor(RoleAnimationType pAnimationName, float pFactor, bool pUseMachine)
 {
     if (pUseMachine && null != animationStateMachine)
     {
         animationStateMachine.SetAnimationSpeedScale(pAnimationName, pFactor);
     }
     else
     {
         AnimationData anim = AnimationGroup.GetAnimationData(pAnimationName);
         if (null != anim)
         {
             anim.SpeedScale = pFactor;
         }
     }
 }
Esempio n. 2
0
 public bool HasAnimation(RoleAnimationType type)
 {
     return(AnimationGroup.GetAnimationData(type) != null);
 }
Esempio n. 3
0
        /// <summary>
        /// Plays the animation range.  Currently this is specified in frame number.  May be better
        /// to use normalized time instead.
        /// </summary>
        /// <param name="pAnimName">Animation name</param>
        /// <param name="pRepeat">Play on repeat or not</param>
        /// <param name="pStart">Range start frame</param>
        /// <param name="pEnd">Range end frame</param>
        public void PlayRange(RoleAnimationType pAnimName, bool pRepeat, int pStart, int pEnd)
        {
            if (IsPlaying && CurrentAnimation != null)
            {
                Stop();
            }

            CurrentAnimation = AnimationGroup.GetAnimationData(pAnimName);
            IsRepeatPlay     = pRepeat;

            if (CurrentAnimation != null)
            {
                if (AnimationWillStart != null)
                {
                    AnimationWillStart(CurrentAnimation);
                }

                startFrame = Mathf.Clamp(pStart, 0, CurrentAnimation.FrameCount - 1);

                if (pEnd == -1)
                {
                    endFrame = CurrentAnimation.FrameCount - 1;
                }
                else
                {
                    endFrame = Mathf.Clamp(pEnd, 0, CurrentAnimation.FrameCount - 1);
                }

                animationSpecificSpeedFactor = 1.0f / CurrentAnimation.SpeedScale;
                if (float.IsInfinity(animationSpecificSpeedFactor))
                {
                    animationSpecificSpeedFactor = 1;
                    UnityEngine.Debug.LogError("animationSpecificSpeedFactor is infinity" + "MeshAnimator.PlayRange");
                }

                frameInterval      = 1.0f / ((GpuSkinAnimationGroup)AnimationGroup).Fps;
                nextUpdate         = /*Time.time + */ frameInterval * SpeedFactor * animationSpecificSpeedFactor;
                CurrentFrame       = startFrame;
                m_lastFrame        = -1;
                m_logicTime        = 0;
                wasUpdateSincePlay = false;

                if (CurrentAnimation.FrameCount == 0)
                {
                    normalizedRatio = 0;
                }
                else
                {
                    normalizedRatio = 1.0f / (float)CurrentAnimation.FrameCount;
                }

                SetNormalizedTime();

                IsPlaying = true;

                if (AnimationStarted != null)
                {
                    AnimationStarted(CurrentAnimation);
                }
            }
        }