AMRotationAction.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using UnityEngine;
  3. [Serializable]
  4. public class AMRotationAction : AMAction
  5. {
  6. public override string ToString(int codeLanguage, int frameRate)
  7. {
  8. if (this.endFrame == -1)
  9. {
  10. return null;
  11. }
  12. string text;
  13. if (codeLanguage == 0)
  14. {
  15. text = string.Concat(new object[]
  16. {
  17. "AMTween.RotateTo (obj.gameObject, AMTween.Hash (\"delay\", ",
  18. base.getWaitTime(frameRate, 0f),
  19. "f, \"time\", ",
  20. this.getTime(frameRate),
  21. "f, "
  22. });
  23. string text2 = text;
  24. text = string.Concat(new object[]
  25. {
  26. text2,
  27. "\"rotation\", new Vector3(",
  28. this.endRotation.eulerAngles.x,
  29. "f, ",
  30. this.endRotation.eulerAngles.y,
  31. "f, ",
  32. this.endRotation.eulerAngles.z,
  33. "f), "
  34. });
  35. text = text + base.getEaseString(codeLanguage) + "));";
  36. }
  37. else
  38. {
  39. text = string.Concat(new object[]
  40. {
  41. "AMTween.RotateTo (obj.gameObject, {\"delay\": ",
  42. base.getWaitTime(frameRate, 0f),
  43. ", \"time\": ",
  44. this.getTime(frameRate),
  45. ", "
  46. });
  47. string text2 = text;
  48. text = string.Concat(new object[]
  49. {
  50. text2,
  51. "\"rotation\": Vector3(",
  52. this.endRotation.eulerAngles.x,
  53. ", ",
  54. this.endRotation.eulerAngles.y,
  55. ", ",
  56. this.endRotation.eulerAngles.z,
  57. "), "
  58. });
  59. text = text + base.getEaseString(codeLanguage) + "});";
  60. }
  61. return text;
  62. }
  63. public override int getNumberOfFrames()
  64. {
  65. return this.endFrame - this.startFrame;
  66. }
  67. public float getTime(int frameRate)
  68. {
  69. return (float)this.getNumberOfFrames() / (float)frameRate;
  70. }
  71. public override void execute(int frameRate, float delay, string trackId)
  72. {
  73. if (!this.obj)
  74. {
  75. return;
  76. }
  77. if (this.endFrame == -1)
  78. {
  79. return;
  80. }
  81. if (base.hasCustomEase())
  82. {
  83. AMTween.RotateTo(this.obj.gameObject, AMTween.Hash(new object[]
  84. {
  85. "trackid",
  86. trackId,
  87. "delay",
  88. base.getWaitTime(frameRate, delay),
  89. "time",
  90. this.getTime(frameRate),
  91. "rotation",
  92. this.endRotation.eulerAngles,
  93. "easecurve",
  94. base.easeCurve
  95. }));
  96. }
  97. else
  98. {
  99. AMTween.RotateTo(this.obj.gameObject, AMTween.Hash(new object[]
  100. {
  101. "trackid",
  102. trackId,
  103. "delay",
  104. base.getWaitTime(frameRate, delay),
  105. "time",
  106. this.getTime(frameRate),
  107. "rotation",
  108. this.endRotation.eulerAngles,
  109. "easetype",
  110. (AMTween.EaseType)this.easeType
  111. }));
  112. }
  113. }
  114. public Quaternion getStartQuaternion()
  115. {
  116. return this.startRotation;
  117. }
  118. public Quaternion getEndQuaternion()
  119. {
  120. return this.endRotation;
  121. }
  122. public override AnimatorTimeline.JSONAction getJSONAction(int frameRate)
  123. {
  124. if (!this.obj || this.endFrame == -1)
  125. {
  126. return null;
  127. }
  128. AnimatorTimeline.JSONAction jsonaction = new AnimatorTimeline.JSONAction();
  129. jsonaction.go = this.obj.gameObject.name;
  130. jsonaction.method = "rotateto";
  131. jsonaction.delay = base.getWaitTime(frameRate, 0f);
  132. jsonaction.time = this.getTime(frameRate);
  133. base.setupJSONActionEase(jsonaction);
  134. jsonaction.setPath(new Vector3[]
  135. {
  136. this.endRotation.eulerAngles
  137. });
  138. return jsonaction;
  139. }
  140. public int endFrame;
  141. public Transform obj;
  142. public Quaternion startRotation;
  143. public Quaternion endRotation;
  144. }