AMAnimationAction.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using UnityEngine;
  3. [Serializable]
  4. public class AMAnimationAction : AMAction
  5. {
  6. public override void execute(int frameRate, float delay, string trackId)
  7. {
  8. if (!this.amClip || !this.obj)
  9. {
  10. return;
  11. }
  12. AMTween.PlayAnimation(this.obj, AMTween.Hash(new object[]
  13. {
  14. "trackid",
  15. trackId,
  16. "delay",
  17. base.getWaitTime(frameRate, delay),
  18. "animation",
  19. this.amClip.name,
  20. "wrapmode",
  21. this.wrapMode,
  22. "crossfade",
  23. this.crossfade,
  24. "fadeLength",
  25. this.crossfadeTime
  26. }));
  27. }
  28. public override string ToString(int codeLanguage, int frameRate)
  29. {
  30. string text = string.Empty;
  31. if (!this.amClip)
  32. {
  33. return null;
  34. }
  35. if (codeLanguage == 0)
  36. {
  37. string text2 = text;
  38. text = string.Concat(new object[]
  39. {
  40. text2,
  41. "AMTween.PlayAnimation(obj.gameObject, AMTween.Hash (\"delay\", ",
  42. base.getWaitTime(frameRate, 0f),
  43. "f, \"animation\", \"",
  44. this.amClip.name,
  45. "\", \"wrapmode\", WrapMode.",
  46. this.wrapMode.ToString(),
  47. ",\"crossfade\", ",
  48. this.crossfade.ToString().ToLower()
  49. });
  50. if (this.crossfade)
  51. {
  52. text = text + ", \"fadeLength\", " + this.crossfadeTime.ToString() + "f";
  53. }
  54. text += "));";
  55. }
  56. else
  57. {
  58. string text2 = text;
  59. text = string.Concat(new object[]
  60. {
  61. text2,
  62. "AMTween.PlayAnimation(obj.gameObject, {\"delay\": ",
  63. base.getWaitTime(frameRate, 0f),
  64. ", \"animation\": \"",
  65. this.amClip.name,
  66. "\", \"wrapmode\": WrapMode.",
  67. this.wrapMode.ToString(),
  68. ",\"crossfade\": ",
  69. this.crossfade.ToString().ToLower()
  70. });
  71. if (this.crossfade)
  72. {
  73. text = text + ", \"fadeLength\": " + this.crossfadeTime.ToString();
  74. }
  75. text += "});";
  76. }
  77. return text;
  78. }
  79. public int getNumberOfFrames(int frameRate)
  80. {
  81. if (!this.amClip)
  82. {
  83. return -1;
  84. }
  85. if (this.wrapMode != WrapMode.Once)
  86. {
  87. return -1;
  88. }
  89. return Mathf.CeilToInt(this.amClip.length * (float)frameRate);
  90. }
  91. public override AnimatorTimeline.JSONAction getJSONAction(int frameRate)
  92. {
  93. if (!this.amClip || !this.obj)
  94. {
  95. return null;
  96. }
  97. return new AnimatorTimeline.JSONAction
  98. {
  99. method = "playanimation",
  100. go = this.obj.gameObject.name,
  101. delay = base.getWaitTime(frameRate, 0f),
  102. strings = new string[]
  103. {
  104. this.amClip.name
  105. },
  106. floats = new float[]
  107. {
  108. (float)this.wrapMode,
  109. this.crossfadeTime
  110. },
  111. bools = new bool[]
  112. {
  113. this.crossfade
  114. }
  115. };
  116. }
  117. public AnimationClip amClip;
  118. public WrapMode wrapMode;
  119. public GameObject obj;
  120. public bool crossfade;
  121. public float crossfadeTime;
  122. }