From cf4e1f9833c810e18429ddf40f4bcf9052ff17ac Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 29 Aug 2021 19:44:31 +0800 Subject: *monster --- Assets/Scripts/Unit/Component/MonsterAnimation.cs | 94 +++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Assets/Scripts/Unit/Component/MonsterAnimation.cs (limited to 'Assets/Scripts/Unit/Component/MonsterAnimation.cs') diff --git a/Assets/Scripts/Unit/Component/MonsterAnimation.cs b/Assets/Scripts/Unit/Component/MonsterAnimation.cs new file mode 100644 index 00000000..f536c5ef --- /dev/null +++ b/Assets/Scripts/Unit/Component/MonsterAnimation.cs @@ -0,0 +1,94 @@ +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(); + + 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); + } +} -- cgit v1.1-26-g67d0