Пример #1
0
        protected string GetAnimationNameByType(GameObject obj, Animation_Type type)
        {
            if (null == obj)
            {
                return(null);
            }
            SharedGameObjectInfo info = LogicSystem.GetSharedGameObjectInfo(obj);

            if (null != info)
            {
                Data_ActionConfig curActionConfig = ActionConfigProvider.Instance.ActionConfigMgr.GetDataById(info.AnimConfigId);

                return(curActionConfig.m_ActionAnimNameContainer[type]);

                //Data_ActionConfig.Data_ActionInfo action = null;
                //if (null != curActionConfig && curActionConfig.m_ActionContainer.ContainsKey(type)) {
                //  if (curActionConfig.m_ActionContainer[type].Count > 0) {
                //    action = curActionConfig.m_ActionContainer[type][0];
                //  }
                //}
                //if (null != action) {
                //  return action.m_AnimName;
                //}
            }
            return(null);
        }
Пример #2
0
 public void NotifyNpcMeetEnemy(NpcInfo npc, Animation_Type type)
 {
     if (null != OnNpcMeetEnemy)
     {
         OnNpcMeetEnemy(npc, type);
     }
 }
Пример #3
0
        protected float GetAnimationLenthByType(GameObject obj, Animation_Type type)
        {
            string    animName = GetAnimationNameByType(obj, type);
            Animation anim     = obj.GetComponent <Animation>();

            if (!string.IsNullOrEmpty(animName))
            {
                if (null != obj && null != anim)
                {
                    try
                    {
                        AnimationState state = anim[animName];
                        if (null != state)
                        {
                            return(state.length);
                        }
                        else
                        {
                            LogSystem.Error("Obj " + obj.name + " GetAnimationLenthBy Type " + type + " is null");
                        }
                    }
                    catch { }
                }
            }
            return(0.0f);
        }
Пример #4
0
        protected void CrossFadeAnimation(GameObject obj, Animation_Type anim, float time = 0.3f, float speed = 1.0f)
        {
            Animation animation = obj.GetComponent <Animation>();

            if (null != obj && null != animation)
            {
                string animName = GetAnimationNameByType(obj, anim);
                if (!string.IsNullOrEmpty(animName) && null != animation[animName])
                {
                    animation[animName].speed = speed;
                    animation.CrossFade(animName, time);
                }
            }
            else
            {
                if (null == obj)
                {
                    LogSystem.Error("null obj");
                }
                else
                {
                    LogSystem.Error("null anim");
                }
            }
        }
Пример #5
0
        private void StartMoveAnimation()
        {
            Animation_Type type = Animation_Type.AT_None;
            float          speed_factor;
            float          move_speed = GetOwner().GetActualProperty().MoveSpeed;

            GetAnimationDirAndSpeed(m_CharacterAnimationInfo.MoveMode,
                                    move_speed, out type, out speed_factor);
            if (type == Animation_Type.AT_RunForward && m_IsCombatState)
            {
                type = Animation_Type.AT_CombatRun;
                if (m_CurActionConfig != null)
                {
                    speed_factor = move_speed / m_CurActionConfig.m_CombatStdSpeed;
                }
            }
            string name = GetAnimationNameByType(type);

            if (!string.IsNullOrEmpty(name))
            {
                float fadetime = 0.3f;
                if (GetOwner() != null && GetOwner().GetSkillStateInfo() != null)
                {
                    fadetime = GetOwner().GetSkillStateInfo().CrossToRunTime;
                    GetOwner().ResetCross2StandRunTime();
                }
                GfxSystem.SetAnimationSpeed(m_Actor, name, speed_factor);
                GfxSystem.CrossFadeAnimation(m_Actor, name, fadetime);
            }
        }
Пример #6
0
        protected void SetAnimationSpeed(GameObject obj, Animation_Type anim, float speed)
        {
            Animation animation = obj.GetComponent <Animation>();

            if (null != obj && null != animation)
            {
                string animName = GetAnimationNameByType(obj, anim);
                if (!string.IsNullOrEmpty(animName))
                {
                    if (null != animation[animName])
                    {
                        animation[animName].speed = speed;
                    }
                    else
                    {
                        LogSystem.Error("obj" + obj.name + " can't find animation clip" + animName);
                    }
                }
            }
            else
            {
                if (null == obj)
                {
                    LogSystem.Error("null obj");
                }
                else
                {
                    LogSystem.Error("obj " + obj.name + " does not have animation");
                }
            }
        }
