FaustAnimEvent.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using UnityEngine;
  3. public class FaustAnimEvent : BaseBehaviour
  4. {
  5. private void Awake()
  6. {
  7. this._eAttr = base.GetComponent<EnemyAttribute>();
  8. this._action = base.GetComponent<FaustAction>();
  9. }
  10. private void Update()
  11. {
  12. if (!this._start && this._eAttr.isOnGround)
  13. {
  14. this._startPos = base.transform.position;
  15. this._start = true;
  16. }
  17. }
  18. public void ChangeState(FaustAction.StateEnum sta)
  19. {
  20. this._action.AnimChangeState(sta, 1f);
  21. }
  22. public void Disappear()
  23. {
  24. base.Invoke("Appear", 0.75f);
  25. }
  26. public void Appear()
  27. {
  28. int disappearTimes = this._disappearTimes;
  29. if (disappearTimes != 0)
  30. {
  31. if (disappearTimes == 1)
  32. {
  33. base.transform.position = this._startPos + Vector3.right * 2f;
  34. this._call = true;
  35. }
  36. }
  37. else
  38. {
  39. base.transform.position = this._startPos + Vector3.left * 8f;
  40. this._disappearTimes++;
  41. }
  42. this._action.FaceToPlayer();
  43. this._action.AnimChangeState(FaustAction.StateEnum.Appear, 1f);
  44. }
  45. public void DestroySelf()
  46. {
  47. base.Invoke("RealDestroy", 2f);
  48. base.gameObject.SetActive(false);
  49. }
  50. private void RealDestroy()
  51. {
  52. UnityEngine.Object.Destroy(base.gameObject);
  53. }
  54. public void PlaySound(int id)
  55. {
  56. R.Audio.PlayEffect(id, new Vector3?(base.transform.position));
  57. }
  58. public void AppearEnd()
  59. {
  60. this._action.AnimChangeState((!this._call) ? FaustAction.StateEnum.Idle : FaustAction.StateEnum.IdleToCall, 1f);
  61. }
  62. private FaustAction _action;
  63. [SerializeField]
  64. private Vector3 _startPos;
  65. private bool _start;
  66. private EnemyAttribute _eAttr;
  67. private int _disappearTimes;
  68. private bool _call;
  69. }