FooterAnimEvent.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System;
  2. using LitJson;
  3. using UnityEngine;
  4. public class FooterAnimEvent : BaseBehaviour
  5. {
  6. private void Awake()
  7. {
  8. this._action = base.GetComponent<FooterAction>();
  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(FooterAction.StateEnum.FlyToFall, 1f);
  35. }
  36. }
  37. if (this._eAttr.checkHitGround && this._eAttr.isOnGround)
  38. {
  39. this._eAttr.checkHitGround = false;
  40. if (this._action.stateMachine.currentState == "HitFall")
  41. {
  42. this.MaxFlyHeight = 4f;
  43. this._eAttr.timeController.SetSpeed(Vector2.up * 25f);
  44. this._action.AnimChangeState(FooterAction.StateEnum.HitToFly, 1f);
  45. }
  46. else
  47. {
  48. this._action.AnimChangeState(FooterAction.StateEnum.FallHitGround, 1f);
  49. }
  50. }
  51. }
  52. public void ChangeState(FooterAction.StateEnum sta)
  53. {
  54. this._action.AnimChangeState(sta, 1f);
  55. }
  56. public void FlyUp()
  57. {
  58. this._eAttr.isFlyingUp = true;
  59. }
  60. public void HitGround()
  61. {
  62. this._eAttr.checkHitGround = true;
  63. }
  64. public void GetUp()
  65. {
  66. if (!this._eAttr.isDead)
  67. {
  68. this._action.AnimChangeState(FooterAction.StateEnum.GetUp, 1f);
  69. }
  70. else
  71. {
  72. this.DestroySelf();
  73. }
  74. }
  75. public void BackToIdle()
  76. {
  77. this._action.AnimChangeState(FooterAction.StateEnum.Idle, 1f);
  78. }
  79. public void SetAtkData()
  80. {
  81. this._enemyAtk.atkData = this._jsonData[this._action.stateMachine.currentState];
  82. this._enemyAtk.atkId = Incrementor.GetNextId();
  83. }
  84. public void DieBlock()
  85. {
  86. 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);
  87. }
  88. public void DestroySelf()
  89. {
  90. this.RealDestroy();
  91. }
  92. private void RealDestroy()
  93. {
  94. UnityEngine.Object.Destroy(base.gameObject);
  95. }
  96. public void PlayAudio(int id)
  97. {
  98. R.Audio.PlayEffect(id, new Vector3?(base.transform.position));
  99. }
  100. public void PlayMoveAudio()
  101. {
  102. int id = this.moveAudio[UnityEngine.Random.Range(0, this.moveAudio.Length)];
  103. this.PlayAudio(id);
  104. }
  105. public void SpwanEffect()
  106. {
  107. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.footerEffect, base.transform.position + Vector3.back * 0.01f, Quaternion.identity);
  108. gameObject.GetComponent<SkeletonAnimation>().state.SetAnimation(0, this._action.stateMachine.currentState, false);
  109. gameObject.transform.localScale = base.transform.localScale;
  110. gameObject.AddComponent<AutoDestroy>();
  111. UnityEngine.Object.Destroy(gameObject.GetComponent<EnemyEffectSync>());
  112. }
  113. public float MaxFlyHeight;
  114. private FooterAction _action;
  115. private EnemyAttribute _eAttr;
  116. private EnemyAtk _enemyAtk;
  117. private JsonData _jsonData;
  118. [SerializeField]
  119. private int[] moveAudio;
  120. [SerializeField]
  121. private GameObject footerEffect;
  122. }