Пример #7
0
        protected void PlayAnimation(GameObject obj, Animation_Type anim, float speed = 1.0f, UnityEngine.AnimationBlendMode blendMode = UnityEngine.AnimationBlendMode.Blend)
        {
            Animation animation = obj.GetComponent <Animation>();

            if (null != obj && null != animation)
            {
                string animName = GetAnimationNameByType(obj, anim);
                if (!string.IsNullOrEmpty(animName) && null != animation[animName])
                {
                    if (!animation.IsPlaying(animName))
                    {
                        animation[animName].speed = speed;
                        animation.Play(animName);
                        animation[animName].blendMode = blendMode;
                    }
                }
            }
            else
            {
                if (null == obj)
                {
                    LogSystem.Error("null obj");
                }
                else
                {
                    LogSystem.Error("null anim");
                }
            }
        }
 private void AddActionAnimName(Animation_Type at)
 {
     if (m_ActionContainer[at].Count > 0)
     {
         m_ActionAnimNameContainer[at] = m_ActionContainer[at][0].m_AnimName;
     }
 }
Пример #9
0
 protected Data_ActionConfig.Data_ActionInfo GetRandomActionByType(Animation_Type type)
 {
     if (m_CurActionConfig != null)
     {
         return(m_CurActionConfig.GetRandomActionByType(type));
     }
     return(null);
 }
Пример #10
0
        /**
         * @brief 获取动作数量
         *
         * @return
         */
        public int GetActionCountByType(Animation_Type type)
        {
            if (!m_ActionContainer.ContainsKey(type))
            {
                return(0);
            }

            return(m_ActionContainer[type].Count);
        }
Пример #11
0
        /**
         * @brief 获取动作数量
         *
         * @return
         */
        public int GetActionCountByType(Animation_Type type)
        {
            List <Data_ActionInfo> infos;

            if (!m_ActionContainer.TryGetValue(type, out infos))
            {
                return(0);
            }
            return(infos.Count);
        }
Пример #12
0
        private void OnNpcMeetEnemy(NpcInfo npc, Animation_Type animType)
        {
            CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId());

            if (null != view)
            {
                GfxSystem.SendMessage(view.Actor, "OnEventMeetEnemy", null);
            }
            ImpactSystem.Instance.SendImpactToCharacter(npc, npc.GetMeetEnemyImpact(), npc.GetId(), -1, -1, npc.GetMovementStateInfo().GetPosition3D(), npc.GetMovementStateInfo().GetFaceDir());
        }
Пример #13
0
        public void StopAnimation(Animation_Type type)
        {
            string name = GetAnimationNameByType(type);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }
            GfxSystem.StopAnimation(m_Actor, name);
        }
Пример #14
0
        protected bool IsAnimationInited(Animation_Type anim_type)
        {
            string name = GetAnimationNameByType(anim_type);

            if (string.IsNullOrEmpty(name))
            {
                return(true);
            }
            return(m_InitedAnimation.Contains(name));
        }
Пример #15
0
        private void OnNpcMeetEnemy(NpcInfo npc, Animation_Type animType)
        {
            CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId());

            if (null != view)
            {
                GfxSystem.SendMessage(view.Actor, "OnMeetEnemy", null);
            }
            view.PlayAnimation(animType);
            view.PlayQueuedAnimation(Animation_Type.AT_Stand);
        }
Пример #16
0
 public List <Data_ActionInfo> GetAllActionByType(Animation_Type type)
 {
     if (m_ActionContainer.ContainsKey(type))
     {
         return(m_ActionContainer[type]);
     }
     else
     {
         return(new List <Data_ActionInfo>());
     }
 }
Пример #17
0
        internal void PlayAnimation(Animation_Type type, float speed)
        {
            string name = GetAnimationNameByType(type);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            GfxSystem.CrossFadeAnimation(m_Actor, name);
            GfxSystem.SetAnimationSpeed(m_Actor, name, speed);
        }
Пример #18
0
 protected string GetAnimationSoundByType(Animation_Type type)
 {
     if (m_CurActionConfig != null)
     {
         Data_ActionConfig.Data_ActionInfo action = m_CurActionConfig.GetRandomActionByType(type);
         if (action != null)
         {
             return(action.m_SoundId);
         }
     }
     return(null);
 }
Пример #19
0
        public void PlayQueuedAnimation(Animation_Type type, float speed)
        {
            string name = GetAnimationNameByType(type);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            GfxSystem.PlayQueuedAnimation(m_Actor, name);
            GfxSystem.SetAnimationSpeed(m_Actor, name, speed);
        }
