BombKillerAnimEvent.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System;
  2. using GameWorld;
  3. using LitJson;
  4. using UnityEngine;
  5. public class BombKillerAnimEvent : BaseBehaviour
  6. {
  7. private void Awake()
  8. {
  9. this._action = base.GetComponent<BombKillerAction>();
  10. this._eAttr = base.GetComponent<EnemyAttribute>();
  11. }
  12. private void Start()
  13. {
  14. this._jsonData = SingletonMono<EnemyDataPreload>.Instance.attack[EnemyType.半身自爆];
  15. }
  16. private void Update()
  17. {
  18. if (this._eAttr.isFlyingUp)
  19. {
  20. bool flag = this.maxFlyHeight > 0f && this._eAttr.height >= this.maxFlyHeight;
  21. if (flag)
  22. {
  23. Vector2 currentSpeed = this._eAttr.timeController.GetCurrentSpeed();
  24. currentSpeed.y = 0f;
  25. this._eAttr.timeController.SetSpeed(currentSpeed);
  26. }
  27. if (this._eAttr.timeController.GetCurrentSpeed().y <= 0f)
  28. {
  29. this._eAttr.isFlyingUp = false;
  30. this._action.AnimChangeState(BombKillerAction.StateEnum.FlyToFall, 1f);
  31. }
  32. }
  33. if (this._eAttr.checkHitGround && this._eAttr.isOnGround)
  34. {
  35. this._eAttr.checkHitGround = false;
  36. R.Effect.Generate(6, base.transform, default(Vector3), default(Vector3), default(Vector3), true);
  37. if (this._action.stateMachine.currentState == "HitFall")
  38. {
  39. this.maxFlyHeight = 4f;
  40. this._eAttr.timeController.SetSpeed(Vector2.up * 25f);
  41. this._action.AnimChangeState(BombKillerAction.StateEnum.HitToFly1, 1f);
  42. }
  43. else
  44. {
  45. this._action.AnimChangeState(BombKillerAction.StateEnum.HitGround, 1f);
  46. }
  47. }
  48. }
  49. public void ChangeState(BombKillerAction.StateEnum sta)
  50. {
  51. this._action.AnimChangeState(sta, 1f);
  52. }
  53. public void HitGround()
  54. {
  55. this._eAttr.checkHitGround = true;
  56. }
  57. public void FlyUp()
  58. {
  59. this._eAttr.isFlyingUp = true;
  60. }
  61. public void GetUp()
  62. {
  63. if (this._eAttr.isDead)
  64. {
  65. this.DieBlock();
  66. this.DestroySelf();
  67. }
  68. else
  69. {
  70. this._action.AnimChangeState(BombKillerAction.StateEnum.GetUp, 1f);
  71. }
  72. }
  73. public void BackToIdle()
  74. {
  75. if (this._action.IsInWeakSta())
  76. {
  77. this._eAttr.enterWeakMod = false;
  78. }
  79. this._action.AnimChangeState(BombKillerAction.StateEnum.Idle, 1f);
  80. }
  81. public void PlaySound(int id)
  82. {
  83. R.Audio.PlayEffect(id, new Vector3?(base.transform.position));
  84. }
  85. public void DieBlock()
  86. {
  87. R.Effect.Generate(163, null, new Vector3(base.transform.position.x, base.transform.position.y, base.transform.position.z - 0.1f), Vector3.zero, default(Vector3), true);
  88. }
  89. public void Atk1DieMessage()
  90. {
  91. EventManager.PostEvent<EnemyAttribute>("EnemyKilled", this._eAttr);
  92. }
  93. public void DestroySelf()
  94. {
  95. base.Invoke("RealDestroy", Time.deltaTime);
  96. base.gameObject.SetActive(false);
  97. }
  98. private void RealDestroy()
  99. {
  100. UnityEngine.Object.Destroy(base.gameObject);
  101. }
  102. public void SetAtkData()
  103. {
  104. base.GetComponentInChildren<EnemyAtk>().atkId = Incrementor.GetNextId();
  105. base.GetComponentInChildren<EnemyAtk>().atkData = this._jsonData[this._action.stateMachine.currentState];
  106. }
  107. public void Atk1Finish()
  108. {
  109. if (this._action.atk1Success)
  110. {
  111. this._action.AnimChangeState(BombKillerAction.StateEnum.Atk1Success, 1f);
  112. }
  113. else
  114. {
  115. this._action.AnimChangeState(BombKillerAction.StateEnum.Atk1Fail, 1f);
  116. }
  117. }
  118. public void Atk1FollowOver()
  119. {
  120. this._action.atk1Success = false;
  121. }
  122. public void GenerateExplosion_Atk1()
  123. {
  124. PlayerHurtAtkEventArgs args = new PlayerHurtAtkEventArgs(R.Player.GameObject, base.gameObject, base.gameObject, this._eAttr.atk, Incrementor.GetNextId(), this._jsonData["Atk1Ready"], true);
  125. EventManager.PostEvent<Transform, PlayerHurtAtkEventArgs>("PlayerHurtAtk", base.transform, args);
  126. }
  127. public void GenerateExplosionEffectNoDamage()
  128. {
  129. Transform transform = R.Effect.Generate(162, base.transform, Vector2.up * 1.2f, Vector3.zero, Vector3.one * 0.4f, true);
  130. UnityEngine.Object.Destroy(transform.GetChild(1).gameObject);
  131. }
  132. public void GenerateExplosionEffect()
  133. {
  134. Transform transform = R.Effect.Generate(162, base.transform, Vector2.up * 1.2f, default(Vector3), default(Vector3), true);
  135. EnemyBullet componentInChildren = transform.GetComponentInChildren<EnemyBullet>();
  136. componentInChildren.SetAtkData(this._jsonData[this._action.stateMachine.currentState]);
  137. componentInChildren.damage = this._eAttr.atk;
  138. componentInChildren.origin = null;
  139. }
  140. private BombKillerAction _action;
  141. private EnemyAttribute _eAttr;
  142. public float maxFlyHeight;
  143. private JsonData _jsonData;
  144. }