StickerAnimEvent.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. using System;
  2. using System.Collections;
  3. using GameWorld;
  4. using LitJson;
  5. using UnityEngine;
  6. public class StickerAnimEvent : 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<StickerAction>();
  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(StickerAction.StateEnum sta)
  26. {
  27. this._action.AnimChangeState(sta, 1f);
  28. }
  29. public void SetAtkData()
  30. {
  31. this._enemyAtk.atkData = this._jsonData[base.GetComponent<StateMachine>().currentState];
  32. this._enemyAtk.atkId = Incrementor.GetNextId();
  33. }
  34. public void CameraShake(int frame)
  35. {
  36. R.Camera.Controller.CameraShake((float)frame / 60f, 0.2f, CameraController.ShakeTypeEnum.Vertical, false);
  37. }
  38. public void BackToIdle()
  39. {
  40. if (this._action.IsInWeakSta())
  41. {
  42. this._eAttr.enterWeakMod = false;
  43. this._action.AnimChangeState(StickerAction.StateEnum.IdleToWeakMod, 1f);
  44. }
  45. else
  46. {
  47. this._action.AnimChangeState(StickerAction.StateEnum.Idle, 1f);
  48. }
  49. }
  50. public IEnumerator WeakOver()
  51. {
  52. for (int i = 0; i < 115; i++)
  53. {
  54. if (this._action.stateMachine.currentState == "WeakMod" && !this._action.IsInWeakSta())
  55. {
  56. this._action.AnimChangeState(StickerAction.StateEnum.WeakModToIdle, 1f);
  57. }
  58. yield return new WaitForFixedUpdate();
  59. }
  60. yield break;
  61. }
  62. public void DestroySelf()
  63. {
  64. R.Enemy.RemoveEnemy(this._eAttr);
  65. base.gameObject.SetActive(false);
  66. base.Invoke("DestroyGameObject", Time.deltaTime);
  67. }
  68. private void DestroyGameObject()
  69. {
  70. UnityEngine.Object.Destroy(base.gameObject);
  71. }
  72. public void QTEHurtShadeAtk()
  73. {
  74. Transform transform = R.Effect.Generate(177, null, base.transform.position + Vector3.up * 2f, default(Vector3), default(Vector3), true);
  75. Vector3 one = Vector3.one;
  76. one.x *= (float)this._eAttr.faceDir;
  77. transform.localScale = one;
  78. }
  79. public void QTEHurtShadeAtkBack()
  80. {
  81. Transform transform = R.Effect.Generate(180, null, base.transform.position, default(Vector3), default(Vector3), true);
  82. Vector3 one = Vector3.one;
  83. one.x *= (float)this._eAttr.faceDir;
  84. transform.localScale = one;
  85. }
  86. public void QTEHitEffect()
  87. {
  88. R.Audio.PlayEffect(258, new Vector3?(base.transform.position));
  89. EnemyBaseHurt component = base.GetComponent<EnemyBaseHurt>();
  90. component.HitEffect(component.center.localPosition, "Atk1");
  91. R.Camera.Controller.CameraShake(0.166666672f, 0.2f, CameraController.ShakeTypeEnum.Rect, false);
  92. }
  93. public void PlayerRollAttack()
  94. {
  95. this.player.transform.position = base.transform.position + Vector3.up * 6f;
  96. R.Player.Action.ChangeState(PlayerAction.StateEnum.QTERoll, 1f);
  97. this.player.GetComponent<PlayerTimeController>().SetSpeed(Vector2.left * (float)this._eAttr.faceDir * 3f);
  98. R.Player.Rigidbody2D.gravityScale = 0.25f;
  99. }
  100. public void PlayerRollAttackEffect()
  101. {
  102. R.Audio.PlayEffect(258, new Vector3?(base.transform.position));
  103. EnemyBaseHurt component = base.GetComponent<EnemyBaseHurt>();
  104. component.HitEffect(this.player.transform.position - base.transform.position, "Atk1");
  105. R.Camera.Controller.CameraShake(0.06666667f, 0.2f, CameraController.ShakeTypeEnum.Rect, false);
  106. }
  107. public void QTEFinalHurt()
  108. {
  109. EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.QTEHurt);
  110. EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player, args);
  111. }
  112. public void PlayerBackToIdle()
  113. {
  114. R.Player.Action.ChangeState(PlayerAction.StateEnum.EndAtk, 0.5f);
  115. }
  116. public void QTEDieShadeAtk()
  117. {
  118. Transform transform = R.Effect.Generate(177, null, base.transform.position + Vector3.up * 1.5f, default(Vector3), default(Vector3), true);
  119. Vector3 one = Vector3.one;
  120. one.x *= (float)(-(float)this._eAttr.faceDir);
  121. transform.localScale = one;
  122. }
  123. public void WeaponFly()
  124. {
  125. R.Audio.PlayEffect(258, new Vector3?(base.transform.position));
  126. Transform transform = UnityEngine.Object.Instantiate<Transform>(this.weaponPrefab, this.rightHand.position, Quaternion.identity);
  127. transform.GetComponent<EnemyArm>().SetAngularSpeed((float)(-30 * this._eAttr.faceDir));
  128. }
  129. public void HeadFly()
  130. {
  131. Transform transform = UnityEngine.Object.Instantiate<Transform>(this.headPrefab, this.headPos.position, Quaternion.identity);
  132. transform.GetComponent<Rigidbody2D>().velocity = new Vector2((float)(-3 * this._eAttr.faceDir), 20f);
  133. transform.GetComponent<EnemyArm>().SetAngularSpeed((float)(50 * this._eAttr.faceDir));
  134. }
  135. public void CameraZoomIn()
  136. {
  137. R.Camera.Controller.CameraZoom(this.headPos.position, 0.166666672f, 3f);
  138. }
  139. public void PlayerRush()
  140. {
  141. this.player.transform.position += Vector3.up * 2.5f;
  142. R.Player.Action.ChangeState(PlayerAction.StateEnum.AirQTEPush, 1f);
  143. }
  144. public void Cameraback()
  145. {
  146. R.Camera.Controller.ZoomFinished();
  147. }
  148. public void ExecuteFinalHurt()
  149. {
  150. EnemyHurtAtkEventArgs args = new EnemyHurtAtkEventArgs(base.gameObject, EnemyHurtAtkEventArgs.HurtTypeEnum.Execute, string.Empty);
  151. EventManager.PostEvent<GameObject, EnemyHurtAtkEventArgs>("EnemyHurtAtk", this.player.gameObject, args);
  152. }
  153. public void PlayAudio(int id)
  154. {
  155. R.Audio.PlayEffect(id, new Vector3?(base.transform.position));
  156. }
  157. public void PlayMoveAudio()
  158. {
  159. int id = this.moveAudio[UnityEngine.Random.Range(0, this.moveAudio.Length)];
  160. this.PlayAudio(id);
  161. }
  162. public void PlayATK2Effect()
  163. {
  164. Transform transform = R.Effect.Generate(209, null, base.transform.position, default(Vector3), default(Vector3), true);
  165. Vector3 localScale = transform.localScale;
  166. localScale.x *= Mathf.Sign(base.transform.localScale.x);
  167. transform.localScale = localScale;
  168. EnemyBullet componentInChildren = transform.GetComponentInChildren<EnemyBullet>();
  169. componentInChildren.SetAtkData(this._jsonData["Atk2"]);
  170. componentInChildren.origin = base.gameObject;
  171. componentInChildren.damage = this._eAttr.atk;
  172. }
  173. private StickerAction _action;
  174. private EnemyAttribute _eAttr;
  175. private EnemyAtk _enemyAtk;
  176. private JsonData _jsonData;
  177. [SerializeField]
  178. private Transform rightHand;
  179. [SerializeField]
  180. private Transform headPos;
  181. [SerializeField]
  182. private Transform weaponPrefab;
  183. [SerializeField]
  184. private Transform headPrefab;
  185. [SerializeField]
  186. private Transform weaponPoint;
  187. [SerializeField]
  188. private int[] moveAudio;
  189. }