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.

40 lines
933B

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. class ActionMoveBy : ActionInterval
  7. {
  8. protected Vector3 delta;
  9. public ActionMoveBy(Vector3 tgtDelta, float tgtDuration)
  10. : base(tgtDuration)
  11. {
  12. delta = tgtDelta;
  13. }
  14. public ActionMoveBy(Vector2 tgtValue, float tgtDuration)
  15. : this((Vector3)tgtValue, tgtDuration)
  16. {
  17. is2d = true;
  18. }
  19. public override ActionInstant clone()
  20. {
  21. return new ActionMoveBy(delta, duration);
  22. }
  23. public override ActionInstant reverse()
  24. {
  25. return new ActionMoveBy(delta * -1F, duration);
  26. }
  27. public override void stepInterval(float dt)
  28. {
  29. float d = dt / duration;
  30. Vector3 tgt = delta * d;
  31. transform.Translate(tgt, Space.World);
  32. }
  33. }
  34. }