XCurveParam.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using UnityEngine;
  3. namespace Xft
  4. {
  5. [Serializable]
  6. public class XCurveParam
  7. {
  8. public float Evaluate(float time, EffectNode node)
  9. {
  10. float num = this.TimeLen;
  11. if (num < 0f)
  12. {
  13. num = node.GetLifeTime();
  14. }
  15. float num2 = time / num;
  16. if (num2 > 1f)
  17. {
  18. if (this.WrapType == WRAP_TYPE.CLAMP)
  19. {
  20. num2 = 1f;
  21. }
  22. else if (this.WrapType == WRAP_TYPE.LOOP)
  23. {
  24. int num3 = Mathf.FloorToInt(num2);
  25. num2 -= (float)num3;
  26. }
  27. else
  28. {
  29. int num4 = Mathf.CeilToInt(num2);
  30. int num5 = Mathf.FloorToInt(num2);
  31. if (num4 % 2 == 0)
  32. {
  33. num2 = (float)num4 - num2;
  34. }
  35. else
  36. {
  37. num2 -= (float)num5;
  38. }
  39. }
  40. }
  41. return this.Curve01.Evaluate(num2) * this.MaxValue;
  42. }
  43. public float Evaluate(float time)
  44. {
  45. float num = time / this.TimeLen;
  46. if (num > 1f)
  47. {
  48. if (this.WrapType == WRAP_TYPE.CLAMP)
  49. {
  50. num = 1f;
  51. }
  52. else if (this.WrapType == WRAP_TYPE.LOOP)
  53. {
  54. int num2 = Mathf.FloorToInt(num);
  55. num -= (float)num2;
  56. }
  57. else
  58. {
  59. int num3 = Mathf.CeilToInt(num);
  60. int num4 = Mathf.FloorToInt(num);
  61. if (num3 % 2 == 0)
  62. {
  63. num = (float)num3 - num;
  64. }
  65. else
  66. {
  67. num -= (float)num4;
  68. }
  69. }
  70. }
  71. return this.Curve01.Evaluate(num) * this.MaxValue;
  72. }
  73. [SerializeField]
  74. public float MaxValue = 1f;
  75. [SerializeField]
  76. public float TimeLen = 1f;
  77. [SerializeField]
  78. public WRAP_TYPE WrapType;
  79. [SerializeField]
  80. public AnimationCurve Curve01 = new AnimationCurve(new Keyframe[]
  81. {
  82. new Keyframe(0f, 0f),
  83. new Keyframe(1f, 1f)
  84. });
  85. }
  86. }