Tween.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using UnityEngine;
  2. using UnityEngine.Events;
  3. using System;
  4. using System.Collections;
  5. public abstract class Tween
  6. {
  7. public virtual bool InOrigin
  8. {
  9. get { return _InOrigin; }
  10. set { _InOrigin = value; }
  11. }
  12. public virtual bool InDestination
  13. {
  14. get { return _InDestination; }
  15. set { _InDestination = value; }
  16. }
  17. protected bool _InOrigin;
  18. protected bool _InDestination;
  19. public bool InForward;
  20. public bool InBackward;
  21. public UnityAction OnForwardStart;
  22. public UnityAction OnForwardFinish;
  23. public UnityAction OnBackwardStart;
  24. public UnityAction OnBackwardFinish;
  25. public float Duration;
  26. protected float Timer;
  27. protected bool DestActive;
  28. protected bool OriginActive;
  29. public abstract bool DoForward();
  30. public abstract bool DoBackward();
  31. public void ConfineForward()
  32. {
  33. if (InOrigin)
  34. {
  35. StartForward();
  36. }
  37. }
  38. public void ConfineBackward()
  39. {
  40. if (InDestination)
  41. {
  42. StartBackward();
  43. }
  44. }
  45. public virtual void StartForward()
  46. {
  47. InForward = true;
  48. if (OnForwardStart != null)
  49. {
  50. OnForwardStart.Invoke();
  51. }
  52. ManaAnim.TweenForList.Add(this);
  53. ManaAnim.TweenBacList.Remove(this);
  54. }
  55. public virtual void StartBackward()
  56. {
  57. InBackward = true;
  58. if (OnBackwardStart != null)
  59. {
  60. OnBackwardStart.Invoke();
  61. }
  62. ManaAnim.TweenForList.Remove(this);
  63. ManaAnim.TweenBacList.Add(this);
  64. }
  65. }