RotateAffector.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using UnityEngine;
  3. namespace Xft
  4. {
  5. public class RotateAffector : Affector
  6. {
  7. public RotateAffector(RSTYPE type, EffectNode node) : base(node, AFFECTORTYPE.RotateAffector)
  8. {
  9. this.RType = type;
  10. }
  11. public RotateAffector(float delta, EffectNode node) : base(node, AFFECTORTYPE.RotateAffector)
  12. {
  13. this.RType = RSTYPE.SIMPLE;
  14. this.Delta = delta;
  15. }
  16. public override void Reset()
  17. {
  18. this.IsFirst = true;
  19. this.Node.RotateAngle = 0f;
  20. }
  21. public override void Update(float deltaTime)
  22. {
  23. if (this.IsFirst)
  24. {
  25. if (this.RType == RSTYPE.RANDOM)
  26. {
  27. this.Delta = UnityEngine.Random.Range(this.Node.Owner.RotateSpeedMin, this.Node.Owner.RotateSpeedMax);
  28. }
  29. else
  30. {
  31. this.Delta = this.Node.Owner.DeltaRot;
  32. }
  33. this.IsFirst = false;
  34. }
  35. float elapsedTime = this.Node.GetElapsedTime();
  36. if (this.RType == RSTYPE.CURVE)
  37. {
  38. this.Node.RotateAngle = (float)((int)this.Node.Owner.RotateCurve.Evaluate(elapsedTime));
  39. }
  40. else if (this.RType == RSTYPE.SIMPLE)
  41. {
  42. float rotateAngle = this.Node.RotateAngle + this.Delta * deltaTime;
  43. this.Node.RotateAngle = rotateAngle;
  44. }
  45. else if (this.RType == RSTYPE.RANDOM)
  46. {
  47. this.Node.RotateAngle = this.Node.RotateAngle + this.Delta * deltaTime;
  48. }
  49. else
  50. {
  51. float num = this.Node.Owner.RotateCurveTime;
  52. if (num < 0f)
  53. {
  54. num = this.Node.GetLifeTime();
  55. }
  56. float num2 = elapsedTime / num;
  57. if (num2 > 1f)
  58. {
  59. if (this.Node.Owner.RotateCurveWrap == WRAP_TYPE.CLAMP)
  60. {
  61. num2 = 1f;
  62. }
  63. else if (this.Node.Owner.RotateCurveWrap == WRAP_TYPE.LOOP)
  64. {
  65. int num3 = Mathf.FloorToInt(num2);
  66. num2 -= (float)num3;
  67. }
  68. else
  69. {
  70. int num4 = Mathf.CeilToInt(num2);
  71. int num5 = Mathf.FloorToInt(num2);
  72. if (num4 % 2 == 0)
  73. {
  74. num2 = (float)num4 - num2;
  75. }
  76. else
  77. {
  78. num2 -= (float)num5;
  79. }
  80. }
  81. }
  82. this.Node.RotateAngle = (float)((int)(this.Node.Owner.RotateCurve01.Evaluate(num2) * this.Node.Owner.RotateCurveMaxValue));
  83. }
  84. }
  85. protected RSTYPE RType;
  86. protected float Delta;
  87. protected bool IsFirst = true;
  88. }
  89. }