123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- using System;
- using System.Runtime.CompilerServices;
- using UnityEngine;
- [Serializable]
- public class AMOrientationAction : AMAction
- {
- public override string ToString(int codeLanguage, int frameRate)
- {
- if (this.endFrame == -1 || !this.startTarget)
- {
- return null;
- }
- string text;
- if (this.isLookFollow())
- {
- if (codeLanguage == 0)
- {
- text = string.Concat(new object[]
- {
- "AMTween.LookFollow (obj.gameObject, AMTween.Hash (\"delay\", ",
- base.getWaitTime(frameRate, 0f),
- "f, \"time\", ",
- this.getTime(frameRate),
- "f, "
- });
- text = text + "\"looktarget\", GameObject.Find(\"" + this.startTarget.gameObject.name + "\").transform";
- text += "));";
- }
- else
- {
- text = string.Concat(new object[]
- {
- "AMTween.LookFollow (obj.gameObject, {\"delay\": ",
- base.getWaitTime(frameRate, 0f),
- ", \"time\": ",
- this.getTime(frameRate),
- ", "
- });
- text = text + "\"looktarget\": GameObject.Find(\"" + this.startTarget.gameObject.name + "\").transform";
- text += "});";
- }
- return text;
- }
- if (!this.endTarget)
- {
- return null;
- }
- if (codeLanguage == 0)
- {
- text = string.Concat(new object[]
- {
- "AMTween.LookToFollow (obj.gameObject, AMTween.Hash (\"delay\", ",
- base.getWaitTime(frameRate, 0f),
- "f, \"time\", ",
- this.getTime(frameRate),
- "f, "
- });
- text = text + "\"looktarget\", GameObject.Find(\"" + this.endTarget.gameObject.name + "\").transform, ";
- if (this.isSetEndPosition)
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "\"endposition\", new Vector3(",
- this.endPosition.x,
- "f, ",
- this.endPosition.y,
- "f, ",
- this.endPosition.z,
- "f), "
- });
- }
- text += base.getEaseString(codeLanguage);
- text += "));";
- }
- else
- {
- text = string.Concat(new object[]
- {
- "AMTween.LookToFollow (obj.gameObject, {\"delay\": ",
- base.getWaitTime(frameRate, 0f),
- ", \"time\": ",
- this.getTime(frameRate),
- ", "
- });
- text = text + "\"looktarget\": GameObject.Find(\"" + this.endTarget.gameObject.name + "\").transform, ";
- if (this.isSetEndPosition)
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "\"endposition\", Vector3(",
- this.endPosition.x,
- ", ",
- this.endPosition.y,
- ", ",
- this.endPosition.z,
- "), "
- });
- }
- text += base.getEaseString(codeLanguage);
- text += "});";
- }
- return text;
- }
- public override void execute(int frameRate, float delay, string trackId)
- {
- if (!this.obj)
- {
- return;
- }
- if (this.endFrame == -1)
- {
- return;
- }
- if (this.isLookFollow())
- {
- AMTween.LookFollow(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "looktarget",
- this.startTarget
- }));
- }
- else if (base.hasCustomEase())
- {
- AMTween.LookToFollow(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "looktarget",
- this.endTarget,
- "endposition",
- (!this.isSetEndPosition) ? null : new Vector3?(this.endPosition),
- "easecurve",
- base.easeCurve
- }));
- }
- else
- {
- AMTween.LookToFollow(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "looktarget",
- this.endTarget,
- "endposition",
- (!this.isSetEndPosition) ? null : new Vector3?(this.endPosition),
- "easetype",
- (AMTween.EaseType)this.easeType
- }));
- }
- }
- public override int getNumberOfFrames()
- {
- return this.endFrame - this.startFrame;
- }
- public float getTime(int frameRate)
- {
- return (float)this.getNumberOfFrames() / (float)frameRate;
- }
- public bool isLookFollow()
- {
- return !(this.startTarget != this.endTarget);
- }
- public Quaternion getQuaternionAtPercent(float percentage, Vector3? startVector = null, Vector3? endVector = null)
- {
- if (this.isLookFollow())
- {
- this.obj.LookAt(this.startTarget);
- return this.obj.rotation;
- }
- Vector3 position = this.obj.position;
- if (this.isSetStartPosition)
- {
- this.obj.position = this.startPosition;
- }
- this.obj.LookAt((startVector == null) ? this.startTarget.position : startVector.Value);
- Vector3 eulerAngles = this.obj.eulerAngles;
- if (this.isSetEndPosition)
- {
- this.obj.position = this.endPosition;
- }
- this.obj.LookAt((endVector == null) ? this.endTarget.position : endVector.Value);
- Vector3 eulerAngles2 = this.obj.eulerAngles;
- this.obj.position = position;
- eulerAngles2 = new Vector3(AMTween.clerp(eulerAngles.x, eulerAngles2.x, 1f), AMTween.clerp(eulerAngles.y, eulerAngles2.y, 1f), AMTween.clerp(eulerAngles.z, eulerAngles2.z, 1f));
- Vector3 euler = default(Vector3);
- AnimationCurve curve = null;
- AMTween.EasingFunction easingFunction;
- if (base.hasCustomEase())
- {
- curve = base.easeCurve;
- if (AMOrientationAction.<>f__mg$cache0 == null)
- {
- AMOrientationAction.<>f__mg$cache0 = new AMTween.EasingFunction(AMTween.customEase);
- }
- easingFunction = AMOrientationAction.<>f__mg$cache0;
- }
- else
- {
- easingFunction = AMTween.GetEasingFunction((AMTween.EaseType)this.easeType);
- }
- euler.x = easingFunction(eulerAngles.x, eulerAngles2.x, percentage, curve);
- euler.y = easingFunction(eulerAngles.y, eulerAngles2.y, percentage, curve);
- euler.z = easingFunction(eulerAngles.z, eulerAngles2.z, percentage, curve);
- return Quaternion.Euler(euler);
- }
- public override AnimatorTimeline.JSONAction getJSONAction(int frameRate)
- {
- if (!this.obj || this.endFrame == -1)
- {
- return null;
- }
- AnimatorTimeline.JSONAction jsonaction = new AnimatorTimeline.JSONAction();
- jsonaction.go = this.obj.gameObject.name;
- jsonaction.delay = base.getWaitTime(frameRate, 0f);
- jsonaction.time = this.getTime(frameRate);
- if (this.isLookFollow())
- {
- jsonaction.method = "lookfollow";
- jsonaction.strings = new string[]
- {
- this.startTarget.gameObject.name
- };
- }
- else
- {
- jsonaction.method = "looktofollow";
- jsonaction.strings = new string[]
- {
- this.endTarget.gameObject.name
- };
- if (this.isSetEndPosition)
- {
- jsonaction.setPath(new Vector3[]
- {
- this.endPosition
- });
- }
- }
- base.setupJSONActionEase(jsonaction);
- return jsonaction;
- }
- public int endFrame;
- public Transform obj;
- public Transform startTarget;
- public Transform endTarget;
- public bool isSetStartPosition;
- public bool isSetEndPosition;
- public Vector3 startPosition;
- public Vector3 endPosition;
- [CompilerGenerated]
- private static AMTween.EasingFunction <>f__mg$cache0;
- }
|