EatingBossAction.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. using System;
  2. using System.Collections.Generic;
  3. using ExtensionMethods;
  4. using UnityEngine;
  5. public class EatingBossAction : EnemyBaseAction
  6. {
  7. static Dictionary<string, int> _003C_003Ef__switch_0024map2;
  8. protected override void Start()
  9. {
  10. this.stateMachine.AddStates(typeof(EatingBossAction.StateEnum));
  11. this.stateMachine.OnEnter += this.OnMyStateEnter;
  12. this.stateMachine.OnTransfer += this.OnStateTransfer;
  13. base.AnimChangeState(EatingBossAction.StateEnum.Idle, 1f);
  14. this.summonRate = (float)((R.GameData.Difficulty > 1) ? 45 : 15);
  15. }
  16. protected override void Update()
  17. {
  18. if (this.attack2Success)
  19. {
  20. Vector3 position = base.transform.position;
  21. R.Player.Transform.position = position.SetZ(LayerManager.ZNum.MMiddle_P);
  22. }
  23. this.summonRate += Time.deltaTime;
  24. this.UpdateHp();
  25. base.Update();
  26. }
  27. private void UpdateHp()
  28. {
  29. switch (R.GameData.Difficulty)
  30. {
  31. case 0:
  32. case 1:
  33. this.NormalModeHp();
  34. break;
  35. case 2:
  36. case 3:
  37. this.HardModeHp();
  38. break;
  39. }
  40. }
  41. private void NormalModeHp()
  42. {
  43. if (this.eAttr.currentHp < this.eAttr.maxHp * 75 / 100 && this.first75)
  44. {
  45. this.first75 = false;
  46. this.useAtk5 = true;
  47. }
  48. if (this.eAttr.currentHp >= this.eAttr.maxHp * 30 / 100 || !this.first30)
  49. {
  50. return;
  51. }
  52. this.first30 = false;
  53. this.useAtk5 = true;
  54. }
  55. private void HardModeHp()
  56. {
  57. if (this.eAttr.currentHp < this.eAttr.maxHp * 75 / 100 && this.first75)
  58. {
  59. this.first75 = false;
  60. this.useAtk5 = true;
  61. }
  62. if (this.eAttr.currentHp < this.eAttr.maxHp * 50 / 100 && this.first50)
  63. {
  64. this.first50 = false;
  65. this.useAtk5 = true;
  66. }
  67. if (this.eAttr.currentHp >= this.eAttr.maxHp * 25 / 100 || !this.first25)
  68. {
  69. return;
  70. }
  71. this.first25 = false;
  72. this.useAtk5 = true;
  73. }
  74. private void OnMyStateEnter(object sender, StateMachine.StateEventArgs args)
  75. {
  76. string state = args.state;
  77. if (state != null)
  78. {
  79. if (EatingBossAction._003C_003Ef__switch_0024map2 == null)
  80. {
  81. EatingBossAction._003C_003Ef__switch_0024map2 = new Dictionary<string, int>(20)
  82. {
  83. {
  84. "Atk1",
  85. 0
  86. },
  87. {
  88. "Atk2Ready",
  89. 0
  90. },
  91. {
  92. "Atk2",
  93. 0
  94. },
  95. {
  96. "Atk2SuccessEnd",
  97. 0
  98. },
  99. {
  100. "Atk2End",
  101. 0
  102. },
  103. {
  104. "Atk3",
  105. 0
  106. },
  107. {
  108. "Atk4",
  109. 0
  110. },
  111. {
  112. "Hit1",
  113. 0
  114. },
  115. {
  116. "Hit2",
  117. 0
  118. },
  119. {
  120. "HitQTE",
  121. 0
  122. },
  123. {
  124. "DieQTE",
  125. 0
  126. },
  127. {
  128. "IdleToWeakMod",
  129. 0
  130. },
  131. {
  132. "WeakModToIdle",
  133. 0
  134. },
  135. {
  136. "Atk5Ready",
  137. 0
  138. },
  139. {
  140. "Atk5End",
  141. 0
  142. },
  143. {
  144. "Atk2Success",
  145. 1
  146. },
  147. {
  148. "Atk5",
  149. 1
  150. },
  151. {
  152. "Idle",
  153. 1
  154. },
  155. {
  156. "Move",
  157. 1
  158. },
  159. {
  160. "WeakMod",
  161. 1
  162. }
  163. };
  164. }
  165. int num;
  166. if (EatingBossAction._003C_003Ef__switch_0024map2.TryGetValue(state, out num))
  167. {
  168. if (num != 0)
  169. {
  170. if (num == 1)
  171. {
  172. this.spineAnim.Play(args.state, true, false, 1f);
  173. }
  174. }
  175. else
  176. {
  177. this.spineAnim.Play(args.state, false, true, 1f);
  178. }
  179. }
  180. }
  181. }
  182. private void OnStateTransfer(object sender, StateMachine.TransferEventArgs args)
  183. {
  184. if (args.lastState == "Atk4" || args.lastState == "Atk5")
  185. {
  186. this.eAttr.timeController.SetGravity(1f);
  187. }
  188. if (args.nextState == "WeakMod")
  189. {
  190. R.Audio.PlayEffect(254, new Vector3?(base.transform.position));
  191. }
  192. if (this.ExitAtkSta(args.lastState, args.nextState) && this.attack2Success)
  193. {
  194. base.GetComponent<EatingBossAnimEvent>().Attack2Release();
  195. }
  196. }
  197. public override void Attack1(int dir)
  198. {
  199. this.summonRate = 0f;
  200. if (this.eAttr.isDead)
  201. {
  202. return;
  203. }
  204. if (!this.IsInNormalState())
  205. {
  206. return;
  207. }
  208. if (R.Enemy.Count >= 3)
  209. {
  210. return;
  211. }
  212. base.AnimChangeState(EatingBossAction.StateEnum.Atk1, 1f);
  213. }
  214. public override void Attack2(int dir)
  215. {
  216. if (this.eAttr.isDead)
  217. {
  218. return;
  219. }
  220. if (!this.IsInNormalState())
  221. {
  222. return;
  223. }
  224. base.ChangeFace(dir);
  225. base.AnimChangeState(EatingBossAction.StateEnum.Atk2Ready, 1f);
  226. }
  227. public void Attack2Success()
  228. {
  229. this.attack2Success = true;
  230. base.AnimChangeState(EatingBossAction.StateEnum.Atk2Success, 1f);
  231. }
  232. public override void Attack3(int dir)
  233. {
  234. if (this.eAttr.isDead)
  235. {
  236. return;
  237. }
  238. if (!this.IsInNormalState())
  239. {
  240. return;
  241. }
  242. base.ChangeFace(dir);
  243. base.AnimChangeState(EatingBossAction.StateEnum.Atk3, 1f);
  244. }
  245. public override void Attack4(int dir)
  246. {
  247. if (this.eAttr.isDead)
  248. {
  249. return;
  250. }
  251. if (!this.IsInNormalState())
  252. {
  253. return;
  254. }
  255. base.ChangeFace(dir);
  256. this.eAttr.timeController.SetSpeed(Vector2.zero);
  257. this.eAttr.timeController.SetGravity(0f);
  258. base.AnimChangeState(EatingBossAction.StateEnum.Atk4, 1f);
  259. }
  260. public override void Attack5(int dir)
  261. {
  262. if (this.eAttr.isDead)
  263. {
  264. return;
  265. }
  266. if (!this.IsInNormalState())
  267. {
  268. return;
  269. }
  270. base.ChangeFace(dir);
  271. this.eAttr.timeController.SetSpeed(Vector2.zero);
  272. this.eAttr.timeController.SetGravity(0f);
  273. base.AnimChangeState(EatingBossAction.StateEnum.Atk5Ready, 1f);
  274. }
  275. public override void CounterAttack(int dir)
  276. {
  277. if (this.eAttr.isDead)
  278. {
  279. return;
  280. }
  281. if (this.IsInAttackState())
  282. {
  283. return;
  284. }
  285. if (this.stateMachine.currentState.IsInArray(EatingBossAction.QTESta) || this.IsInWeakSta())
  286. {
  287. return;
  288. }
  289. R.Effect.Generate(128, base.transform, Vector3.up * 3.3f, Vector3.zero, default(Vector3), true);
  290. base.ChangeFace(dir);
  291. base.AnimChangeState(EatingBossAction.StateEnum.Atk3, 1f);
  292. }
  293. public override void AnimMove()
  294. {
  295. base.AnimChangeState(EatingBossAction.StateEnum.Move, 1f);
  296. }
  297. public override void AnimReady()
  298. {
  299. base.AnimChangeState(EatingBossAction.StateEnum.Idle, 1f);
  300. }
  301. public override bool IsInNormalState()
  302. {
  303. return this.stateMachine.currentState.IsInArray(EatingBossAction.NormalSta) && base.IsInNormalState();
  304. }
  305. public override bool IsInAttackState()
  306. {
  307. return this.stateMachine.currentState.IsInArray(EatingBossAction.AttackSta);
  308. }
  309. public override bool IsInDeadState(string state)
  310. {
  311. return state == "DieQTE";
  312. }
  313. public override bool IsInWeakSta()
  314. {
  315. return this.eAttr.inWeakState;
  316. }
  317. public override bool IsInIdle()
  318. {
  319. return this.stateMachine.currentState == "Idle";
  320. }
  321. protected override bool EnterAtkSta(string lastState, string nextState)
  322. {
  323. return nextState.IsInArray(EatingBossAction.AttackSta) && !lastState.IsInArray(EatingBossAction.AttackSta);
  324. }
  325. protected override bool ExitAtkSta(string lastState, string nextState)
  326. {
  327. return !nextState.IsInArray(EatingBossAction.AttackSta) && lastState.IsInArray(EatingBossAction.AttackSta);
  328. }
  329. public override void AnimQTEHurt()
  330. {
  331. int dir = (base.player.transform.localScale.x >= 0f) ? 1 : -1;
  332. base.ChangeFace(dir);
  333. base.ExitWeakState(true);
  334. Vector3 position = base.transform.position;
  335. position.y = LayerManager.YNum.GetGroundHeight(base.gameObject);
  336. position.z = LayerManager.ZNum.TempEnemy;
  337. base.transform.position = position;
  338. base.AnimChangeState(EatingBossAction.StateEnum.HitQTE, 1f);
  339. }
  340. public override void AnimExecute()
  341. {
  342. int dir = (base.player.transform.localScale.x >= 0f) ? 1 : -1;
  343. base.ChangeFace(dir);
  344. base.ExitWeakState(true);
  345. Vector3 position = base.transform.position;
  346. position.y = LayerManager.YNum.GetGroundHeight(base.gameObject);
  347. position.z = LayerManager.ZNum.TempEnemy;
  348. base.transform.position = position;
  349. base.AnimChangeState(EatingBossAction.StateEnum.DieQTE, 1f);
  350. }
  351. public bool useAtk5;
  352. private bool first75 = true;
  353. private bool first50 = true;
  354. private bool first30 = true;
  355. private bool first25 = true;
  356. public bool attack2Success;
  357. public float summonRate;
  358. private static readonly string[] NormalSta = new string[]
  359. {
  360. "Idle",
  361. "Move"
  362. };
  363. private static readonly string[] AttackSta = new string[]
  364. {
  365. "Atk1",
  366. "Atk2Ready",
  367. "Atk2",
  368. "Atk2Success",
  369. "Atk2SuccessEnd",
  370. "Atk2End",
  371. "Atk3",
  372. "Atk4",
  373. "Atk5Ready",
  374. "Atk5",
  375. "Atk5End"
  376. };
  377. private static readonly string[] QTESta = new string[]
  378. {
  379. "DieQTE",
  380. "HitQTE"
  381. };
  382. public enum StateEnum
  383. {
  384. Idle,
  385. Move,
  386. Atk1,
  387. Atk2Ready,
  388. Atk2,
  389. Atk2Success,
  390. Atk2SuccessEnd,
  391. Atk2End,
  392. Atk3,
  393. Atk4,
  394. DieQTE,
  395. Hit1,
  396. Hit2,
  397. HitQTE,
  398. IdleToWeakMod,
  399. WeakMod,
  400. WeakModToIdle,
  401. Atk5Ready,
  402. Atk5,
  403. Atk5End
  404. }
  405. public enum HurtSta
  406. {
  407. Hit1,
  408. Hit2,
  409. HitQTE
  410. }
  411. }