From 22891bf59032ba88262824255a706d652031384b Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 10 Mar 2022 14:07:40 +0800 Subject: * move folder --- .../Unit/Components/UnitState/PCState_States.cs | 390 --------------------- 1 file changed, 390 deletions(-) delete mode 100644 Assets/Scripts/Unit/Components/UnitState/PCState_States.cs (limited to 'Assets/Scripts/Unit/Components/UnitState/PCState_States.cs') diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState_States.cs b/Assets/Scripts/Unit/Components/UnitState/PCState_States.cs deleted file mode 100644 index 738cc7ce..00000000 --- a/Assets/Scripts/Unit/Components/UnitState/PCState_States.cs +++ /dev/null @@ -1,390 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public partial class PCState : UnitState -{ - - #region state param - public struct IdleParam { } - - public struct MoveParam - { - public bool isRight; - public string key; - } - - public struct SkillParam - { - public float offset; - } - - public struct AirDashParam - { - - } - - public struct JumpParam - { } - - public struct TurnParam - { - EUnitState nextState; - } - - public struct LandingParam { } - - #endregion - - IEnumerator Nein() { yield break; } - void OnNienExit(EUnitState nextState) { } - - #region Idle - - IEnumerator Idle(IdleParam param) - { - m_Owner.pcAnimation.AnimIdle(); - yield return new WaitForTransitionDone(owner.unitAnimation); - m_Owner.SetYPosition(0); - while (true) - { - if(TryAttackToAir()) - { - yield break; - } - if (Input.GetKeyDown("j")) - { - ChangeState(EUnitState.Attack, new SkillParam()); - yield break; - } - if (Input.GetKeyDown("space")) - { - ChangeState(EUnitState.Jump, new JumpParam()); - yield break; - } - if (Input.GetKey("d")) - { - MoveParam move = new MoveParam(); - move.isRight = true; - move.key = "d"; - ChangeState(EUnitState.Move, move); - yield break; - } - if (Input.GetKey("a")) - { - MoveParam move = new MoveParam(); - move.isRight = false; - move.key = "a"; - ChangeState(EUnitState.Move, move); - yield break; - } - yield return null; - } - } - - void OnIdleExit(EUnitState nextState) - { - } - #endregion - - #region Move - IEnumerator Move(MoveParam param) - { - if (m_Owner.isTowardRight && !param.isRight - || !m_Owner.isTowardRight && param.isRight) - { - //m_Owner.pcAnimation.Play(UnitAnimation.EAnimState.Turn); - //yield return new WaitForActionReachEnd(m_Owner.pcAnimation); - //if (param.isRight) - // m_Owner.transform.rotation = Quaternion.Euler(0, 0, 0); - //else - // 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.pcAnimation.AnimMove(); - while (Input.GetKey(param.key)) - { - TryAttackToAir(); - yield return null; - } - ChangeState(EUnitState.Idle, new IdleParam()); - } - - void OnMoveExit(EUnitState nextState) - { - m_Owner.pcAnimation.animator.ResetTrigger("ToMove"); - } - - #endregion - - #region Attack - - IEnumerator Attack(SkillParam param) - { - const int total = 4; - int id = 0; - m_Owner.pcAnimation.AnimAttack(id++); - yield return null; - while (true) - { - if (isComboOpen) - { - //if (InputManager.Instance.TryCommand(0.5f, KeyCode.W, KeyCode.J)) - if (Input.GetKeyDown("u")) - { - SkillParam skill = new SkillParam(); - skill.offset = 0.12f; - ChangeState(EUnitState.AttackToAir, skill); - } - } - - if (isComboOpen && id < total) - { - if (Input.GetKeyDown("j")) - { - TryTurnAround(); - - m_Owner.pcAnimation.AnimAttack(id++); - yield return null; - yield return new WaitForTransitionDone(m_Owner.pcAnimation); - } - } - - if (isAnimationReachEnd) - { - ChangeState(EUnitState.Idle, new IdleParam()); - } - - yield return null; - } - } - - void OnAttackExit(EUnitState next) - { - } - - #endregion - - #region AttackToAir - - IEnumerator AttackToAir(SkillParam param) - { - m_Owner.pcAnimation.AnimAttackToAir(param.offset); - yield return null; - InputManager.Instance.ClearCommand(); - while (true) - { - TryTianyin(); - - if (isComboOpen) - { - TryDash(); - - if (InputManager.Instance.TryCommand(0.5f, false, KeyCode.J)) - { - ChangeState(EUnitState.AirAttack, new SkillParam()); - } - } - - if (isAnimationReachEnd || isAnimationReachEndPoint) - { - ChangeState(EUnitState.Landing, new LandingParam()); - } - yield return null; - } - } - - void OnAttackToAirExit(EUnitState next) - { - } - - #endregion - - #region AirAttack - - IEnumerator AirAttack(SkillParam param) - { - int total = 5; - int id = 0; - m_Owner.pcAnimation.AnimAirAttack(id++); - yield return null; - InputManager.Instance.ClearCommand(); - while (true) - { - if (TryTeleport()) - { - } - - TryTianyin(); - - if (isComboOpen) - { - TryDash(); - - if (InputManager.Instance.TryCommand(0.3f, false, KeyCode.J)) - { - TryTurnAround(); - - m_Owner.pcAnimation.AnimAirAttack(id++); - id %= total; - yield return null; // 等待animator更新 - yield return new WaitForTransitionDone(m_Owner.pcAnimation); - } - } - - if (isAnimationReachEnd) - { - ChangeState(EUnitState.Landing, new LandingParam()); - } - - yield return null; - } - } - - void OnAirAttackExit(EUnitState next) - { - - } - - #endregion - - #region AirDash - - IEnumerator AirDash(AirDashParam param) - { - m_Owner.pcAnimation.AnimAirDash(); - yield return null; - while (true) - { - if (isAnimationReachEnd) - { - ChangeState(EUnitState.Landing, new LandingParam()); - } - - TryTianyin(); - - if (isComboOpen) - { - TryDash(); - - if (Input.GetKeyDown("j")) - { - TryTurnAround(); - ChangeState(EUnitState.AirAttack, new SkillParam()); - } - } - - yield return null; - } - } - - void OnAirDashExit(EUnitState next) - { - } - - #endregion - - #region Jump - - IEnumerator Jump(JumpParam param) - { - pcAnimation.AnimJump(); - yield return null; - yield return new WaitForTransitionDone(pcAnimation); - while (true) - { - if (InputManager.Instance.TryCommand(0.5f, KeyCode.A, KeyCode.A)) - { - TurnLeft(); - ChangeState(EUnitState.AirDash, new AirDashParam()); - } - if (InputManager.Instance.TryCommand(0.5f, KeyCode.D, KeyCode.D)) - { - TurnRight(); - ChangeState(EUnitState.AirDash, new AirDashParam()); - } - if (isAnimationReachEnd) - ChangeState(EUnitState.Landing, new LandingParam()); - bool canAttack = m_Owner.pcAnimation.baseLayer.IsToggleOpen(EAnimationToogle.Combo); - if (Input.GetKeyDown("j") && canAttack) - { - ChangeState(EUnitState.AirAttack, new SkillParam()); - } - yield return null; - } - } - - void OnJumpExit(EUnitState next) - { - } - - #endregion - - #region Landing - - IEnumerator Landing(LandingParam param) - { - m_Owner.pcAnimation.AnimLanding(); - yield return null; - yield return new WaitForTransitionDone(m_Owner.pcAnimation); - float vy = 0; - float g = -9.8f; - bool landingGround = false; - float vx = 5; - while (true) - { - Vector3 pos = m_Owner.transform.position; - - if(!landingGround) - { - vy += g * Time.deltaTime; - pos.y += vy * Time.deltaTime; - pos.y = Mathf.Max(0, pos.y); - } - - TryDash(); - - TryTianyin(); - - if (Input.GetKey("a")) - { - TurnAround(false); - pos.x -= vx * Time.deltaTime; - } - if (Input.GetKey("d")) - { - TurnAround(true); - pos.x += vx * Time.deltaTime; - } - - if (Input.GetKeyDown("j")) - { - ChangeState(EUnitState.AirAttack, new SkillParam()); - } - - m_Owner.transform.position = pos; - - if (pos.y > 0 && pos.y <= 1 && !landingGround) - { - landingGround = true; - m_Owner.pcAnimation.AnimLandingGround(); - } - if (pos.y <= 0) - { - pos.y = 0; - m_Owner.transform.position = pos; - ChangeState(EUnitState.Idle, new IdleParam()); - } - - yield return null; - } - } - - void OnLandingExit(EUnitState next) - { - } - - #endregion - -} -- cgit v1.1-26-g67d0