From e5faa213bae57d3d7a92ceb078b4d1ddbe3c2f0c Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 30 Aug 2021 09:49:38 +0800 Subject: *misc --- Assets/Scripts/Unit/Component/PCState.cs | 79 +++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 26 deletions(-) (limited to 'Assets/Scripts/Unit/Component/PCState.cs') diff --git a/Assets/Scripts/Unit/Component/PCState.cs b/Assets/Scripts/Unit/Component/PCState.cs index 594ae131..1b01fad8 100644 --- a/Assets/Scripts/Unit/Component/PCState.cs +++ b/Assets/Scripts/Unit/Component/PCState.cs @@ -132,21 +132,21 @@ public class PCState : UnitState IEnumerator Idle(IdleParam param) { - if (m_Owner.isInAir) // 浮空切换到landing - { - ChangeState(EUnitState.Landing, new LandingParam()); - } - else // idle - { + //if (m_Owner.isInAir) // 浮空切换到landing + //{ + // ChangeState(EUnitState.Landing, new LandingParam()); + //} + //else // idle + //{ m_Owner.SetYPosition(0); m_Owner.pcAnimation.AnimIdle(); while (true) { - //if (Input.GetKeyDown("j")) - //{ - // ChangeState(EUnitState.Attack, new SkillParam()); - //} - if (Input.GetKeyDown("space")) + if (Input.GetKeyDown("j")) + { + ChangeState(EUnitState.Attack, new SkillParam()); + } + if (Input.GetKeyDown("space")) { ChangeState(EUnitState.Jump, new JumpParam()); } @@ -166,7 +166,7 @@ public class PCState : UnitState } yield return null; } - } + //} } void OnIdleExit(EUnitState nextState) @@ -202,23 +202,50 @@ public class PCState : UnitState m_Owner.pcAnimation.animator.ResetTrigger("ToMove"); } - #endregion - - #region Attack - - IEnumerator Attack(SkillParam param) - { - while (true) - { - - - yield return null; - } - } + #endregion + + #region Attack + + IEnumerator Attack(SkillParam param) + { + const int total = 3; + int id = 0; + m_Owner.pcAnimation.AnimAttack(id); + yield return null; + while (true) + { + bool canCombo = m_Owner.pcAnimation.layers[0].IsToggleOpen(EAnimationToogle.Combo); + if (canCombo) + { + if (Input.GetKeyDown("j")) + { + if (Input.GetKey("a")) + { + TurnAround(false); + } + if (Input.GetKey("d")) + { + TurnAround(true); + } + ++id; + m_Owner.pcAnimation.AnimAttack(id); + yield return null; // 等待animator更新 + yield return new WaitForTransitionDone(m_Owner.pcAnimation); + } + } + + bool reachEnd = m_Owner.pcAnimation.layers[0].playbackNomralizedTime == 1; + if (reachEnd) + { + ChangeState(EUnitState.Idle, new IdleParam()); + } + + yield return null; + } + } void OnAttackExit(EUnitState next) { - } #endregion -- cgit v1.1-26-g67d0