JumperFooterAnimEvent.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using System;
  2. using System.Collections;
  3. using GameWorld;
  4. using LitJson;
  5. using UnityEngine;
  6. public class JumperFooterAnimEvent : BaseBehaviour
  7. {
  8. private GameObject player
  9. {
  10. get
  11. {
  12. return R.Player.GameObject;
  13. }
  14. }
  15. private void Awake()
  16. {
  17. this._action = base.GetComponent<JumperFooterAction>();
  18. this._eAttr = base.GetComponent<EnemyAttribute>();
  19. this._enemyAtk = base.GetComponentInChildren<EnemyAtk>();
  20. }
  21. private void Start()
  22. {
  23. this._jsonData = SingletonMono<EnemyDataPreload>.Instance.attack[EnemyType.跳拳大脚组合];
  24. }
  25. public void ChangeState(JumperFooterAction.StateEnum sta)
  26. {
  27. this._action.AnimChangeState(sta, 1f);
  28. }
  29. public void SetAtkData()
  30. {
  31. this._enemyAtk.atkData = this._jsonData[this._action.stateMachine.currentState];
  32. this._enemyAtk.atkId = Incrementor.GetNextId();
  33. }
  34. public void Atk2Finish()
  35. {
  36. if (this._action.Atk2Success)
  37. {
  38. this._action.Atk2Result = true;
  39. this._action.AnimChangeState(JumperFooterAction.StateEnum.Atk2Success, 1f);
  40. }
  41. else
  42. {
  43. this._action.Atk2Result = false;
  44. this._action.AnimChangeState(JumperFooterAction.StateEnum.Atk2Fail, 1f);
  45. }
  46. }
  47. public void Atk2Release()
  48. {
  49. this._action.Atk2Success = false;
  50. R.Player.GetComponent<Collider2D>().enabled = false;
  51. R.Player.Transform.localRotation = Quaternion.identity;
  52. PlayerHurtAtkEventArgs args = new PlayerHurtAtkEventArgs(R.Player.GameObject, base.gameObject, base.gameObject, this._eAttr.atk, Incrementor.GetNextId(), this._jsonData["Atk2Release"], true);
  53. EventManager.PostEvent<Transform, PlayerHurtAtkEventArgs>("PlayerHurtAtk", base.transform, args);
  54. Vector3 position = base.transform.position;
  55. position.z = LayerManager.ZNum.MMiddleE(this._eAttr.rankType);
  56. base.transform.position = position;
  57. }
  58. public void Atk2FailEnd()
  59. {
  60. int num = UnityEngine.Random.Range(0, 100);
  61. if (num < 40)
  62. {
  63. this._action.Defence();
  64. }
  65. else
  66. {
  67. this._action.AnimChangeState(JumperFooterAction.StateEnum.Idle, 1f);
  68. }
  69. }
  70. public void BackToIdle()
  71. {
  72. if (this._action.IsInWeakSta())
  73. {
  74. this._eAttr.enterWeakMod = false;
  75. this._action.AnimChangeState(JumperFooterAction.StateEnum.HitToWeakMod, 1f);
  76. }
  77. else
  78. {
  79. this._action.AnimChangeState(JumperFooterAction.StateEnum.Idle, 1f);
  80. }
  81. }
  82. public IEnumerator WeakOver()
  83. {
  84. for (int i = 0; i < 75; i++)
  85. {
  86. if (this._action.stateMachine.currentState == "WeakMod" && !this._action.IsInWeakSta())
  87. {
  88. this._action.AnimChangeState(JumperFooterAction.StateEnum.WeakModToIdle, 1f);
  89. }
  90. yield return new WaitForFixedUpdate();
  91. }
  92. yield break;
  93. }
  94. public void DestroySelf()
  95. {
  96. base.Invoke("RealDestroy", 2f);
  97. base.gameObject.SetActive(false);
  98. }
  99. private void RealDestroy()
  100. {
  101. UnityEngine.Object.Destroy(base.gameObject);
  102. }
  103. public void QTEHurtShadeAtk()
  104. {
  105. Transform transform = R.Effect.Generate(177, null, base.transform.position, default(Vector3), default(Vector3), true);
  106. Vector3 one = Vector3.one;
  107. one.x *= (float)this._eAttr.faceDir;
  108. transform.localScale = one;
  109. }
  110. public void QTEHurtPlayerHitGround()
  111. {
  112. this.player.transform.position = base.transform.position + Vector3.up * 5f + Vector3.right * (float)this._eAttr.faceDir;
  113. int dir = InputSetting.JudgeDir(this.player.transform.position, base.transform.position);
  114. R.Player.Action.TurnRound(dir);
  115. R.Player.Action.ChangeState(PlayerAction.StateEnum.QTEHitGround, 1f);
  116. }
  117. public void QTEFinalHurt()
  118. {
  119. EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.QTEHurt);
  120. EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player, args);
  121. }
  122. public void QTEEffect()
  123. {
  124. EnemyBaseHurt component = base.GetComponent<EnemyBaseHurt>();
  125. component.HitEffect(component.center.localPosition, "Atk1");
  126. R.Audio.PlayEffect(257, new Vector3?(base.transform.position));
  127. }
  128. public void QTEHurtShadeAtkBack()
  129. {
  130. Transform transform = R.Effect.Generate(177, null, base.transform.position, default(Vector3), default(Vector3), true);
  131. Vector3 one = Vector3.one;
  132. one.x *= (float)(-(float)this._eAttr.faceDir);
  133. transform.localScale = one;
  134. }
  135. public void QTEDiePush()
  136. {
  137. R.Player.Action.ChangeState(PlayerAction.StateEnum.QTEPush, 1f);
  138. }
  139. public void ExecuteFinalHurt()
  140. {
  141. EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.Execute, string.Empty);
  142. EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.gameObject, args);
  143. }
  144. public void PlayAudio(int id)
  145. {
  146. R.Audio.PlayEffect(id, new Vector3?(base.transform.position));
  147. }
  148. private JumperFooterAction _action;
  149. private EnemyAttribute _eAttr;
  150. private EnemyAtk _enemyAtk;
  151. private JsonData _jsonData;
  152. }