Exemplo n.º 1
0
 public void Play(AnimationAction info)
 {
     if (m_boneEnt == null)
     {
         return;
     }
     m_boneEnt.Play(info);
 }
Exemplo n.º 2
0
 private void OnCreateUI()
 {
     if (m_photoImage == null)
     {
         return;
     }
     m_photoImage.gameObject.SetActiveNew(true);
     UIDragListener.Get(m_photoImage.gameObject).OnDragEvent = (ev, delta) =>
     {
         if (m_boneEnt == null)
         {
             return;
         }
         if (m_boneEnt.m_animation != null && m_boneEnt.m_animation.IsPlaying("born"))
         {
             return;
         }
         if (ev == eDragEvent.Drag)
         {
             m_boneEnt.SetDirection(m_boneEnt.GetRotate() + new Vector3(0f, -1 * delta.x, 0f));
         }
     };
     UIEventListener.Get(m_photoImage.gameObject).onClick = (obj) =>
     {
         if (m_boneEnt == null || m_boneEnt.m_animation == null || !m_bCanClick)
         {
             return;
         }
         if (m_boneEnt.m_animation.IsPlaying("idle") &&
             !m_boneEnt.m_animation.IsPlaying(m_showEffectData.clickAnimaName)) // 在休闲时,才播放点击动作
         {
             m_bCanClick = false;
             AnimationAction anima = new AnimationAction();
             anima.crossTime = 0.2f;
             anima.strFull   = m_showEffectData.clickAnimaName;
             anima.eMode     = WrapMode.Once;
             anima.endEvent  = () =>
             {
                 m_bCanClick = true;
                 AnimationAction anima2 = new AnimationAction();
                 anima2.crossTime = 0.2f;
                 anima2.strFull   = "idle";
                 anima2.eMode     = WrapMode.Loop;
                 Play(anima2);
                 OnCreateIdleEffect();
             };
             Play(anima);
             OnDestroyIdleEffect();
             // 点击播放动作时,播放对应的特效,切换动作时删除
             int     hId = CEffectMgr.Create(m_showEffectData.clickEffectId, m_boneEnt, "origin");
             CEffect ef  = CEffectMgr.GetEffect(hId);
             if (ef != null)
             {
                 ef.SetLayer(LusuoLayer.eEL_Photo);
             }
         }
     };
 }
Exemplo n.º 3
0
        /// <summary>
        /// 播放完动作后,默认播放待机
        /// </summary>
        public void PlayAnima(int animaId, Action playerEnd = null, bool bCross = true, float playSpeed = 1.0f)
        {
            if (m_animaInfo == null)
            {
                m_animaInfo = new AnimationAction();
            }

            AnimationCsvData animData = CsvManager.Inst.GetCsv <AnimationCsv>((int)eAllCSV.eAC_Animation).GetData(animaId);

            if (animData == null)
            {
                //Debug.LogError("动作为空 id= " + animaId);
                return;
            }

            // 通过优先级和技能保护时间,来判断是否需要播放
            if (animData.priority < m_animaPriority)
            {
                return;
            }

            m_animaPriority = animData.priority;
            //if(m_object != null)
            //Debug.LogWarning(m_object.name + " id: " + animaId +  " 设置优先级: " + m_animaPriority);

            if (bCross)
            {
                m_animaInfo.crossTime = AnimationInfo.m_crossTime;
            }

            if (animaId == SMtCreatureAnima.ANIMA_DIE)
            {
                m_animaInfo.crossTime = 0;
            }

            m_animaInfo.playSpeed = playSpeed * animData.speed;
            m_animaInfo.strFull   = animData.animationName;
            m_animaInfo.eMode     = (WrapMode)animData.mode;

            if (m_animaInfo.eMode == WrapMode.Once)
            {
                m_animaInfo.endEvent = playerEnd;
            }
            else
            {
                m_animaInfo.endEvent = null;
            }
            m_animaInfo.atOnce = animData.atOnce;
            Play(m_animaInfo);
        }
