SpiderAnimEvent.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using LitJson;
  3. using UnityEngine;
  4. public class SpiderAnimEvent : BaseBehaviour
  5. {
  6. private void Awake()
  7. {
  8. this._action = base.GetComponent<SpiderAction>();
  9. this._eAttr = base.GetComponent<EnemyAttribute>();
  10. this._enemyAtk = base.GetComponentInChildren<EnemyAtk>();
  11. }
  12. private void Start()
  13. {
  14. this._jsonData = SingletonMono<EnemyDataPreload>.Instance.attack[EnemyType.蜘蛛];
  15. }
  16. private void Update()
  17. {
  18. if (this._eAttr.isDead)
  19. {
  20. return;
  21. }
  22. if (this._eAttr.isFlyingUp)
  23. {
  24. bool flag = this.maxFlyHeight > 0f && this._eAttr.height >= this.maxFlyHeight;
  25. if (flag)
  26. {
  27. Vector2 currentSpeed = this._eAttr.timeController.GetCurrentSpeed();
  28. currentSpeed.y = 0f;
  29. this._eAttr.timeController.SetSpeed(currentSpeed);
  30. }
  31. if (this._eAttr.timeController.GetCurrentSpeed().y <= 0f)
  32. {
  33. this._eAttr.isFlyingUp = false;
  34. this._action.AnimChangeState(SpiderAction.StateEnum.FlyToFall, 1f);
  35. }
  36. }
  37. if (this._eAttr.checkHitGround && this._eAttr.isOnGround)
  38. {
  39. this._eAttr.checkHitGround = false;
  40. R.Effect.Generate(6, base.transform, default(Vector3), default(Vector3), default(Vector3), true);
  41. if (this._action.stateMachine.currentState == "HitFall")
  42. {
  43. this.maxFlyHeight = 4f;
  44. this._eAttr.timeController.SetSpeed(Vector2.up * 25f);
  45. this._action.AnimChangeState(SpiderAction.StateEnum.HitToFly1, 1f);
  46. }
  47. else
  48. {
  49. this._action.AnimChangeState(SpiderAction.StateEnum.FallHitGround, 1f);
  50. }
  51. }
  52. }
  53. public void ChangeState(SpiderAction.StateEnum sta)
  54. {
  55. this._action.AnimChangeState(sta, 1f);
  56. }
  57. public void HitGround()
  58. {
  59. this._eAttr.checkHitGround = true;
  60. }
  61. public void FlyUp()
  62. {
  63. this._eAttr.isFlyingUp = true;
  64. }
  65. public void SetAtkData()
  66. {
  67. this._enemyAtk.atkData = this._jsonData[this._action.stateMachine.currentState];
  68. this._enemyAtk.atkId = Incrementor.GetNextId();
  69. }
  70. public void GetUp()
  71. {
  72. if (this._eAttr.isDead)
  73. {
  74. this.DestroySelf();
  75. }
  76. else
  77. {
  78. this._action.AnimChangeState(SpiderAction.StateEnum.GetUp, 1f);
  79. }
  80. }
  81. public void DestroySelf()
  82. {
  83. base.Invoke("RealDestroy", 2f);
  84. base.gameObject.SetActive(false);
  85. }
  86. private void RealDestroy()
  87. {
  88. UnityEngine.Object.Destroy(base.gameObject);
  89. }
  90. public void DieBlock()
  91. {
  92. 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);
  93. }
  94. public void PlayAudio(int id)
  95. {
  96. R.Audio.PlayEffect(id, new Vector3?(base.transform.position));
  97. }
  98. public float maxFlyHeight;
  99. private SpiderAction _action;
  100. private EnemyAttribute _eAttr;
  101. private JsonData _jsonData;
  102. private EnemyAtk _enemyAtk;
  103. }