コード例 #1
0
ファイル: AvatarAnimator.cs プロジェクト: moto2002/FrameLock
        /// <summary>
        /// 添加到播放队列
        /// </summary>
        public void UF_AddToPlayQueue(string strName, bool triggerEvent, float fSpeed = 1.0f, string playParam = "", DelegateMethod eventFinish = null)
        {
            if (lockPlay)
            {
                Debugger.UF_Warn(string.Format("Animator Has been lock,play {0} failed", strName));
                return;
            }
            AnimatorClip action = UF_GetAnimatorClip(strName);

            if (action == null)
            {
                Debugger.UF_Warn(string.Format("Count not found the AnimatorClip[{0}] to Play ", strName));
                if (eventFinish != null)
                {
                    eventFinish(null);
                }
                return;
            }
            PlayQueueElemelt element;

            element.triggerEvent  = triggerEvent;
            element.clip          = action;
            element.eventOnFinish = eventFinish;
            element.speed         = fSpeed;
            element.playParam     = playParam;
            m_ListPlayQueue.Add(element);
        }
コード例 #2
0
ファイル: AvatarAnimator.cs プロジェクト: moto2002/FrameLock
 public void UF_Stop()
 {
     if (m_CurrentPlayClip != null)
     {
         m_IsOver = true;
         UF_ClearPlayQueue();
         m_CurrentPlayClip = null;
         m_PlayingCallback = null;
         this.ctrlSpeed    = 0;
     }
 }
コード例 #3
0
ファイル: AvatarAnimator.cs プロジェクト: moto2002/FrameLock
 public void UF_OnReset()
 {
     if (m_DicAnimatorClips == null)
     {
         return;
     }
     m_ListPlayQueue.Clear();
     m_CurrentPlayClip   = null;
     m_PlayingCallback   = null;
     m_EventTriggerIndex = 0;
     lockPlay            = false;
 }
コード例 #4
0
ファイル: AvatarAnimator.cs プロジェクト: moto2002/FrameLock
        public void UF_SetAnimateFrameAt(string strName, float normalTime)
        {
            this.UF_Stop();
            AnimatorClip action = UF_GetAnimatorClip(strName);

            if (action != null && m_Animator != null)
            {
                m_Animator.Play(action.clipName, 0, normalTime);
                m_Animator.Update(normalTime);
                this.ctrlSpeed = 0;
            }
        }
コード例 #5
0
ファイル: AvatarAnimator.cs プロジェクト: moto2002/FrameLock
        public float UF_GetClipLength(string strName)
        {
            AnimatorClip actionClip = UF_GetAnimatorClip(strName);

            if (actionClip != null)
            {
                AnimationClip animaClip = UF_GetAnimationClip(actionClip.clipName);
                if (animaClip != null)
                {
                    return(animaClip.length);
                }
            }
            return(1);
        }
コード例 #6
0
ファイル: AvatarAnimator.cs プロジェクト: moto2002/FrameLock
        public void UF_OnUpdate()
        {
            if (m_IsActive && !m_IsOver && !m_IsPause)
            {
                if (m_CurrentPlayClip != null && m_isPlayingElemelt)
                {
                    UF_UpdatePlayClipEvent();
                }
                else
                {
                    if (m_ListPlayQueue.Count > 0)
                    {
                        PlayQueueElemelt element = m_ListPlayQueue [0];
                        m_ListPlayQueue.RemoveAt(0);

                        m_CurrentPlayClip = element.clip;
                        m_CurrentPlayClip.playingAcitveEvent = element.triggerEvent;
                        m_CurrentPlayClip.playingCallback    = element.eventOnFinish;
                        m_CurrentPlayClip.playingSpeed       = element.speed;
                        m_CurrentPlayClip.playingParam       = element.playParam;
                        UF_PlayAnimatorClip(m_CurrentPlayClip);

                        UF_UpdatePlayClipEvent();
                    }
                    else
                    {
                        if (m_CurrentPlayClip != null && !m_isPlayingElemelt && m_CurrentPlayClip.isLoop)
                        {
                            UF_PlayAnimatorClip(m_CurrentPlayClip);
                            UF_UpdatePlayClipEvent();
                        }
                        else
                        {
                            if (m_CurrentPlayClip != null)
                            {
                                m_CurrentPlayClip.ResetPlayingState();
                                m_CurrentPlayClip = null;
                            }
                            m_IsOver = true;
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: AvatarAnimator.cs プロジェクト: moto2002/FrameLock
        /// <summary>
        /// 播放Action,并清空之前的播放列表,可用';'间隔多个Action的播放,所有Action播放完毕会触发完成事件
        /// </summary>
        public void UF_Play(string strName, bool triggerEvent, float fSpeed, string playParam = "", DelegateMethod eventFinish = null)
        {
            if (string.IsNullOrEmpty(strName))
            {
                return;
            }
            if (lockPlay)
            {
                Debugger.UF_Warn(string.Format("Animator Has been lock,play {0} failed", strName));
                return;
            }
            //避免重复播放
            if (m_isPlayingElemelt && m_CurrentPlayClip != null && m_CurrentPlayClip.name == strName)
            {
                return;
            }
            UF_ClearPlayQueue();
            m_CurrentPlayClip = null;
            m_IsOver          = false;
            m_IsPause         = false;
            this.ctrlSpeed    = 1;
            if (strName.IndexOf(';') > -1)
            {
                List <string> inlist = ListCache <string> .Acquire();

                GHelper.UF_SplitString(strName, inlist);
                for (int k = 0; k < inlist.Count; k++)
                {
                    if (!string.IsNullOrEmpty(inlist[k]))
                    {
                        UF_AddToPlayQueue(inlist[k], triggerEvent, fSpeed, string.Empty, eventFinish);
                    }
                }
                ListCache <string> .Release(inlist);
            }
            else
            {
                UF_AddToPlayQueue(strName, triggerEvent, fSpeed, playParam, eventFinish);
            }

            //立即执行更新一次,避免播放速度过快导致显示异常
            this.UF_OnUpdate();
        }
コード例 #8
0
ファイル: AvatarAnimator.cs プロジェクト: moto2002/FrameLock
        private void UF_PlayAnimatorClip(AnimatorClip aClip)
        {
            //获取影片播放长度
            m_PlayingLength = UF_GetAnimationClipRealLength(m_CurrentPlayClip.name) / m_CurrentPlayClip.playingSpeed;
            m_PlayingLength = GHelper.ShortFloat(m_PlayingLength);
            //设置当前影片播放速度
            this.speed = m_CurrentPlayClip.speed * m_CurrentPlayClip.playingSpeed;
            //重置索引
            m_EventTriggerIndex = 0;
            //重置当前影片播放时间
            m_PlayingTime      = 0;
            m_IsOver           = false;
            m_isPlayingElemelt = true;

            //播放影片动画
            if (m_Animator == null)
            {
                Debugger.UF_Warn("Animator Component is null,Animation will not play!");
                return;
            }
            switch (aClip.crossMode)
            {
            case AnimatorClip.CrossMode.CrossFabe:
                m_Animator.CrossFadeInFixedTime(aClip.clipName, aClip.fadeFactor);
                break;

            case AnimatorClip.CrossMode.Direct:
                if (aClip.wrapMode == WrapMode.Loop)
                {
                    m_Animator.Play(aClip.clipName);
                }
                else
                {
                    m_Animator.Play(aClip.clipName, 0, 0);
                }
                break;

            default:
                m_Animator.Play(aClip.clipName);
                break;
            }
        }