選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
このリポジトリはアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュや、課題・プルリクエストのオープンはできません。

51 行
1.4KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. /// <summary>
  7. /// Skews the object by the given angles.
  8. /// </summary>
  9. class ActionSkewBy : ActionInterval
  10. {
  11. protected Vector3 skewAngles1;
  12. protected Vector3 skewAngles2;
  13. protected Mesh mesh;
  14. public ActionSkewBy(Vector3 targetAngles1, Vector3 targetAngles2, float targetDuration)
  15. : base(targetDuration)
  16. {
  17. skewAngles1 = targetAngles1;
  18. skewAngles2 = targetAngles2;
  19. }
  20. public override ActionInstant Clone()
  21. {
  22. return new ActionSkewBy(skewAngles1, skewAngles2, duration);
  23. }
  24. public override ActionInstant Reverse()
  25. {
  26. return new ActionSkewBy(-skewAngles1, -skewAngles2, duration);
  27. }
  28. public override void Start()
  29. {
  30. base.Start();
  31. if (!(target is Actor))
  32. {
  33. throw new Exception("You should use Actor class instead of Actor, if you want to skew your object.");
  34. }
  35. }
  36. public override void Step(float dt)
  37. {
  38. float d = dt / duration;
  39. Vector3 target = skewAngles1 * d;
  40. ((Actor)target).skewAngles1 += target;
  41. target = skewAngles2 * d;
  42. ((Actor)target).skewAngles2 += target;
  43. }
  44. }
  45. }