123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- using System;
- using System.Collections.Generic;
- using ExtensionMethods;
- using UnityEngine;
- public class FooterAction : EnemyBaseAction
- {
- static Dictionary<string, int> _003C_003Ef__switch_0024mapF;
- protected override void Start()
- {
- this.stateMachine.AddStates(typeof(FooterAction.StateEnum));
- this.stateMachine.OnEnter += this.OnMyStateEnter;
- this.stateMachine.OnTransfer += this.OnStateTransfer;
- base.AnimChangeState(FooterAction.StateEnum.Idle, 1f);
- }
- private void FixedUpdate()
- {
- if (this.stateMachine.currentState == "FlyToFall")
- {
- Vector2 currentSpeed = this.eAttr.timeController.GetCurrentSpeed();
- float f = currentSpeed.x;
- f = Mathf.Clamp(Mathf.Abs(f) - 8f * Time.fixedDeltaTime, 0f, float.MaxValue) * Mathf.Sign(f);
- currentSpeed.x = Mathf.Clamp(Mathf.Abs(f) - 8f * Time.fixedDeltaTime, 0f, float.PositiveInfinity) * Mathf.Sign(f);
- this.eAttr.timeController.SetSpeed(currentSpeed);
- }
- }
- protected override void Update()
- {
- base.Update();
- if (this.stateMachine.currentState == "FlyToFall")
- {
- Vector2 currentSpeed = this.eAttr.timeController.GetCurrentSpeed();
- if (currentSpeed.y > 0f)
- {
- currentSpeed.y = 0f;
- this.eAttr.timeController.SetSpeed(currentSpeed);
- }
- }
- if (this.stateMachine.currentState == "Atk1" || this.stateMachine.currentState == "Atk3")
- {
- this.eAttr.timeController.SetGravity(0f);
- }
- }
- private void OnStateTransfer(object sender, StateMachine.TransferEventArgs args)
- {
- base.GetComponent<EnemyBaseHurt>().StopFollowLeftHand();
- if (this.ExitAtkSta(args.lastState, args.nextState))
- {
- this.atkBox.localScale = Vector3.zero;
- }
- if (args.nextState == "FlyToFall")
- {
- Vector2 currentSpeed = this.eAttr.timeController.GetCurrentSpeed();
- currentSpeed.y = 0f;
- this.eAttr.timeController.SetSpeed(currentSpeed);
- this.eAttr.timeController.SetGravity(0f);
- }
- if (args.lastState == "FlyToFall" && !this.eAttr.willBeExecute)
- {
- this.eAttr.timeController.SetGravity(1f);
- }
- if (args.nextState.IsInArray(FooterAction.NormalSta))
- {
- this.hurtBox.localScale = Vector3.one;
- this.eAttr.timeController.SetGravity(1f);
- }
- }
- private void OnMyStateEnter(object sender, StateMachine.StateEventArgs args)
- {
- string state = args.state;
- if (state != null)
- {
- if (FooterAction._003C_003Ef__switch_0024mapF == null)
- {
- FooterAction._003C_003Ef__switch_0024mapF = new Dictionary<string, int>(24)
- {
- {
- "Atk1",
- 0
- },
- {
- "Atk2",
- 0
- },
- {
- "Atk3",
- 0
- },
- {
- "Die",
- 0
- },
- {
- "DieQTE",
- 0
- },
- {
- "FallHitGround",
- 0
- },
- {
- "FlyToFall",
- 0
- },
- {
- "GetUp",
- 0
- },
- {
- "Hit1",
- 0
- },
- {
- "HitToFly",
- 0
- },
- {
- "MoveAway",
- 0
- },
- {
- "AirDieFlyToFall",
- 0
- },
- {
- "AirDieHitGround",
- 0
- },
- {
- "ExecuteDie",
- 0
- },
- {
- "Null",
- 0
- },
- {
- "Jump",
- 0
- },
- {
- "HitToFly2",
- 1
- },
- {
- "Idle",
- 1
- },
- {
- "Move",
- 1
- },
- {
- "Fall",
- 1
- },
- {
- "AirDie",
- 1
- },
- {
- "AirDieFall",
- 1
- },
- {
- "HitFall",
- 1
- },
- {
- "Execute",
- 1
- }
- };
- }
- int num;
- if (FooterAction._003C_003Ef__switch_0024mapF.TryGetValue(state, out num))
- {
- if (num != 0)
- {
- if (num == 1)
- {
- this.spineAnim.Play(args.state, true, false, 1f);
- }
- }
- else
- {
- this.spineAnim.Play(args.state, false, true, 1f);
- }
- }
- }
- }
- public override void Attack1(int dir)
- {
- if (this.eAttr.isDead)
- {
- return;
- }
- if (!this.IsInNormalState())
- {
- return;
- }
- base.ChangeFace(dir);
- this.eAttr.timeController.SetGravity(0f);
- this.eAttr.timeController.SetSpeed(Vector2.zero);
- base.AnimChangeState(FooterAction.StateEnum.Atk1, 1f);
- }
- public override void Attack2(int dir)
- {
- if (this.eAttr.isDead)
- {
- return;
- }
- if (!this.IsInNormalState())
- {
- return;
- }
- base.ChangeFace(dir);
- base.AnimChangeState(FooterAction.StateEnum.Atk2, 1f);
- }
- public override void Attack3(int dir)
- {
- if (this.eAttr.isDead)
- {
- return;
- }
- if (!this.IsInNormalState())
- {
- return;
- }
- base.ChangeFace(dir);
- this.eAttr.timeController.SetGravity(0f);
- this.eAttr.timeController.SetSpeed(Vector2.zero);
- base.AnimChangeState(FooterAction.StateEnum.Atk3, 1f);
- }
- public override void CounterAttack(int dir)
- {
- if (this.eAttr.isDead)
- {
- return;
- }
- if (this.IsInAttackState())
- {
- return;
- }
- R.Effect.Generate(128, base.transform, Vector3.up * 1.5f, Vector3.zero, default(Vector3), true);
- base.ChangeFace(dir);
- this.eAttr.timeController.SetGravity(0f);
- this.eAttr.timeController.SetSpeed(Vector2.zero);
- base.AnimChangeState(FooterAction.StateEnum.Atk3, 1f);
- }
- public override void SideStep()
- {
- if (this.eAttr.isDead)
- {
- return;
- }
- if (this.IsInSideStepState())
- {
- return;
- }
- if (!this.eAttr.isOnGround)
- {
- return;
- }
- base.SideStep();
- this.eAttr.timeController.SetGravity(0f);
- this.eAttr.timeController.SetSpeed(Vector2.zero);
- base.AnimChangeState(FooterAction.StateEnum.MoveAway, 1f);
- }
- public void Jump()
- {
- if (this.eAttr.isDead)
- {
- return;
- }
- if (!this.IsInNormalState())
- {
- return;
- }
- this.eAttr.timeController.SetGravity(0f);
- this.eAttr.timeController.SetSpeed(Vector2.zero);
- base.AnimChangeState(FooterAction.StateEnum.Jump, 1f);
- }
- public override void AnimMove()
- {
- base.AnimChangeState(FooterAction.StateEnum.Move, 1f);
- }
- public override void AnimReady()
- {
- base.AnimChangeState(FooterAction.StateEnum.Idle, 1f);
- }
- public override bool IsInNormalState()
- {
- return this.stateMachine.currentState.IsInArray(FooterAction.NormalSta) && base.IsInNormalState();
- }
- public override bool IsInAttackState()
- {
- return this.stateMachine.currentState.IsInArray(FooterAction.AttackSta);
- }
- public override bool IsInDeadState(string state)
- {
- return state.IsInArray(FooterAction.DieSta);
- }
- public override bool IsInWeakSta()
- {
- return this.eAttr.inWeakState;
- }
- protected override bool EnterAtkSta(string lastState, string nextState)
- {
- return nextState.IsInArray(FooterAction.AttackSta) && !lastState.IsInArray(FooterAction.AttackSta);
- }
- protected override bool ExitAtkSta(string lastState, string nextState)
- {
- return !nextState.IsInArray(FooterAction.AttackSta) && lastState.IsInArray(FooterAction.AttackSta);
- }
- public override bool IsInSideStepState()
- {
- return this.stateMachine.currentState == "MoveAway";
- }
- public override bool IsInIdle()
- {
- return this.stateMachine.currentState == "Idle";
- }
- private static readonly string[] AttackSta = new string[]
- {
- "Atk1",
- "Atk2",
- "Atk3"
- };
- public static readonly string[] HurtSta = new string[]
- {
- "Fall",
- "FallHitGround",
- "FlyToFall",
- "GetUp",
- "Hit1",
- "HitToFly",
- "HitToFly2",
- "HitFall"
- };
- private static readonly string[] DieSta = new string[]
- {
- "Die",
- "DieQTE",
- "AirDie",
- "AirDieFlyToFall",
- "AirDieFall",
- "AirDieHitGround",
- "Execute",
- "ExecuteDie",
- "Null"
- };
- private static readonly string[] NormalSta = new string[]
- {
- "Idle",
- "Move"
- };
- private const float AirFric = 8f;
- public enum StateEnum
- {
- Atk1,
- Atk2,
- Atk3,
- Die,
- DieQTE,
- Fall,
- FallHitGround,
- FlyToFall,
- GetUp,
- Hit1,
- HitToFly,
- HitToFly2,
- Idle,
- Jump,
- Move,
- MoveAway,
- AirDie,
- AirDieFlyToFall,
- AirDieFall,
- AirDieHitGround,
- HitFall,
- Execute,
- ExecuteDie,
- Null
- }
- }
|