RiderGunAnimEvent.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. using System;
  2. using System.Collections;
  3. using GameWorld;
  4. using LitJson;
  5. using UnityEngine;
  6. public class RiderGunAnimEvent : BaseBehaviour
  7. {
  8. private Transform player
  9. {
  10. get
  11. {
  12. return R.Player.Transform;
  13. }
  14. }
  15. private void Start()
  16. {
  17. this._action = base.GetComponent<RiderGunAction>();
  18. this._eAttr = base.GetComponent<EnemyAttribute>();
  19. this._atk = base.GetComponentInChildren<EnemyAtk>();
  20. this._atkData = SingletonMono<EnemyDataPreload>.Instance.attack[EnemyType.骑兵改];
  21. this._atk2LoopTimes = 2;
  22. }
  23. public void ChangeState(RiderGunAction.StateEnum sta)
  24. {
  25. this._action.AnimChangeState(sta, 1f);
  26. }
  27. public void Atk2End()
  28. {
  29. this._atk2LoopTimes--;
  30. if (this._atk2LoopTimes <= 0)
  31. {
  32. this._atk2LoopTimes = 2;
  33. this._action.AnimChangeState(RiderGunAction.StateEnum.Atk2End, 1f);
  34. }
  35. }
  36. public void StartPabody()
  37. {
  38. this._eAttr.paBody = true;
  39. }
  40. public void EndPabody()
  41. {
  42. this._eAttr.paBody = false;
  43. }
  44. public void SetAtkData()
  45. {
  46. this._atk.atkData = this._atkData[this._action.stateMachine.currentState];
  47. }
  48. public void LunchBullet()
  49. {
  50. float num = Vector2.Angle(this.gunLunch.position - this.gun.position, Vector2.up);
  51. Transform transform = UnityEngine.Object.Instantiate<Transform>(this.bulletPrefab, this.gunLunch.position, Quaternion.identity);
  52. transform.localRotation = Quaternion.Euler(0f, 0f, (float)this._eAttr.faceDir * -num);
  53. transform.GetComponent<Rigidbody2D>().velocity = (this.gunLunch.position - this.gun.position).normalized * 20f;
  54. EnemyBullet component = transform.GetComponent<EnemyBullet>();
  55. component.damage = this._eAttr.atk;
  56. component.origin = base.gameObject;
  57. component.SetAtkData(this._atkData["GunAtk2Ready"]);
  58. }
  59. public void SpwanEffect()
  60. {
  61. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.atkEffect, base.transform.position + Vector3.back * 0.01f, Quaternion.identity);
  62. gameObject.GetComponent<SkeletonAnimation>().state.SetAnimation(0, this._action.stateMachine.currentState, false);
  63. gameObject.transform.localScale = base.transform.localScale;
  64. gameObject.AddComponent<AutoDestroy>();
  65. UnityEngine.Object.Destroy(gameObject.GetComponent<EnemyEffectSync>());
  66. }
  67. public void PlaySound(int index)
  68. {
  69. R.Audio.PlayEffect(index, new Vector3?(base.transform.position));
  70. }
  71. public void PlayMoveSound()
  72. {
  73. R.Audio.PlayEffect(this.moveSound[UnityEngine.Random.Range(0, this.moveSound.Length)], new Vector3?(base.transform.position));
  74. }
  75. public void DestroySelf()
  76. {
  77. base.Invoke("RealDestroy", 2f);
  78. base.gameObject.SetActive(false);
  79. }
  80. private void RealDestroy()
  81. {
  82. UnityEngine.Object.Destroy(base.gameObject);
  83. }
  84. public void BackToIdle()
  85. {
  86. if (this._action.IsInWeakSta())
  87. {
  88. this._eAttr.enterWeakMod = false;
  89. this._action.AnimChangeState(RiderAction.StateEnum.WeakMod, 1f);
  90. }
  91. else
  92. {
  93. this._action.AnimChangeState(RiderAction.StateEnum.Ready, 1f);
  94. }
  95. }
  96. public IEnumerator WeakOver()
  97. {
  98. for (int i = 0; i < 116; i++)
  99. {
  100. if (this._action.stateMachine.currentState == "WeakMod" && !this._action.IsInWeakSta())
  101. {
  102. this._action.AnimChangeState(RiderAction.StateEnum.Ready, 1f);
  103. }
  104. yield return new WaitForFixedUpdate();
  105. }
  106. yield break;
  107. }
  108. public void QTECameraZoomIn()
  109. {
  110. R.Camera.Controller.CameraZoom(base.transform.position + Vector3.up * 3f, 0.2f, 3f);
  111. R.Camera.Controller.CameraShake(0.2f, 0.4f, CameraController.ShakeTypeEnum.Rect, false);
  112. R.Camera.Controller.OpenMotionBlur(0.13333334f, 1f, base.transform.position);
  113. }
  114. public void QTEFinalHurt()
  115. {
  116. EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.QTEHurt);
  117. EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.gameObject, args);
  118. }
  119. public void QTEPlyerAttack()
  120. {
  121. R.Player.Action.ChangeState(PlayerAction.StateEnum.RiderQTEHurt_2, 1f);
  122. }
  123. public void QTEPlayerBack()
  124. {
  125. R.Player.Action.ChangeState(PlayerAction.StateEnum.EndAtk, 1f);
  126. }
  127. public void ExecuteEffect()
  128. {
  129. EnemyBaseHurt component = base.GetComponent<EnemyBaseHurt>();
  130. component.HitEffect(component.center.localPosition, "Atk1");
  131. }
  132. public void ExecuteShadeAttack()
  133. {
  134. R.Effect.Generate(180, null, base.transform.position, default(Vector3), default(Vector3), true);
  135. }
  136. public void ExecutePlyerAttack()
  137. {
  138. Vector3 position = base.transform.position + Vector3.up * 2.1f;
  139. position.z = LayerManager.ZNum.MMiddle_P;
  140. this.player.position = position;
  141. R.Player.Action.ChangeState(PlayerAction.StateEnum.RiderQTEHurt_3, 2f);
  142. }
  143. public void ExecuteFinalHurt()
  144. {
  145. EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.Execute, string.Empty);
  146. EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.gameObject, args);
  147. }
  148. private RiderGunAction _action;
  149. private EnemyAttribute _eAttr;
  150. private int _atk2LoopTimes;
  151. private EnemyAtk _atk;
  152. private JsonData _atkData;
  153. [SerializeField]
  154. private Transform gun;
  155. [SerializeField]
  156. private Transform gunLunch;
  157. [SerializeField]
  158. private Transform bulletPrefab;
  159. [SerializeField]
  160. private GameObject atkEffect;
  161. [SerializeField]
  162. private int[] moveSound;
  163. }