Beispiel #1
0
        public float GetAnimTime(int nAnimID)
        {
            DRAnimation animData = GetConfigData(nAnimID);

            if (animData == null)
            {
                return(0.0f);
            }

            if (null == m_Animator || string.IsNullOrEmpty(animData.ResAnimName) || null == m_Animator.runtimeAnimatorController)
            {
                return(0.0f);
            }

            RuntimeAnimatorController ac = m_Animator.runtimeAnimatorController;

            AnimationClip[] tAnimationClips = ac.animationClips;
            if (null == tAnimationClips || tAnimationClips.Length <= 0)
            {
                return(0.0f);
            }

            AnimationClip tAnimationClip;

            for (int tCounter = 0; tCounter < tAnimationClips.Length; tCounter++)
            {
                tAnimationClip = ac.animationClips[tCounter];
                if (null != tAnimationClip && tAnimationClip.name == animData.ResAnimName)
                {
                    return(tAnimationClip.length);
                }
            }

            return(0.0f);
        }
Beispiel #2
0
        public bool GetAnimPos(int nAnimID, float fMotionTime, ref Vector3 vAnimDeltaPos)
        {
            if (m_Animator == null)
            {
                return(false);
            }

            DRAnimation animData = GetConfigData(nAnimID);

            if (animData == null)
            {
                return(false);
            }

            m_Animator.Play(animData.ResAnimName);
            m_Animator.Update(0);
            m_Animator.Update(fMotionTime);
            Vector3 vWorldDelta = m_Animator.deltaPosition;

            m_Animator.Play(animData.ResAnimName, -1, 0);
            m_Animator.Update(0);

            vAnimDeltaPos = vWorldDelta;
            return(true);
        }
Beispiel #3
0
        private DRAnimation GetConfigData(int nAnimID)
        {
            DRAnimation data = GameEntry.DataTable.GetDataTable <DRAnimation>().GetDataRow(nAnimID);

            if (data == null)
            {
                Log.Warning("动画表中没有 '{0}' ", nAnimID);
                return(null);
            }
            return(data);
        }
Beispiel #4
0
        public bool PlayAnimation(int nAnimID, Vector3 vGoalPos = default(Vector3), Vector3 vGoalDir = default(Vector3), float fMotionTime = 0, bool bPhy = false)
        {
            if (Owner == null)
            {
                return(false);
            }

            if (m_Animator == null)
            {
                return(false);
            }

            DRAnimation animData = GetConfigData(nAnimID);

            if (animData == null)
            {
                return(false);
            }

            if (animData.IsSelfRestart != 0 && m_curAnimID == nAnimID)
            {
                StopAnim();
            }
            if (animData.IsSelfRestart == 0 && m_curAnimID == nAnimID)
            {
                return(true);
            }

            m_triggerWaitingList.Push(animData.ResAnimName);

            m_curAnimID = nAnimID;
            if (animData.Layer == 0)
            {
                m_motionData.bMotion = (animData.Motion != 0);
                if (m_motionData.bMotion == true)
                {
                    m_motionData.Reset();
                    SaveMotionData(vGoalPos, vGoalDir, fMotionTime, bPhy);
                }
            }

            return(true);
        }