Last active
August 29, 2015 14:02
-
-
Save shinriyo/452c9c96ffbfdfc8653e to your computer and use it in GitHub Desktop.
It is sequence for LeanTween.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| /// <summary> | |
| /// Lean tween sequence. | |
| /// </summary> | |
| public class LeanTweenSequence | |
| { | |
| /// <summary> | |
| /// Moves the local x. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="xs">Xs.</param> | |
| /// <param name="times">Times.</param> | |
| public static void MoveLocalX (GameObject go, float[] xs, float[] times) | |
| { | |
| if (xs.Length != times.Length) | |
| { | |
| Debug.LogError ("xs and times are not same length!"); | |
| } | |
| CreateNextMoveLocalX (go, xs, times); | |
| } | |
| /// <summary> | |
| /// Creates the next move local x. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="xs">Xs.</param> | |
| /// <param name="times">Times.</param> | |
| private static void CreateNextMoveLocalX (GameObject go, float[] xs, float[] times) | |
| { | |
| LeanTween.moveLocalY (go, xs [0], times [0]).setOnComplete (() => { | |
| float[] tmpXs = RemoveIndices (xs, 0); | |
| float[] tmpTimes = RemoveIndices (times, 0); | |
| if (tmpXs.Length > 0) | |
| { | |
| CreateNextMoveLocalX (go, tmpXs, tmpTimes); | |
| } | |
| }); | |
| } | |
| /// <summary> | |
| /// Moves the local y. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="ys">Ys.</param> | |
| /// <param name="times">Times.</param> | |
| public static void MoveLocalY (GameObject go, float[] ys, float[] times) | |
| { | |
| if (ys.Length != times.Length) | |
| { | |
| Debug.LogError ("xs and times are not same length!"); | |
| } | |
| CreateNextMoveLocalY (go, ys, times); | |
| } | |
| /// <summary> | |
| /// Creates the next move local y. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="ys">Ys.</param> | |
| /// <param name="times">Times.</param> | |
| private static void CreateNextMoveLocalY (GameObject go, float[] ys, float[] times) | |
| { | |
| LeanTween.moveLocalX (go, ys [0], times [0]).setOnComplete (() => { | |
| float[] tmpYs = RemoveIndices (ys, 0); | |
| float[] tmpTimes = RemoveIndices (times, 0); | |
| if (tmpYs.Length > 0) | |
| { | |
| CreateNextMoveLocalY (go, tmpYs, tmpTimes); | |
| } | |
| }); | |
| } | |
| /// <summary> | |
| /// Moves the x. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="xs">Xs.</param> | |
| /// <param name="times">Times.</param> | |
| public static void MoveX (GameObject go, float[] xs, float[] times) | |
| { | |
| if (xs.Length != times.Length) | |
| { | |
| Debug.LogError ("xs and times are not same length!"); | |
| } | |
| CreateNextMoveX (go, xs, times); | |
| } | |
| /// <summary> | |
| /// Creates the next move x. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="xs">Xs.</param> | |
| /// <param name="times">Times.</param> | |
| private static void CreateNextMoveX (GameObject go, float[] xs, float[] times) | |
| { | |
| LeanTween.moveX (go, xs [0], times [0]).setOnComplete (() => { | |
| float[] tmpXs = RemoveIndices (xs, 0); | |
| float[] tmpTimes = RemoveIndices (times, 0); | |
| if (tmpXs.Length > 0) | |
| { | |
| CreateNextMoveX (go, tmpXs, tmpTimes); | |
| } | |
| }); | |
| } | |
| /// <summary> | |
| /// Moves the y. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="ys">Ys.</param> | |
| /// <param name="times">Times.</param> | |
| public static void MoveY (GameObject go, float[] ys, float[] times) | |
| { | |
| if (ys.Length != times.Length) | |
| { | |
| Debug.LogError ("xs and times are not same length!"); | |
| } | |
| CreateNextMoveY (go, ys, times); | |
| } | |
| /// <summary> | |
| /// Creates the next move y. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="ys">Ys.</param> | |
| /// <param name="times">Times.</param> | |
| private static void CreateNextMoveY (GameObject go, float[] ys, float[] times) | |
| { | |
| LeanTween.moveY (go, ys [0], times [0]).setOnComplete (() => { | |
| float[] tmpYs = RemoveIndices (ys, 0); | |
| float[] tmpTimes = RemoveIndices (times, 0); | |
| if (tmpYs.Length > 0) | |
| { | |
| CreateNextMoveY (go, tmpYs, tmpTimes); | |
| } | |
| }); | |
| } | |
| /// <summary> | |
| /// Moves the local. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="vecs">Vecs.</param> | |
| /// <param name="times">Times.</param> | |
| public static void MoveLocal (GameObject go, Vector3[] vecs, float[] times) | |
| { | |
| if (vecs.Length != times.Length) | |
| { | |
| Debug.LogError ("xs and times are not same length!"); | |
| } | |
| CreateNextMoveLocal (go, vecs, times); | |
| } | |
| /// <summary> | |
| /// Creates the next move local. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="vecs">Vecs.</param> | |
| /// <param name="times">Times.</param> | |
| private static void CreateNextMoveLocal (GameObject go, Vector3[] vecs, float[] times) | |
| { | |
| LeanTween.moveLocal (go, vecs [0], times [0]).setOnComplete (() => { | |
| Vector3[] tmpVecs = RemoveIndices (vecs, 0); | |
| float[] tmpTimes = RemoveIndices (times, 0); | |
| if (tmpVecs.Length > 0) | |
| { | |
| CreateNextMoveLocal (go, tmpVecs, tmpTimes); | |
| } | |
| }); | |
| } | |
| /// <summary> | |
| /// Move the specified go, vecs and times. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="vecs">Vecs.</param> | |
| /// <param name="times">Times.</param> | |
| public static void Move (GameObject go, Vector3[] vecs, float[] times) | |
| { | |
| if (vecs.Length != times.Length) | |
| { | |
| Debug.LogError ("xs and times are not same length!"); | |
| } | |
| CreateNextMove (go, vecs, times); | |
| } | |
| /// <summary> | |
| /// Creates the next move. | |
| /// </summary> | |
| /// <param name="go">Go.</param> | |
| /// <param name="vecs">Vecs.</param> | |
| /// <param name="times">Times.</param> | |
| private static void CreateNextMove (GameObject go, Vector3[] vecs, float[] times) | |
| { | |
| LeanTween.moveLocal (go, vecs [0], times [0]).setOnComplete (() => { | |
| Vector3[] tmpVecs = RemoveIndices (vecs, 0); | |
| float[] tmpTimes = RemoveIndices (times, 0); | |
| if (tmpVecs.Length > 0) | |
| { | |
| CreateNextMove (go, tmpVecs, tmpTimes); | |
| } | |
| }); | |
| } | |
| /// <summary> | |
| /// Removes the indices. | |
| /// </summary> | |
| /// <returns>The indices.</returns> | |
| /// <param name="IndicesArray">Indices array.</param> | |
| /// <param name="RemoveAt">Remove at.</param> | |
| private static float[] RemoveIndices (float[] IndicesArray, int RemoveAt) | |
| { | |
| float[] newIndicesArray = new float[IndicesArray.Length - 1]; | |
| int i = 0; | |
| int j = 0; | |
| while (i < IndicesArray.Length) | |
| { | |
| if (i != RemoveAt) | |
| { | |
| newIndicesArray [j] = IndicesArray [i]; | |
| j++; | |
| } | |
| i++; | |
| } | |
| return newIndicesArray; | |
| } | |
| private static Vector3[] RemoveIndices (Vector3[] IndicesArray, int RemoveAt) | |
| { | |
| Vector3[] newIndicesArray = new Vector3[IndicesArray.Length - 1]; | |
| int i = 0; | |
| int j = 0; | |
| while (i < IndicesArray.Length) | |
| { | |
| if (i != RemoveAt) | |
| { | |
| newIndicesArray [j] = IndicesArray [i]; | |
| j++; | |
| } | |
| i++; | |
| } | |
| return newIndicesArray; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment