FooterAction.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. using System;
  2. using System.Collections.Generic;
  3. using ExtensionMethods;
  4. using UnityEngine;
  5. public class FooterAction : EnemyBaseAction
  6. {
  7. static Dictionary<string, int> _003C_003Ef__switch_0024mapF;
  8. protected override void Start()
  9. {
  10. this.stateMachine.AddStates(typeof(FooterAction.StateEnum));
  11. this.stateMachine.OnEnter += this.OnMyStateEnter;
  12. this.stateMachine.OnTransfer += this.OnStateTransfer;
  13. base.AnimChangeState(FooterAction.StateEnum.Idle, 1f);
  14. }
  15. private void FixedUpdate()
  16. {
  17. if (this.stateMachine.currentState == "FlyToFall")
  18. {
  19. Vector2 currentSpeed = this.eAttr.timeController.GetCurrentSpeed();
  20. float f = currentSpeed.x;
  21. f = Mathf.Clamp(Mathf.Abs(f) - 8f * Time.fixedDeltaTime, 0f, float.MaxValue) * Mathf.Sign(f);
  22. currentSpeed.x = Mathf.Clamp(Mathf.Abs(f) - 8f * Time.fixedDeltaTime, 0f, float.PositiveInfinity) * Mathf.Sign(f);
  23. this.eAttr.timeController.SetSpeed(currentSpeed);
  24. }
  25. }
  26. protected override void Update()
  27. {
  28. base.Update();
  29. if (this.stateMachine.currentState == "FlyToFall")
  30. {
  31. Vector2 currentSpeed = this.eAttr.timeController.GetCurrentSpeed();
  32. if (currentSpeed.y > 0f)
  33. {
  34. currentSpeed.y = 0f;
  35. this.eAttr.timeController.SetSpeed(currentSpeed);
  36. }
  37. }
  38. if (this.stateMachine.currentState == "Atk1" || this.stateMachine.currentState == "Atk3")
  39. {
  40. this.eAttr.timeController.SetGravity(0f);
  41. }
  42. }
  43. private void OnStateTransfer(object sender, StateMachine.TransferEventArgs args)
  44. {
  45. base.GetComponent<EnemyBaseHurt>().StopFollowLeftHand();
  46. if (this.ExitAtkSta(args.lastState, args.nextState))
  47. {
  48. this.atkBox.localScale = Vector3.zero;
  49. }
  50. if (args.nextState == "FlyToFall")
  51. {
  52. Vector2 currentSpeed = this.eAttr.timeController.GetCurrentSpeed();
  53. currentSpeed.y = 0f;
  54. this.eAttr.timeController.SetSpeed(currentSpeed);
  55. this.eAttr.timeController.SetGravity(0f);
  56. }
  57. if (args.lastState == "FlyToFall" && !this.eAttr.willBeExecute)
  58. {
  59. this.eAttr.timeController.SetGravity(1f);
  60. }
  61. if (args.nextState.IsInArray(FooterAction.NormalSta))
  62. {
  63. this.hurtBox.localScale = Vector3.one;
  64. this.eAttr.timeController.SetGravity(1f);
  65. }
  66. }
  67. private void OnMyStateEnter(object sender, StateMachine.StateEventArgs args)
  68. {
  69. string state = args.state;
  70. if (state != null)
  71. {
  72. if (FooterAction._003C_003Ef__switch_0024mapF == null)
  73. {
  74. FooterAction._003C_003Ef__switch_0024mapF = new Dictionary<string, int>(24)
  75. {
  76. {
  77. "Atk1",
  78. 0
  79. },
  80. {
  81. "Atk2",
  82. 0
  83. },
  84. {
  85. "Atk3",
  86. 0
  87. },
  88. {
  89. "Die",
  90. 0
  91. },
  92. {
  93. "DieQTE",
  94. 0
  95. },
  96. {
  97. "FallHitGround",
  98. 0
  99. },
  100. {
  101. "FlyToFall",
  102. 0
  103. },
  104. {
  105. "GetUp",
  106. 0
  107. },
  108. {
  109. "Hit1",
  110. 0
  111. },
  112. {
  113. "HitToFly",
  114. 0
  115. },
  116. {
  117. "MoveAway",
  118. 0
  119. },
  120. {
  121. "AirDieFlyToFall",
  122. 0
  123. },
  124. {
  125. "AirDieHitGround",
  126. 0
  127. },
  128. {
  129. "ExecuteDie",
  130. 0
  131. },
  132. {
  133. "Null",
  134. 0
  135. },
  136. {
  137. "Jump",
  138. 0
  139. },
  140. {
  141. "HitToFly2",
  142. 1
  143. },
  144. {
  145. "Idle",
  146. 1
  147. },
  148. {
  149. "Move",
  150. 1
  151. },
  152. {
  153. "Fall",
  154. 1
  155. },
  156. {
  157. "AirDie",
  158. 1
  159. },
  160. {
  161. "AirDieFall",
  162. 1
  163. },
  164. {
  165. "HitFall",
  166. 1
  167. },
  168. {
  169. "Execute",
  170. 1
  171. }
  172. };
  173. }
  174. int num;
  175. if (FooterAction._003C_003Ef__switch_0024mapF.TryGetValue(state, out num))
  176. {
  177. if (num != 0)
  178. {
  179. if (num == 1)
  180. {
  181. this.spineAnim.Play(args.state, true, false, 1f);
  182. }
  183. }
  184. else
  185. {
  186. this.spineAnim.Play(args.state, false, true, 1f);
  187. }
  188. }
  189. }
  190. }
  191. public override void Attack1(int dir)
  192. {
  193. if (this.eAttr.isDead)
  194. {
  195. return;
  196. }
  197. if (!this.IsInNormalState())
  198. {
  199. return;
  200. }
  201. base.ChangeFace(dir);
  202. this.eAttr.timeController.SetGravity(0f);
  203. this.eAttr.timeController.SetSpeed(Vector2.zero);
  204. base.AnimChangeState(FooterAction.StateEnum.Atk1, 1f);
  205. }
  206. public override void Attack2(int dir)
  207. {
  208. if (this.eAttr.isDead)
  209. {
  210. return;
  211. }
  212. if (!this.IsInNormalState())
  213. {
  214. return;
  215. }
  216. base.ChangeFace(dir);
  217. base.AnimChangeState(FooterAction.StateEnum.Atk2, 1f);
  218. }
  219. public override void Attack3(int dir)
  220. {
  221. if (this.eAttr.isDead)
  222. {
  223. return;
  224. }
  225. if (!this.IsInNormalState())
  226. {
  227. return;
  228. }
  229. base.ChangeFace(dir);
  230. this.eAttr.timeController.SetGravity(0f);
  231. this.eAttr.timeController.SetSpeed(Vector2.zero);
  232. base.AnimChangeState(FooterAction.StateEnum.Atk3, 1f);
  233. }
  234. public override void CounterAttack(int dir)
  235. {
  236. if (this.eAttr.isDead)
  237. {
  238. return;
  239. }
  240. if (this.IsInAttackState())
  241. {
  242. return;
  243. }
  244. R.Effect.Generate(128, base.transform, Vector3.up * 1.5f, Vector3.zero, default(Vector3), true);
  245. base.ChangeFace(dir);
  246. this.eAttr.timeController.SetGravity(0f);
  247. this.eAttr.timeController.SetSpeed(Vector2.zero);
  248. base.AnimChangeState(FooterAction.StateEnum.Atk3, 1f);
  249. }
  250. public override void SideStep()
  251. {
  252. if (this.eAttr.isDead)
  253. {
  254. return;
  255. }
  256. if (this.IsInSideStepState())
  257. {
  258. return;
  259. }
  260. if (!this.eAttr.isOnGround)
  261. {
  262. return;
  263. }
  264. base.SideStep();
  265. this.eAttr.timeController.SetGravity(0f);
  266. this.eAttr.timeController.SetSpeed(Vector2.zero);
  267. base.AnimChangeState(FooterAction.StateEnum.MoveAway, 1f);
  268. }
  269. public void Jump()
  270. {
  271. if (this.eAttr.isDead)
  272. {
  273. return;
  274. }
  275. if (!this.IsInNormalState())
  276. {
  277. return;
  278. }
  279. this.eAttr.timeController.SetGravity(0f);
  280. this.eAttr.timeController.SetSpeed(Vector2.zero);
  281. base.AnimChangeState(FooterAction.StateEnum.Jump, 1f);
  282. }
  283. public override void AnimMove()
  284. {
  285. base.AnimChangeState(FooterAction.StateEnum.Move, 1f);
  286. }
  287. public override void AnimReady()
  288. {
  289. base.AnimChangeState(FooterAction.StateEnum.Idle, 1f);
  290. }
  291. public override bool IsInNormalState()
  292. {
  293. return this.stateMachine.currentState.IsInArray(FooterAction.NormalSta) && base.IsInNormalState();
  294. }
  295. public override bool IsInAttackState()
  296. {
  297. return this.stateMachine.currentState.IsInArray(FooterAction.AttackSta);
  298. }
  299. public override bool IsInDeadState(string state)
  300. {
  301. return state.IsInArray(FooterAction.DieSta);
  302. }
  303. public override bool IsInWeakSta()
  304. {
  305. return this.eAttr.inWeakState;
  306. }
  307. protected override bool EnterAtkSta(string lastState, string nextState)
  308. {
  309. return nextState.IsInArray(FooterAction.AttackSta) && !lastState.IsInArray(FooterAction.AttackSta);
  310. }
  311. protected override bool ExitAtkSta(string lastState, string nextState)
  312. {
  313. return !nextState.IsInArray(FooterAction.AttackSta) && lastState.IsInArray(FooterAction.AttackSta);
  314. }
  315. public override bool IsInSideStepState()
  316. {
  317. return this.stateMachine.currentState == "MoveAway";
  318. }
  319. public override bool IsInIdle()
  320. {
  321. return this.stateMachine.currentState == "Idle";
  322. }
  323. private static readonly string[] AttackSta = new string[]
  324. {
  325. "Atk1",
  326. "Atk2",
  327. "Atk3"
  328. };
  329. public static readonly string[] HurtSta = new string[]
  330. {
  331. "Fall",
  332. "FallHitGround",
  333. "FlyToFall",
  334. "GetUp",
  335. "Hit1",
  336. "HitToFly",
  337. "HitToFly2",
  338. "HitFall"
  339. };
  340. private static readonly string[] DieSta = new string[]
  341. {
  342. "Die",
  343. "DieQTE",
  344. "AirDie",
  345. "AirDieFlyToFall",
  346. "AirDieFall",
  347. "AirDieHitGround",
  348. "Execute",
  349. "ExecuteDie",
  350. "Null"
  351. };
  352. private static readonly string[] NormalSta = new string[]
  353. {
  354. "Idle",
  355. "Move"
  356. };
  357. private const float AirFric = 8f;
  358. public enum StateEnum
  359. {
  360. Atk1,
  361. Atk2,
  362. Atk3,
  363. Die,
  364. DieQTE,
  365. Fall,
  366. FallHitGround,
  367. FlyToFall,
  368. GetUp,
  369. Hit1,
  370. HitToFly,
  371. HitToFly2,
  372. Idle,
  373. Jump,
  374. Move,
  375. MoveAway,
  376. AirDie,
  377. AirDieFlyToFall,
  378. AirDieFall,
  379. AirDieHitGround,
  380. HitFall,
  381. Execute,
  382. ExecuteDie,
  383. Null
  384. }
  385. }