diff options
author | chai <chaifix@163.com> | 2022-03-10 14:07:40 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2022-03-10 14:07:40 +0800 |
commit | 22891bf59032ba88262824255a706d652031384b (patch) | |
tree | 7595439ba9966c9402d37e37cee5e8cf098757d5 /Assets/Scripts/Unit/Components/UnitState/MonsterState.cs | |
parent | 8b04ea73e540067f83870b61d89db4868fea5e8a (diff) |
* move folder
Diffstat (limited to 'Assets/Scripts/Unit/Components/UnitState/MonsterState.cs')
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitState/MonsterState.cs | 218 |
1 files changed, 0 insertions, 218 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitState/MonsterState.cs b/Assets/Scripts/Unit/Components/UnitState/MonsterState.cs deleted file mode 100644 index c2a581b1..00000000 --- a/Assets/Scripts/Unit/Components/UnitState/MonsterState.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System; -using System.Reflection; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class MonsterState : UnitState -{ - public enum EUnitState - { - Nien, - - Idle, - - Move, - - HitLight, - HitAir, - HitInAir,
- HitGround, - HitFall, - KnockDown, - Rise, - - Pull, - Landing, - } - - [SerializeField] private EUnitState m_State; - public EUnitState CurrentState { get { return m_State; } } - - UnitAnimation unitAnimation { get { return m_Owner.unitAnimation; } } - - public override void Initialize() - { - base.Initialize(); - } - - public void ChangeState<T>(EUnitState nextState, T param = default, bool bForce = false) - { - if (!IsChange(nextState, bForce)) - return; - - LogHelper.Log("Monster UnitState: " + m_State.ToString() + " -> " + nextState.ToString()); - - StopAllCoroutines(); - - EUnitState prevState = m_State; - 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_State = nextState; - - StartCoroutine(m_State.ToString(), param); - } - - bool IsChange(EUnitState newState, bool bForce) - { - if (newState != m_State || bForce) - return true; - return false; - } - - IEnumerator Nein() { yield break; } - void OnNienExit(EUnitState nextState) { } - - public struct IdleParam { } - - public struct LandingParam { } - - public struct HitLightParam { } - - public struct HitAirParam { } - - public struct RiseParam { } - - public struct HitInAirParam { } - - #region Idle - - IEnumerator Idle(IdleParam param) - { - //if (m_Owner.isInAir) // 浮空切换到landing - //{ - // ChangeState(EUnitState.Landing, new LandingParam()); - //} - //else // idle - //{ - m_Owner.SetYPosition(0); - m_Owner.monsterAnimation.AnimIdle(); - while (true) - { - yield return null; - } - //} - } - - void OnIdleExit(EUnitState nextState) - { - } - #endregion - - #region HitLight - - IEnumerator HitLight(HitLightParam param) - { - ((MonsterController)owner).FacePC(); - m_Owner.monsterAnimation.AnimHitBackHeavy(); - yield return null; - while (true) - { - bool reachEnd = m_Owner.monsterAnimation.layers[0].playbackNormalizedTime == 1; - if(reachEnd) - { - ChangeState(EUnitState.Idle, new IdleParam()); - } - yield return null; - } - } - - void OnHitLightExit(EUnitState nextState) - { - } - - #endregion - - #region HitAir - - IEnumerator HitAir(HitAirParam param) - { - ((MonsterController)owner).FacePC(); - m_Owner.monsterAnimation.AnimHitAir(); - yield return null; - while (true) - { - bool reachEnd = m_Owner.monsterAnimation.layers[0].playbackNormalizedTime == 1; - if (reachEnd) - { - //yield return new WaitForSeconds(1f); - ChangeState(EUnitState.Rise, new RiseParam()); - } - yield return null; - } - } - - void OnHitAirExit(EUnitState nextState) - { - }
-
- #endregion -
- #region HitInAir -
- IEnumerator HitInAir(HitInAirParam param) - { - ((MonsterController)owner).FaceToFacePC(); - m_Owner.monsterAnimation.AnimHitInAir(); - yield return null; - float vy = -1f; - float g = -15.8f; - while (true) - { - bool reachEnd = m_Owner.monsterAnimation.baseLayer.playbackNormalizedTime == 1; - if (reachEnd) - { - vy += g * Time.deltaTime; - Vector3 pos = owner.transform.position; - pos.y += vy * Time.deltaTime; - if(pos.y <= 0)
- {
- yield return new WaitForSeconds(0.5f);
- ChangeState(EUnitState.Rise, new RiseParam());
- } - owner.transform.position = pos; - } - yield return null; - } - } - - void OnHitInAirExit(EUnitState nextState) - { - }
-
- #endregion -
- #region Rise -
- IEnumerator Rise(RiseParam param) - { - m_Owner.monsterAnimation.AnimRise(); - yield return null; - while (true) - { - bool reachEnd = m_Owner.monsterAnimation.layers[0].playbackNormalizedTime == 1; - if (reachEnd) - { - ChangeState(EUnitState.Idle, new IdleParam()); - } - yield return null; - } - } - - void OnRiseExit(EUnitState nextState) - { - } - - - #endregion - - -}
\ No newline at end of file |