You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

47 lines
975B

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionScaleBy : ActionInterval
  5. {
  6. protected Vector3 delta;
  7. protected Vector3 path;
  8. public ActionScaleBy(Vector3 tgtDelta, float tgtDuration)
  9. : base(tgtDuration)
  10. {
  11. delta = tgtDelta;
  12. }
  13. public override Action clone()
  14. {
  15. return new ActionScaleBy(delta, duration);
  16. }
  17. public override Action reverse()
  18. {
  19. return new ActionScaleBy(delta * -1F, duration);
  20. }
  21. public override void start()
  22. {
  23. base.start();
  24. Vector3 scale = transform.localScale;
  25. scale.x *= delta.x;
  26. scale.y *= delta.y;
  27. scale.z *= delta.z;
  28. path = scale - transform.localScale;
  29. }
  30. public override void stepInterval(float dt)
  31. {
  32. float d = dt / duration;
  33. Vector3 tgt = path * d;
  34. transform.localScale += tgt;
  35. }
  36. public override void stop()
  37. {
  38. base.stop();
  39. }
  40. }