diff options
Diffstat (limited to 'Assets/Scripts/Unit/Components/UnitState/PCState.cs')
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitState/PCState.cs | 186 |
1 files changed, 0 insertions, 186 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState.cs b/Assets/Scripts/Unit/Components/UnitState/PCState.cs deleted file mode 100644 index 6a326431..00000000 --- a/Assets/Scripts/Unit/Components/UnitState/PCState.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System; -using System.Reflection; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -// 角色状态机 -[DisallowMultipleComponent] -public partial class PCState : UnitState -{ - public enum EUnitState - { - Nien, - - Idle, - Move, - Spawn, - Die, - Dead, - // - Attack, - AirAttack, - AttackToAir, - AirDash, - // - HitAir, - HitAirHit, - Knockdown, - // - HitGuard, - // - Walk, - // - Rise, - // - Jump, - // 转身 - Turn, - Landing, // 从空中降落 - } - - [SerializeField] private EUnitState m_State; - public EUnitState CurrentState { get { return m_State; } } - - private EUnitState m_PrevState; - - public override void Initialize() - { - base.Initialize(); - owner.onTimelineEvent += OnTimeLineEvent; - } - - public override void Release()
- {
- owner.onTimelineEvent -= OnTimeLineEvent;
- base.Release();
- } -
- PCAnimation pcAnimation { get { return m_Owner.pcAnimation; } } - - public void ChangeState<T>(EUnitState nextState, T param = default, bool bForce = false) - { - if (!IsChange(nextState, bForce)) - return; - - LogHelper.Log("UnitState: " + m_State.ToString() + " -> " + nextState.ToString()); - - StopAllCoroutines(); - - string methodFunc = "On" + m_State.ToString() + "Exit"; - MethodInfo exitMethod = GetType().GetMethod(methodFunc, BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(EUnitState) }, null); - if (exitMethod != null) - { - exitMethod.Invoke(this, new object[] { nextState }); - } - else - { - LogHelper.LogError("缺少 " + methodFunc); - }
- m_PrevState = m_State; - m_State = nextState;
-
- if(m_PrevState != m_State && owner.unitRender != null)
- {
- // owner.unitRender.SetVisibilityInMainCamera(true);
- }
-
- StartCoroutine(m_State.ToString(), param); - } - - bool IsChange(EUnitState newState, bool bForce) - { - if (newState != m_State || bForce) - return true; - return false; - } - - public void TurnAround(bool bRight) - { - m_Owner.transform.rotation = Quaternion.Euler(0, bRight ? 0 : 180, 0); - } - - public void TurnLeft() - { - TurnAround(false); - } - - public void TurnRight() - { - TurnAround(true); - }
-
- void TryDash()
- {
- if (InputManager.Instance.TryCommand(0.5f, KeyCode.A, KeyCode.A))
- {
- TurnLeft();
- ChangeState(EUnitState.AirDash, new AirDashParam(), true);
- }
- if (InputManager.Instance.TryCommand(0.5f, KeyCode.D, KeyCode.D))
- {
- TurnRight();
- ChangeState(EUnitState.AirDash, new AirDashParam(), true);
- } - } - - void TryTurnAround()
- {
- if (Input.GetKey("a"))
- {
- TurnLeft();
- }
- if (Input.GetKey("d"))
- {
- TurnRight();
- } - } - - bool TryTeleport()
- {
- if (Input.GetKeyDown("i"))
- {
- float offset = owner.isTowardRight ? 1.5f : -1.5f;
-
- Vector3 targetPos = TestErika.Instance.monster.owner.center + new Vector3(offset, -0.5f, 0);
- targetPos.y = Mathf.Max(1, targetPos.y);
-
- UnitSnapshotInfo info = owner.TakeSnapshot();
- Vector2 dir = targetPos - owner.center;
- owner.unitLensEffect.Dash(Color.white, 0.1f, Mathf.Rad2Deg * Mathf.Atan2(dir.y, dir.x), info);
-
- owner.center = targetPos;
- TurnAround(!owner.isTowardRight);
- return true;
- } - return false; - } - - bool TryBlink()
- {
- return false;
- }
-
- bool TryTianyin()
- {
- if (Input.GetKeyDown("o"))
- {
- float offset = owner.isTowardRight ? 1.2f : -1.2f;
- TestErika.Instance.monster.owner.center = owner.center + new Vector3(offset, 0.5f, 0);
- ((MonsterController)TestErika.Instance.monster.owner).monsterState.ChangeState(MonsterState.EUnitState.HitInAir, new MonsterState.HitInAirParam(), true);
- return true;
- } - return false; - }
-
- bool TryAttackToAir()
- {
- if(Input.GetKey("w") && Input.GetKeyDown("j"))
- {
- ChangeState(EUnitState.AttackToAir, new SkillParam());
- return true;
- }
- return false;
- }
-
-}
\ No newline at end of file |