diff options
author | chai <chaifix@163.com> | 2021-07-27 09:40:26 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-07-27 09:40:26 +0800 |
commit | 8bbc03542340b4ea7ca1e2beec2f11ff335851e8 (patch) | |
tree | 15a4bdebe7b8d9448c476e0f67b94a5a50bc2ec5 /Assets/Scripts/Unit/Component | |
parent | 4ceee84cd45e4e3ec40ebd888e41bd47a938c2d5 (diff) |
*mic
Diffstat (limited to 'Assets/Scripts/Unit/Component')
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitAnimation.cs | 43 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitRender.cs | 15 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitState.cs | 2 |
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)
|