diff options
author | chai <chaifix@163.com> | 2021-08-29 19:44:31 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-08-29 19:44:31 +0800 |
commit | cf4e1f9833c810e18429ddf40f4bcf9052ff17ac (patch) | |
tree | 2cfae8edc3966b084baabfd5366c1c928a113c29 /Assets/Scripts/Unit/Component/MonsterAnimation.cs | |
parent | d88698a454fbfe306bd0142660172bdd6e93ecf3 (diff) |
*monster
Diffstat (limited to 'Assets/Scripts/Unit/Component/MonsterAnimation.cs')
-rw-r--r-- | Assets/Scripts/Unit/Component/MonsterAnimation.cs | 94 |
1 files changed, 94 insertions, 0 deletions
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<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);
+ }
+}
|