Level56DahalDieTrigger.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Collections;
  3. using Core;
  4. using GameWorld;
  5. using UnityEngine;
  6. public class Level56DahalDieTrigger : BaseBehaviour
  7. {
  8. private Transform player
  9. {
  10. get
  11. {
  12. return R.Player.Transform;
  13. }
  14. }
  15. private void Start()
  16. {
  17. this.dahalDieFlag = false;
  18. this.dahalShotFlag = false;
  19. this.startCheckDahalShot = false;
  20. EventManager.RegisterEvent<EventArgs>("EnemyKilled", new EventManager.FBEventHandler<EventArgs>(this.DieEvent), EventManager.ListenerQueue.Game);
  21. }
  22. public void OnDestroy()
  23. {
  24. EventManager.UnregisterEvent<EventArgs>("EnemyKilled", new EventManager.FBEventHandler<EventArgs>(this.DieEvent), EventManager.ListenerQueue.Game);
  25. }
  26. private void Update()
  27. {
  28. if (!R.Player.Attribute.isDead && R.Player.Action.IsInNormalState() && this.player.position.x > 40f && this.player.position.x < 53f && !this.dahalShotFlag && this.startCheckDahalShot)
  29. {
  30. this.dahalShotFlag = true;
  31. this.DahalShot();
  32. }
  33. }
  34. private bool DieEvent(string eventName, object sender, EventArgs msg)
  35. {
  36. if (!this.dahalDieFlag)
  37. {
  38. this.dahalDieFlag = true;
  39. DahalAction component = R.Enemy.Boss.GetComponent<DahalAction>();
  40. component.DahalDie = true;
  41. EventManager.PostEvent<Level56DahalDieTrigger, BattleEventArgs>("Battle", this, BattleEventArgs.End);
  42. base.StartCoroutine(this.DieEventStart(component));
  43. }
  44. return true;
  45. }
  46. private IEnumerator DieEventStart(DahalAction dAction)
  47. {
  48. while (dAction.stateMachine.currentState == "QTEDie")
  49. {
  50. yield return null;
  51. }
  52. this.InputSet(false);
  53. R.Player.ActionController.ChangeState(PlayerAction.StateEnum.Idle);
  54. yield return new WaitForSeconds(0.5f);
  55. if (this.dahalDieEvent)
  56. {
  57. this.dahalDieEvent.SetActive(true);
  58. }
  59. yield return new WaitForSeconds(2f);
  60. this.startCheckDahalShot = true;
  61. yield break;
  62. }
  63. private void DahalShot()
  64. {
  65. if (this.dahalShotEvent)
  66. {
  67. this.dahalShotEvent.SetActive(true);
  68. this.InputSet(true);
  69. }
  70. }
  71. private void InputSet(bool open)
  72. {
  73. Core.Input.Game.Jump.IsOpen = open;
  74. Core.Input.Game.Flash.Down.IsOpen = open;
  75. Core.Input.Game.Flash.FaceDirection.IsOpen = open;
  76. Core.Input.Game.Flash.Left.IsOpen = open;
  77. Core.Input.Game.Flash.LeftDown.IsOpen = open;
  78. Core.Input.Game.Flash.LeftUp.IsOpen = open;
  79. Core.Input.Game.Flash.Right.IsOpen = open;
  80. Core.Input.Game.Flash.RightDown.IsOpen = open;
  81. Core.Input.Game.Flash.RightUp.IsOpen = open;
  82. Core.Input.Game.Flash.Up.IsOpen = open;
  83. }
  84. [Header("死亡飞走事件")]
  85. public GameObject dahalDieEvent;
  86. [Header("炸桥事件")]
  87. public GameObject dahalShotEvent;
  88. private bool dahalDieFlag;
  89. private bool dahalShotFlag;
  90. private bool startCheckDahalShot;
  91. }