Пример #20
0
        /**
         * @brief 获取随机动作
         *
         * @return
         */
        public Data_ActionInfo GetRandomActionByType(Animation_Type type)
        {
            int count = GetActionCountByType(type);

            if (count > 0)
            {
                int randIndex = CrossEngineHelper.Random.Next(count);
                return(m_ActionContainer[type][randIndex]);
            }

            return(null);
        }
Пример #21
0
        public List <Data_ActionInfo> GetAllActionByType(Animation_Type type)
        {
            List <Data_ActionInfo> infos;

            if (m_ActionContainer.TryGetValue(type, out infos))
            {
                return(infos);
            }
            else
            {
                return(new List <Data_ActionInfo>());
            }
        }
Пример #22
0
        protected virtual void UpdateIdle()
        {
            if (!GetOwner().IsDead() && m_CharacterAnimationInfo.IsIdle())
            {
                if (m_IdleState == IdleState.kNotIdle)
                {
                    Animation_Type at   = m_IsCombatState ? Animation_Type.AT_CombatStand : Animation_Type.AT_Stand;
                    string         name = GetAnimationNameByType(at);
                    if (!string.IsNullOrEmpty(name))
                    {
                        float fadetime = 0.5f;
                        if (GetOwner() != null && GetOwner().GetSkillStateInfo() != null)
                        {
                            fadetime = GetOwner().GetSkillStateInfo().CrossToStandTime;
                            GetOwner().ResetCross2StandRunTime();
                        }
                        GfxSystem.CrossFadeAnimation(m_Actor, name, fadetime);
                    }

                    m_BeginIdleTime = TimeUtility.GetServerMilliseconds();
                    m_IdleState     = IdleState.kReady;
                    m_IdleInterval  = CrossEngineHelper.Random.Next(1, 3) * 1000;
                }
                else if (m_IdleState == IdleState.kReady)
                {
                    if (TimeUtility.GetServerMilliseconds() - m_BeginIdleTime > m_IdleInterval)
                    {
                        Animation_Type at   = m_IsCombatState ? Animation_Type.AT_CombatStand : Animation_Type.AT_Stand;
                        string         name = GetAnimationNameByType(at);
                        if (!string.IsNullOrEmpty(name))
                        {
                            float fadetime = 0.5f;
                            if (GetOwner() != null && GetOwner().GetSkillStateInfo() != null)
                            {
                                fadetime = GetOwner().GetSkillStateInfo().CrossToStandTime;
                            }
                            GfxSystem.CrossFadeAnimation(m_Actor, name, fadetime);
                        }
                        m_BeginIdleTime = TimeUtility.GetServerMilliseconds();
                    }
                }
            }
            else
            {
                m_IdleState = IdleState.kNotIdle;
            }
        }
Пример #23
0
        private void StartMoveAnimation()
        {
            Animation_Type type = Animation_Type.AT_None;
            float          speed_factor;
            float          move_speed = GetOwner().GetActualProperty().MoveSpeed;

            GetAnimationDirAndSpeed(m_CharacterAnimationInfo.MoveMode,
                                    m_CharacterAnimationInfo.MoveDir,
                                    move_speed, out type, out speed_factor);
            string name = GetAnimationNameByType(type);

            if (!string.IsNullOrEmpty(name))
            {
                RecordAnim(name, false);
                GfxSystem.CrossFadeAnimation(m_Actor, name, 0.05f);
                //GfxSystem.SetAnimationSpeed(m_Actor, name, (float)speed_factor);
            }
        }
Пример #24
0
 internal void PlayStoryAnimation(Animation_Type type, long remain_time, bool isQueued)
 {
     m_IsStoryAnimationPlaying = true;
     m_IdleState     = IdleState.kNotIdle;
     m_StoryAnimName = GetAnimationNameByType(type);
     if (remain_time > 0)
     {
         m_StoryAnimStopTime = TimeUtility.GetServerMilliseconds() + remain_time;
     }
     if (isQueued)
     {
         PlayQueuedAnimation(type, 1.0f);
     }
     else
     {
         PlayAnimation(type, 1.0f);
     }
 }
Пример #25
0
        protected void InitAnimation(Animation_Type type, bool isUpperBody)
        {
            if (m_CurActionConfig == null)
            {
                return;
            }
            List <Data_ActionConfig.Data_ActionInfo> list = m_CurActionConfig.GetAllActionByType(type);

            for (int i = 0; i < list.Count; i++)
            {
                string animName = list[i].m_AnimName;
                if (null == animName || "" == animName)
                {
                    continue;
                }
                if (m_InitedAnimation.Contains(animName))
                {
                    continue;
                }
                m_InitedAnimation.Add(animName);
            }
        }