Exemplo n.º 4
0
        public virtual bool Play(AnimationAction action)
        {
            if (action == null)
            {
                return(false);
            }

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


            AnimationState anima = m_animation[action.strFull];

            if (anima == null)
            {
                m_animaPriority = 0;   // 先重置为0
                return(false);
            }

            anima.wrapMode = action.eMode;
            anima.speed    = action.playSpeed;
            if (action.atOnce)
            {
                m_animation.Stop(action.strFull);
                m_animation[action.strFull].time = Mathf.Epsilon;
            }
            m_animation.CrossFade(action.strFull, action.crossTime);
            //Debug.LogError(m_animation.gameObject.name + "播放:" + action.strFull + " 速度:" + action.playSpeed + "  时间:" + anima.length);
            if (action.endEvent != null)
            {
                action.endTime = anima.length;
                action.curTime = 0.0f;
            }
            // 如果是播放一次的才需要接受回调
            if (action.eMode == WrapMode.Once)
            {
                m_curAnimaStart = true;
            }
            m_curAnimaAction = action;   // 用于暂停时,无论是一次,还是循环都需要存储当前动作
            return(true);
        }
Exemplo n.º 5
0
 public bool _UpdateAnima(float fTime, float fDTime)
 {
     if (m_curAnimaStart && m_curAnimaAction != null && m_curAnimaAction.eMode == WrapMode.Once)
     {
         //Debug.LogError("播放once: " + m_curAnimaAction.curTime  +"   " + m_curAnimaAction.endTime);
         m_curAnimaAction.curTime += fDTime;
         if (m_curAnimaAction.curTime >= m_curAnimaAction.endTime)
         {
             if (null != m_curAnimaAction && null != m_curAnimaAction.endEvent)
             {
                 m_animaPriority = 0;   // 先重置为0
                 m_curAnimaAction.endEvent();
                 m_curAnimaAction.endEvent = null;
                 m_curAnimaAction          = null;
                 m_curAnimaStart           = false;
             }
         }
     }
     return(true);
 }
Exemplo n.º 6
0
        private void OnEnter()
        {
            // 先播放入场特效
            if (m_showEffectData == null)
            {
                Debug.LogError("英雄展示特效表无资源id:" + m_resId);
                OnCreateEnterPhoto("born");
                return;
            }

            string[] timeList   = m_showEffectData.enterEffectTime.Split('|');
            string[] effectList = m_showEffectData.enterEffectId.Split('|');

            for (int i = 0; i < timeList.Length; i++)
            {
                float time = 0;
                float.TryParse(timeList[i], out time);
                int effectId = 0;
                int.TryParse(effectList[i], out effectId);

                int eEventId = TimeMgr.Inst.RegisterEvent(time, () =>
                {
                    int hId    = CEffectMgr.Create(effectId, m_photoObject.transform.position, Vector3.zero);
                    CEffect ef = CEffectMgr.GetEffect(hId);
                    if (ef != null)
                    {
                        ef.SetLayer(LusuoLayer.eEL_Photo);
                    }
                    m_enterEffectHid.Add(hId);
                });

                m_eventList.Add(eEventId);
            }

            // 入场播放动作
            int eventId = TimeMgr.Inst.RegisterEvent(m_showEffectData.enterAnimaTime, () => {
                if (m_photoObject == null)
                {
                    return;
                }
                string animaName = m_showEffectData.enterAnimaName;

                EntityBaseInfo info = new EntityBaseInfo();
                info.m_resID        = (int)m_resId;
                info.m_ilayer       = (int)LusuoLayer.eEL_Photo;
                m_handleId          = EntityManager.Inst.CreateEntity(eEntityType.eBoneEntity, info, (ent) =>
                {
                    if (m_photoObject == null)
                    {
                        return;
                    }
                    // 播放人物动作
                    if (m_type == PhotoType.hero)
                    {
                        m_boneEnt = ent as BoneEntity;
                        m_boneEnt.SetParent(m_photoObject.transform);

                        string idleAnima      = "idle";
                        AnimationAction anima = new AnimationAction();
                        anima.strFull         = animaName;
                        anima.eMode           = WrapMode.Once;
                        anima.endEvent        = () =>
                        {
                            AnimationAction anima2 = new AnimationAction();
                            anima2.crossTime       = AnimationInfo.m_crossTime;
                            anima2.strFull         = idleAnima;
                            anima2.eMode           = WrapMode.Loop;
                            Play(anima2);
                            OnCreateIdleEffect();
                        };
                        Play(anima);
                    }
                    else if (m_type == PhotoType.uieffect)
                    {
                        m_boneEnt = ent as BoneEntity;
                        m_boneEnt.SetParent(m_photoObject.transform);

                        AnimationAction anima = new AnimationAction();
                        anima.strFull         = "idle";
                        anima.eMode           = WrapMode.Loop;
                        Play(anima);
                    }
                });
            });

            m_eventList.Add(eventId);
            // 播放英雄声音
            m_speakSoundHid = SoundManager.Inst.PlaySound(m_showEffectData.enterSpeakId, null);
        }