EffectAnimTimeController.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using UnityEngine;
  3. public class EffectAnimTimeController : BaseBehaviour
  4. {
  5. private void Start()
  6. {
  7. this.anim = base.GetComponent<Animator>();
  8. }
  9. private void OnEnable()
  10. {
  11. if (SingletonMono<WorldTime>.Instance != null)
  12. {
  13. SingletonMono<WorldTime>.Instance.FrozenEvent += this.ClipFrozen;
  14. SingletonMono<WorldTime>.Instance.ResumeEvent += this.ClipResume;
  15. }
  16. }
  17. private void OnDisable()
  18. {
  19. if (SingletonMono<WorldTime>.Instance != null)
  20. {
  21. SingletonMono<WorldTime>.Instance.FrozenEvent -= this.ClipFrozen;
  22. SingletonMono<WorldTime>.Instance.ResumeEvent -= this.ClipResume;
  23. }
  24. }
  25. private void OnDestroy()
  26. {
  27. }
  28. private void Update()
  29. {
  30. }
  31. public void SetSpeed(Vector2 speed)
  32. {
  33. if (this.isPause)
  34. {
  35. this.currentSpeed = speed;
  36. }
  37. else
  38. {
  39. base.GetComponent<Rigidbody2D>().velocity = speed;
  40. }
  41. }
  42. private void ClipFrozen(object obj, WorldTime.FrozenArgs e)
  43. {
  44. if (e.Type == WorldTime.FrozenArgs.FrozenType.Player)
  45. {
  46. return;
  47. }
  48. if (e.Type == WorldTime.FrozenArgs.FrozenType.Target && base.gameObject != e.Target)
  49. {
  50. return;
  51. }
  52. if (this.isPause)
  53. {
  54. return;
  55. }
  56. this.isPause = true;
  57. if (this.anim != null)
  58. {
  59. this.anim.speed = 0f;
  60. }
  61. }
  62. private void ClipResume(object obj, WorldTime.FrozenArgs e)
  63. {
  64. if (e.Type == WorldTime.FrozenArgs.FrozenType.Player)
  65. {
  66. return;
  67. }
  68. if (e.Type == WorldTime.FrozenArgs.FrozenType.Target && base.gameObject != e.Target)
  69. {
  70. return;
  71. }
  72. if (!this.isPause)
  73. {
  74. return;
  75. }
  76. this.currentSpeed = Vector2.zero;
  77. if (this.anim != null)
  78. {
  79. this.anim.speed = 1f;
  80. }
  81. this.isPause = false;
  82. }
  83. public void Pause()
  84. {
  85. }
  86. public void Resume()
  87. {
  88. }
  89. public Vector2 currentSpeed;
  90. [SerializeField]
  91. public bool isPause;
  92. public Animator anim;
  93. }