diff options
Diffstat (limited to 'Assets/Scripts/Unit/Components/UnitAnimation/MonsterAnimation.cs')
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitAnimation/MonsterAnimation.cs | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/MonsterAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/MonsterAnimation.cs new file mode 100644 index 00000000..26361098 --- /dev/null +++ b/Assets/Scripts/Unit/Components/UnitAnimation/MonsterAnimation.cs @@ -0,0 +1,110 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class MonsterAnimation : UnitAnimation +{ + public enum ELayer + { + Basic = 0, + + Count, + } + + // 动作名,和animator里的state对应 + public enum EAnimState + { + // layer 0 + Idle = 0, + Move, + Jump, + Hit, + Attack, + Rise, + Stinger, + Turn, + Landing, + + AirAttack0, + AirAttack1, + AirAttack2, + AirAttack3, + + Attack0, + Attack1, + Attack2, + Attack3, + } + + public override void Initialize() + { + base.Initialize(); + + m_Animator = this.m_Owner.unitObj.GetComponent<Animator>(); + + m_Animator.speed = 0; + + m_LayerInfo = new AnimatorLayerInfo[2]; + m_LayerInfo[0] = new AnimatorLayerInfo(this, m_Animator, (int)ELayer.Basic); + //m_LayerInfo[1] = new AnimatorLayerInfo(this, m_Animator, ELayer.Attack); + + if (m_Animator == null) + { + LogHelper.LogError("没有挂Animator组件"); + } + + } + + public override void OnUpdate() + { + base.OnUpdate(); + + UpdateLayer(); + UpdateAnimation(); + UpdateRootMotion(); + } + + void UpdateLayer() + { + m_LayerInfo[0].OnUpdate(); + return; + for (int i = 0; i < m_LayerInfo.Length; ++i) + { + m_LayerInfo[i].OnUpdate(); + } + } + + void UpdateAnimation() + { + m_Animator.speed = 1; + m_Animator.Update(Time.deltaTime); + m_Animator.speed = 0; + } + + void UpdateRootMotion() + { + m_Owner.unitRootMotion.UpdateRootMotion(); + } + + public void AnimIdle() + { + m_Animator.CrossFade("Idle", 0.2f, 0); + } + + public void AnimHitLight() + { + m_Animator.Play("HitLight", 0, 0); + //m_Animator.CrossFade("HitLight", 0.05f, 0, 0, 0); + } + public void AnimHitAir() + { + m_Animator.Play("HitAir", 0, 0); + //m_Animator.CrossFade("HitLight", 0.05f, 0, 0, 0); + } + + public void AnimRise() + { + m_Animator.CrossFade("Rise", 0); + } + +} |