Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

52 lignes
1.4KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. class ActionJumpBy : ActionSequence
  7. {
  8. protected Vector3 point;
  9. float height;
  10. int jumps;
  11. public ActionJumpBy(Vector3 tgtPoint, float tgtHeight, int tgtJumps, float tgtDuration)
  12. : base(new ActionInstant[tgtJumps])
  13. {
  14. point = tgtPoint;
  15. jumps = tgtJumps;
  16. height = tgtHeight;
  17. duration = tgtDuration;
  18. }
  19. public ActionJumpBy(Vector2 tgtPoint, float tgtHeight, int tgtJumps, float tgtDuration)
  20. : this((Vector3)tgtPoint, tgtHeight, tgtJumps, tgtDuration)
  21. {
  22. is2d = true;
  23. }
  24. public override ActionInstant clone()
  25. {
  26. return new ActionJumpBy(point, height, jumps, duration);
  27. }
  28. public override ActionInstant reverse()
  29. {
  30. return new ActionJumpBy(-point, height, jumps, duration);
  31. }
  32. public override void start()
  33. {
  34. float coeff = 1F / jumps;
  35. Vector3 end = point * coeff;
  36. Vector3 cp1 = Vector3.up * height;
  37. Vector3 cp2 = end + cp1;
  38. ActionBezierRel singleJump = new ActionBezierRel(cp1, cp2, end, duration * coeff);
  39. for (int i = 0; i < jumps; i++)
  40. {
  41. actions[i] = singleJump;
  42. }
  43. base.start();
  44. }
  45. }
  46. }