using System; using UnityEngine; [Serializable] public class AMAnimationAction : AMAction { public override void execute(int frameRate, float delay, string trackId) { if (!this.amClip || !this.obj) { return; } AMTween.PlayAnimation(this.obj, AMTween.Hash(new object[] { "trackid", trackId, "delay", base.getWaitTime(frameRate, delay), "animation", this.amClip.name, "wrapmode", this.wrapMode, "crossfade", this.crossfade, "fadeLength", this.crossfadeTime })); } public override string ToString(int codeLanguage, int frameRate) { string text = string.Empty; if (!this.amClip) { return null; } if (codeLanguage == 0) { string text2 = text; text = string.Concat(new object[] { text2, "AMTween.PlayAnimation(obj.gameObject, AMTween.Hash (\"delay\", ", base.getWaitTime(frameRate, 0f), "f, \"animation\", \"", this.amClip.name, "\", \"wrapmode\", WrapMode.", this.wrapMode.ToString(), ",\"crossfade\", ", this.crossfade.ToString().ToLower() }); if (this.crossfade) { text = text + ", \"fadeLength\", " + this.crossfadeTime.ToString() + "f"; } text += "));"; } else { string text2 = text; text = string.Concat(new object[] { text2, "AMTween.PlayAnimation(obj.gameObject, {\"delay\": ", base.getWaitTime(frameRate, 0f), ", \"animation\": \"", this.amClip.name, "\", \"wrapmode\": WrapMode.", this.wrapMode.ToString(), ",\"crossfade\": ", this.crossfade.ToString().ToLower() }); if (this.crossfade) { text = text + ", \"fadeLength\": " + this.crossfadeTime.ToString(); } text += "});"; } return text; } public int getNumberOfFrames(int frameRate) { if (!this.amClip) { return -1; } if (this.wrapMode != WrapMode.Once) { return -1; } return Mathf.CeilToInt(this.amClip.length * (float)frameRate); } public override AnimatorTimeline.JSONAction getJSONAction(int frameRate) { if (!this.amClip || !this.obj) { return null; } return new AnimatorTimeline.JSONAction { method = "playanimation", go = this.obj.gameObject.name, delay = base.getWaitTime(frameRate, 0f), strings = new string[] { this.amClip.name }, floats = new float[] { (float)this.wrapMode, this.crossfadeTime }, bools = new bool[] { this.crossfade } }; } public AnimationClip amClip; public WrapMode wrapMode; public GameObject obj; public bool crossfade; public float crossfadeTime; }