From 8bbc03542340b4ea7ca1e2beec2f11ff335851e8 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 27 Jul 2021 09:40:26 +0800 Subject: *mic --- Assets/Scripts/Unit/Component/UnitAnimation.cs | 43 +++++++++++++++++++++++--- Assets/Scripts/Unit/Component/UnitRender.cs | 15 +++------ Assets/Scripts/Unit/Component/UnitState.cs | 2 +- 3 files changed, 44 insertions(+), 16 deletions(-) (limited to 'Assets/Scripts/Unit/Component') 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(); + m_Animator = this.m_Owner.unitObj.GetComponent(); + + 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) -- cgit v1.1-26-g67d0