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.

39 lines
908B

  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. }
  18. public override ActionInstant clone()
  19. {
  20. return new ActionMoveBy(delta, duration);
  21. }
  22. public override ActionInstant reverse()
  23. {
  24. return new ActionMoveBy(delta * -1F, duration);
  25. }
  26. public override void stepInterval(float dt)
  27. {
  28. float d = dt / duration;
  29. Vector3 tgt = delta * d;
  30. transform.Translate(tgt, Space.World);
  31. }
  32. }
  33. }