summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/Component
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Unit/Component')
-rw-r--r--Assets/Scripts/Unit/Component/UnitAnimation.cs43
-rw-r--r--Assets/Scripts/Unit/Component/UnitRender.cs15
-rw-r--r--Assets/Scripts/Unit/Component/UnitState.cs2
3 files changed, 44 insertions, 16 deletions
diff --git a/Assets/Scripts/Unit/Component/UnitAnimation.cs b/Assets/Scripts/Unit/Component/UnitAnimation.cs
index ac04148d..568863c9 100644
--- a/Assets/Scripts/Unit/Component/UnitAnimation.cs
+++ b/Assets/Scripts/Unit/Component/UnitAnimation.cs
@@ -6,13 +6,48 @@ using UnityEngine;
[DisallowMultipleComponent]
public class UnitAnimation : UnitComponent
{
- private Animator m_Animator;
+ // animator trigger值,切换动画
+ public enum ETrigger
+ {
+ Nein = 0,
+ ToIdle ,
+ ToMove ,
+ ToSpawn ,
+
+ ToDie ,
+ ToHitAir ,
+ ToHitAirAir,
+
+ ToHitKnockDown,
+
+ ToJump,
+ ToWalk,
+ }
+
+ private Animator m_Animator;
private TimelineEvent m_Timeline;
- public void Play()
- {
+ private UnitActionData m_ActionData;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ m_Timeline = this.m_Owner.unitObj.GetOrAddComponent<TimelineEvent>();
+ m_Animator = this.m_Owner.unitObj.GetComponent<Animator>();
+
+ if(m_Animator == null)
+ {
+ LogHelper.LogError("没有挂Animator组件");
+ }
+
+ }
- }
+ public void Play(ETrigger trigger)
+ {
+ string toAnim = trigger.ToString();
+ m_Animator.SetTrigger(toAnim);
+ }
}
diff --git a/Assets/Scripts/Unit/Component/UnitRender.cs b/Assets/Scripts/Unit/Component/UnitRender.cs
index cf308bab..2ba53a7d 100644
--- a/Assets/Scripts/Unit/Component/UnitRender.cs
+++ b/Assets/Scripts/Unit/Component/UnitRender.cs
@@ -2,18 +2,11 @@
using System.Collections.Generic;
using UnityEngine;
+// 控制角色渲染
[DisallowMultipleComponent]
-public class UnitRender : MonoBehaviour
+public class UnitRender : UnitComponent
{
- // Start is called before the first frame update
- void Start()
- {
-
- }
- // Update is called once per frame
- void Update()
- {
-
- }
+
+
}
diff --git a/Assets/Scripts/Unit/Component/UnitState.cs b/Assets/Scripts/Unit/Component/UnitState.cs
index d5b91cec..3832c933 100644
--- a/Assets/Scripts/Unit/Component/UnitState.cs
+++ b/Assets/Scripts/Unit/Component/UnitState.cs
@@ -85,7 +85,7 @@ public class UnitState : UnitComponent
}
IEnumerator Idle(IdleParam param)
{
- m_Owner.unitAnimation.Play();
+ //m_Owner.unitAnimation.Play();
yield return null;
}
void OnIdleExit(EUnitState nextState)