123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- using System;
- using UnityEngine;
- [Serializable]
- public class AMTranslationAction : AMAction
- {
- public override string ToString(int codeLanguage, int frameRate)
- {
- if (this.path.Length <= 1)
- {
- return null;
- }
- if (this.getNumberOfFrames() <= 0)
- {
- return null;
- }
- string text;
- if (codeLanguage == 0)
- {
- text = string.Concat(new object[]
- {
- "AMTween.MoveTo (obj.gameObject, AMTween.Hash (\"delay\", ",
- base.getWaitTime(frameRate, 0f),
- "f, \"time\", ",
- this.getTime(frameRate),
- "f, "
- });
- if (this.path.Length == 2)
- {
- text += "\"position\", ";
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "new Vector3(",
- this.path[1].x,
- "f, ",
- this.path[1].y,
- "f, ",
- this.path[1].z,
- "f), "
- });
- }
- else
- {
- text += "\"path\", new Vector3[]{";
- for (int i = 0; i < this.path.Length; i++)
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "new Vector3(",
- this.path[i].x,
- "f, ",
- this.path[i].y,
- "f, ",
- this.path[i].z,
- "f)"
- });
- if (i < this.path.Length - 1)
- {
- text += ", ";
- }
- }
- text += "}, ";
- }
- text = text + base.getEaseString(codeLanguage) + "));";
- }
- else
- {
- text = string.Concat(new object[]
- {
- "AMTween.MoveTo (obj.gameObject, {\"delay\": ",
- base.getWaitTime(frameRate, 0f),
- ", \"time\": ",
- this.getTime(frameRate),
- ", "
- });
- if (this.path.Length == 2)
- {
- text += "\"position\": ";
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- " Vector3(",
- this.path[1].x,
- ", ",
- this.path[1].y,
- ", ",
- this.path[1].z,
- "), "
- });
- }
- else
- {
- text += "\"path\": [";
- for (int j = 0; j < this.path.Length; j++)
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- " Vector3(",
- this.path[j].x,
- ", ",
- this.path[j].y,
- ", ",
- this.path[j].z,
- ")"
- });
- if (j < this.path.Length - 1)
- {
- text += ", ";
- }
- }
- text += "], ";
- }
- text = text + base.getEaseString(codeLanguage) + "});";
- }
- return text;
- }
- public override int getNumberOfFrames()
- {
- return this.endFrame - this.startFrame;
- }
- public float getTime(int frameRate)
- {
- return (float)this.getNumberOfFrames() / (float)frameRate;
- }
- public override void execute(int frameRate, float delay, string trackId)
- {
- if (!this.obj)
- {
- return;
- }
- if (this.path.Length <= 1)
- {
- return;
- }
- if (this.getNumberOfFrames() <= 0)
- {
- return;
- }
- if (this.path.Length == 2)
- {
- if (base.hasCustomEase())
- {
- AMTween.MoveTo(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "position",
- this.path[1],
- "easecurve",
- base.easeCurve
- }));
- }
- else
- {
- AMTween.MoveTo(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "position",
- this.path[1],
- "easetype",
- (AMTween.EaseType)this.easeType
- }));
- }
- return;
- }
- if (base.hasCustomEase())
- {
- AMTween.MoveTo(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "path",
- this.path,
- "easecurve",
- base.easeCurve
- }));
- }
- else
- {
- AMTween.MoveTo(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "path",
- this.path,
- "easetype",
- (AMTween.EaseType)this.easeType
- }));
- }
- }
- public override AnimatorTimeline.JSONAction getJSONAction(int frameRate)
- {
- if (!this.obj)
- {
- return null;
- }
- if (this.path.Length <= 1)
- {
- return null;
- }
- if (this.getNumberOfFrames() <= 0)
- {
- return null;
- }
- AnimatorTimeline.JSONAction jsonaction = new AnimatorTimeline.JSONAction();
- jsonaction.go = this.obj.gameObject.name;
- jsonaction.method = "moveto";
- jsonaction.delay = base.getWaitTime(frameRate, 0f);
- jsonaction.time = this.getTime(frameRate);
- base.setupJSONActionEase(jsonaction);
- if (this.path.Length == 2)
- {
- jsonaction.setPath(new Vector3[]
- {
- this.path[1]
- });
- }
- else
- {
- jsonaction.setPath(this.path);
- }
- return jsonaction;
- }
- public int endFrame;
- public Transform obj;
- public Vector3[] path;
- }
|