JetAffector.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using UnityEngine;
  3. namespace Xft
  4. {
  5. public class JetAffector : Affector
  6. {
  7. public JetAffector(float mag, MAGTYPE type, AnimationCurve curve, EffectNode node) : base(node, AFFECTORTYPE.JetAffector)
  8. {
  9. this.Mag = mag;
  10. this.MType = type;
  11. this.MagCurve = curve;
  12. }
  13. public override void Update(float deltaTime)
  14. {
  15. Vector3 b = Vector3.zero;
  16. if (this.MType == MAGTYPE.Fixed)
  17. {
  18. b = this.Node.Velocity.normalized * this.Mag * deltaTime;
  19. }
  20. else if (this.MType == MAGTYPE.Curve_OBSOLETE)
  21. {
  22. b = this.Node.Velocity.normalized * this.MagCurve.Evaluate(this.Node.GetElapsedTime());
  23. }
  24. else
  25. {
  26. b = this.Node.Velocity.normalized * this.Node.Owner.JetCurveX.Evaluate(this.Node.GetElapsedTime());
  27. }
  28. Vector3 vector = this.Node.Velocity + b;
  29. if (Vector3.Dot(vector, this.Node.Velocity) <= 0f)
  30. {
  31. this.Node.Velocity = Vector3.zero;
  32. return;
  33. }
  34. this.Node.Velocity = vector;
  35. }
  36. protected float Mag;
  37. protected MAGTYPE MType;
  38. protected AnimationCurve MagCurve;
  39. }
  40. }