Пример #26
0
        protected void GetAnimationDirAndSpeed(MovementMode mode, float move_speed, out Animation_Type at, out float speed_factor)
        {
            Data_ActionConfig action_config = m_CurActionConfig;

            if (mode == MovementMode.LowSpeed)
            {
                at = Animation_Type.AT_SlowMove;
            }
            else if (mode == MovementMode.HighSpeed)
            {
                at = Animation_Type.AT_FastMove;
            }
            else
            {
                at = Animation_Type.AT_RunForward;
            }
            if (action_config != null)
            {
                if (mode == MovementMode.LowSpeed)
                {
                    speed_factor = move_speed / action_config.m_SlowStdSpeed;
                }
                else if (mode == MovementMode.HighSpeed)
                {
                    speed_factor = move_speed / action_config.m_FastStdSpeed;
                }
                else
                {
                    speed_factor = move_speed / action_config.m_ForwardStdSpeed;
                }
            }
            else
            {
                speed_factor = 1.0f;
            }
        }
Пример #27
0
        protected void StopAnimation(GameObject obj, Animation_Type anim)
        {
            Animation animation = obj.GetComponent <Animation>();

            if (null != obj && null != animation)
            {
                string animName = GetAnimationNameByType(obj, anim);
                if (!string.IsNullOrEmpty(animName) && null != animation[animName])
                {
                    animation.Stop(animName);
                }
            }
            else
            {
                if (null == obj)
                {
                    LogSystem.Error("null obj");
                }
                else
                {
                    LogSystem.Error("null anim");
                }
            }
        }
Пример #28
0
 public void PlayQueuedAnimation(Animation_Type type)
 {
     PlayQueuedAnimation(type, 1.0f);
 }
Пример #29
0
 internal void PlayQueuedAnimation(Animation_Type type)
 {
     PlayQueuedAnimation(type, 1.0f);
 }
Пример #30
0
        protected void GetAnimationDirAndSpeed(MovementMode mode, RelMoveDir rmd, float move_speed, out Animation_Type at, out float speed_factor)
        {
            Data_ActionConfig action_config = m_CurActionConfig;

            if (mode == MovementMode.LowSpeed)
            {
                at = Animation_Type.AT_SlowMove;
            }
            else if (mode == MovementMode.HighSpeed)
            {
                at = Animation_Type.AT_FastMove;
            }
            else
            {
                at = new Animation_Type[] {
                    Animation_Type.AT_Idle0,            // N
                    Animation_Type.AT_RunForward,       // F
                    Animation_Type.AT_RunBackward,      // B
                    Animation_Type.AT_Idle0,            // N
                    Animation_Type.AT_RunLeft,          // L
                    Animation_Type.AT_RunForwardLeft,   // LF
                    Animation_Type.AT_RunBackwardLeft,  // BL
                    Animation_Type.AT_Idle0,            // N
                    Animation_Type.AT_RunRight,         // R
                    Animation_Type.AT_RunForwardRight,  // FR
                    Animation_Type.AT_RunBackwardRight, // BR
                }[(int)rmd];
            }
            //                           N    F   B       N   L       LF      BL      N   R       FR      BR
            //speed_factor = new float[] { 0f, 1f, 1 / 2f, 0f, 3 / 4f, 7 / 8f, 5 / 8f, 0f, 3 / 4f, 7 / 8f, 5 / 8f }[(int)rmd];
            if (action_config != null)
            {
                if (mode == MovementMode.LowSpeed)
                {
                    speed_factor = move_speed / action_config.m_SlowStdSpeed;
                }
                else if (mode == MovementMode.HighSpeed)
                {
                    speed_factor = move_speed / action_config.m_FastStdSpeed;
                }
                else
                {
                    speed_factor = new float[] {
                        0f,                                                    //N
                        move_speed / action_config.m_ForwardStdSpeed,          //F
                        move_speed / action_config.m_BackStdSpeed,             //B
                        0f,                                                    //N
                        move_speed / action_config.m_LeftRightStdSpeed,        //L
                        move_speed / action_config.m_LeftRightForwardStdSpeed, // LF
                        move_speed / action_config.m_LeftRightBackStdSpeed,    //LB
                        0f,
                        move_speed / action_config.m_LeftRightStdSpeed,        //R
                        move_speed / action_config.m_LeftRightForwardStdSpeed, //RF
                        move_speed / action_config.m_LeftRightBackStdSpeed     //RB
                    }[(int)rmd];
                }
            }
            else
            {
                speed_factor = 1.0f;
            }
        }