123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- using System;
- using System.Collections.Generic;
- using ExtensionMethods;
- using UnityEngine;
- public class BladeGunAction : EnemyBaseAction
- {
- static Dictionary<string, int> _003C_003Ef__switch_0024mapC;
- protected override void Start()
- {
- this.stateMachine.AddStates(typeof(BladeGunAction.StateEnum));
- this.stateMachine.OnEnter += this.OnMyStateEnter;
- this.stateMachine.OnTransfer += this.OnStateTransfer;
- base.AnimChangeState(BladeGunAction.StateEnum.Idle, 1f);
- }
- private void FixedUpdate()
- {
- if (this.stateMachine.currentState != "FlyToFall")
- {
- return;
- }
- Vector2 currentSpeed = this.eAttr.timeController.GetCurrentSpeed();
- float f = currentSpeed.x;
- f = Mathf.Clamp(Mathf.Abs(f) - this.airFric * Time.fixedDeltaTime, 0f, float.MaxValue) * Mathf.Sign(f);
- currentSpeed.x = Mathf.Clamp(Mathf.Abs(f) - this.airFric * Time.fixedDeltaTime, 0f, float.PositiveInfinity) * Mathf.Sign(f);
- this.eAttr.timeController.SetSpeed(currentSpeed);
- }
- private void OnStateTransfer(object sender, StateMachine.TransferEventArgs args)
- {
- this.gun.mode = SkeletonUtilityBone.Mode.Follow;
- 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 == "Atk1")
- {
- this.eAttr.paBody = true;
- }
- if (args.lastState == "Atk1")
- {
- this.eAttr.paBody = false;
- }
- }
- private void OnMyStateEnter(object sender, StateMachine.StateEventArgs args)
- {
- string state = args.state;
- if (state != null)
- {
- if (BladeGunAction._003C_003Ef__switch_0024mapC == null)
- {
- BladeGunAction._003C_003Ef__switch_0024mapC = new Dictionary<string, int>(14)
- {
- {
- "Atk1End",
- 0
- },
- {
- "Atk1Ready",
- 0
- },
- {
- "Atk2",
- 0
- },
- {
- "Die",
- 0
- },
- {
- "FallHitGround",
- 0
- },
- {
- "FlyToFall",
- 0
- },
- {
- "Hit1",
- 0
- },
- {
- "HitToFly1",
- 0
- },
- {
- "Warning",
- 0
- },
- {
- "Fall",
- 1
- },
- {
- "HitFall",
- 1
- },
- {
- "HitToFly2",
- 1
- },
- {
- "Atk1",
- 1
- },
- {
- "Idle",
- 1
- }
- };
- }
- int num;
- if (BladeGunAction._003C_003Ef__switch_0024mapC.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 AnimMove()
- {
- if (this.stateMachine.currentState != "Atk1Ready" && this.stateMachine.currentState != "Atk1")
- {
- base.AnimChangeState(BladeGunAction.StateEnum.Atk1Ready, 1f);
- }
- else if (this.stateMachine.currentState == "Atk1")
- {
- base.AnimChangeState(BladeGunAction.StateEnum.Atk1, 1f);
- }
- }
- public override void Attack2(int dir)
- {
- if (this.eAttr.isDead)
- {
- return;
- }
- if (!this.IsInNormalState())
- {
- return;
- }
- base.ChangeFace(dir);
- base.AnimChangeState(BladeGunAction.StateEnum.Atk2, 1f);
- }
- public override void AnimReady()
- {
- base.AnimChangeState(BladeGunAction.StateEnum.Atk1End, 1f);
- }
- public override bool IsInNormalState()
- {
- return this.stateMachine.currentState.IsInArray(BladeGunAction.NormalSta) && base.IsInNormalState();
- }
- public override bool IsInAttackState()
- {
- return this.stateMachine.currentState == "Atk2";
- }
- public override bool IsInDeadState(string state)
- {
- return state == "Die";
- }
- public override bool IsInWeakSta()
- {
- return this.eAttr.inWeakState;
- }
- public override bool IsInIdle()
- {
- return this.stateMachine.currentState == "Idle";
- }
- protected override bool EnterAtkSta(string lastState, string nextState)
- {
- return nextState == "Atk2" && lastState != "Atk2";
- }
- protected override bool ExitAtkSta(string lastState, string nextState)
- {
- return nextState != "Atk2" && lastState == "Atk2";
- }
- public float airFric = 8f;
- [SerializeField]
- private SkeletonUtilityBone gun;
- private static readonly string[] NormalSta = new string[]
- {
- "Idle",
- "Atk1Ready",
- "Atk1",
- "Atk1End",
- "Warning"
- };
- public enum StateEnum
- {
- Idle,
- Atk1Ready,
- Atk1,
- Atk1End,
- Atk2,
- Die,
- Fall,
- FallHitGround,
- FlyToFall,
- Hit1,
- HitToFly1,
- HitToFly2,
- Warning,
- HitFall
- }
- public enum HurtSta
- {
- Fall,
- FallHitGround,
- FlyToFall,
- Hit1,
- HitToFly1,
- HitToFly2,
- HitFall
- }
- }
|