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); }
public void NotifyNpcMeetEnemy(NpcInfo npc, Animation_Type type) { if (null != OnNpcMeetEnemy) { OnNpcMeetEnemy(npc, type); } }
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); }
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"); } } }
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); } }
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"); } } }
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; } }
protected Data_ActionConfig.Data_ActionInfo GetRandomActionByType(Animation_Type type) { if (m_CurActionConfig != null) { return(m_CurActionConfig.GetRandomActionByType(type)); } return(null); }
/** * @brief 获取动作数量 * * @return */ public int GetActionCountByType(Animation_Type type) { if (!m_ActionContainer.ContainsKey(type)) { return(0); } return(m_ActionContainer[type].Count); }
/** * @brief 获取动作数量 * * @return */ public int GetActionCountByType(Animation_Type type) { List <Data_ActionInfo> infos; if (!m_ActionContainer.TryGetValue(type, out infos)) { return(0); } return(infos.Count); }
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()); }
public void StopAnimation(Animation_Type type) { string name = GetAnimationNameByType(type); if (string.IsNullOrEmpty(name)) { return; } GfxSystem.StopAnimation(m_Actor, name); }
protected bool IsAnimationInited(Animation_Type anim_type) { string name = GetAnimationNameByType(anim_type); if (string.IsNullOrEmpty(name)) { return(true); } return(m_InitedAnimation.Contains(name)); }
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); }
public List <Data_ActionInfo> GetAllActionByType(Animation_Type type) { if (m_ActionContainer.ContainsKey(type)) { return(m_ActionContainer[type]); } else { return(new List <Data_ActionInfo>()); } }
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); }
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); }
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); }
/** * @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); }
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>()); } }
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; } }
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); } }
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); } }
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); } }
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; } }
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"); } } }
public void PlayQueuedAnimation(Animation_Type type) { PlayQueuedAnimation(type, 1.0f); }
internal void PlayQueuedAnimation(Animation_Type type) { PlayQueuedAnimation(type, 1.0f); }
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; } }