summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/Component/UnitState.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Unit/Component/UnitState.cs')
-rw-r--r--Assets/Scripts/Unit/Component/UnitState.cs86
1 files changed, 53 insertions, 33 deletions
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<EUnitState, ExitStateHandler> m_ExitStateHandlerDic = new Dictionary<EUnitState, ExitStateHandler>();
-
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<IdleParam>(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<IdleParam>(EUnitState.Idle);
+ }
+
+ void OnLandingExit(EUnitState next)
+ {
+ }
+
+ #endregion
}