From 494d3f727786ff70753692d8de019d9600a007e1 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 3 Aug 2021 19:33:43 +0800 Subject: *misc --- Assets/Scripts/Unit/Component/UnitState.cs | 86 ++++++++++++++++++------------ 1 file changed, 53 insertions(+), 33 deletions(-) (limited to 'Assets/Scripts/Unit/Component/UnitState.cs') diff --git a/Assets/Scripts/Unit/Component/UnitState.cs b/Assets/Scripts/Unit/Component/UnitState.cs index 587c2f33..4a57ad6d 100644 --- a/Assets/Scripts/Unit/Component/UnitState.cs +++ b/Assets/Scripts/Unit/Component/UnitState.cs @@ -11,34 +11,31 @@ public class UnitState : UnitComponent public enum EUnitState { Idle , - Move , - Spawn , - Die , - Dead , - Skill , - // - HitAir , - HitAirHit , - Knockdown , - // - HitGuard , - // - Walk , - // - Rise , - // - Jump , - // 转身 - Turn , + Move , + Spawn , + Die , + Dead , + Skill , + // + HitAir , + HitAirHit , + Knockdown , + // + HitGuard , + // + Walk , + // + Rise , + // + Jump , + // 转身 + Turn , + Landing , // 从空中降落 } [SerializeField] private EUnitState m_State; public EUnitState CurrentState { get { return m_State; } } - private delegate void ExitStateHandler(EUnitState nextState); - - private Dictionary m_ExitStateHandlerDic = new Dictionary(); - public override void Initialize() { base.Initialize(); @@ -68,6 +65,8 @@ public class UnitState : UnitComponent EUnitState nextState; } + public struct LandingParam { } + #endregion void InitState() @@ -110,8 +109,12 @@ public class UnitState : UnitComponent IEnumerator Idle(IdleParam param) { - m_Owner.unitAnimation.Play(UnitAnimation.EAnimState.Idle); - yield return null; + if(m_Owner.isInAir) + { + + } + m_Owner.unitAnimation.AnimIdle(); + yield return null; } void OnIdleExit(EUnitState nextState) @@ -134,9 +137,9 @@ public class UnitState : UnitComponent // m_Owner.transform.rotation = Quaternion.Euler(0, 180, 0); m_Owner.transform.rotation = Quaternion.Euler(0, param.isRight ? 0 : 180, 0); } - if(Input.GetKey(param.key)) - m_Owner.unitAnimation.Play(UnitAnimation.EAnimState.Move); - while (Input.GetKey(param.key)) + //if (Input.GetKey(param.key)) + m_Owner.unitAnimation.AnimMove(); + while (Input.GetKey(param.key)) { yield return null; } @@ -145,7 +148,7 @@ public class UnitState : UnitComponent void OnMoveExit(EUnitState nextState) { - + //m_Owner.unitAnimation.animator.ResetTrigger("ToMove"); } #endregion @@ -154,8 +157,9 @@ public class UnitState : UnitComponent IEnumerator Skill(SkillParam param) { - m_Owner.unitAnimation.Play(UnitAnimation.EAnimState.Attack); - yield return new WaitForActionReachEnd(m_Owner.unitAnimation); + m_Owner.unitAnimation.AnimAttack(); + yield return new WaitForTransitionDone(m_Owner.unitAnimation); + yield return new WaitForActionReachEnd(m_Owner.unitAnimation); ChangeState(EUnitState.Idle, new IdleParam()); } @@ -170,7 +174,6 @@ public class UnitState : UnitComponent IEnumerator Jump(JumpParam param) { - m_Owner.unitAnimation.Play(UnitAnimation.EAnimState.Jump); yield return new WaitForActionReachEnd(m_Owner.unitAnimation); ChangeState(EUnitState.Idle); } @@ -180,6 +183,23 @@ public class UnitState : UnitComponent } - #endregion + #endregion + + #region Landing + + IEnumerator Landing(LandingParam param) + { + yield return new WaitForLanding(m_Owner); + Vector3 pos = m_Owner.transform.position; + pos.y = 0; + m_Owner.transform.position = pos; + ChangeState(EUnitState.Idle); + } + + void OnLandingExit(EUnitState next) + { + } + + #endregion } -- cgit v1.1-26-g67d0