private void SetPos(Transform trans, Ttype ttype, Vector3 pos)
        {
            switch (ttype)
            {
            case Ttype.Position:
                trans.position = pos;
                break;

            case Ttype.LocalPosition:
                trans.localPosition = pos;
                break;

            case Ttype.EulerAngles:
                trans.eulerAngles = pos;
                break;

            case Ttype.LocalEulerAngles:
                trans.localEulerAngles = pos;
                break;

            case Ttype.Scale:
                trans.localScale = pos;
                break;
            }
        }
        IEnumerator COTransform(Transform trans, Ttype ttype, Vector3 aVec, Vector3 bVec, float duration, float delay,
                                Easing.Type easingType, Action callback)
        {
            yield return(new WaitForSeconds(delay));

            float countTime = 0;
            float perc      = 0;
            float progress  = 0;

            while (countTime < duration)
            {
                countTime += Time.deltaTime;
                if (countTime > duration)
                {
                    countTime = duration;
                    break;
                }
                perc     = countTime / duration;
                progress = Easing.GetEasingFunction(easingType, perc);
                SetPos(trans, ttype, Vector3.Lerp(aVec, bVec, progress));
                yield return(null);
            }
            SetPos(trans, ttype, bVec);
            if (callback != null)
            {
                callback();
            }
            Destroy(this);
        }
        public static void Transform(Transform trans, Ttype ttype,
                                     Vector3 aVec, Vector3 bVec, float duration, float delay = 0,
                                     Easing.Type easingType = Easing.Type.Linear, Action callback = null)
        {
            Tweener tweener = trans.gameObject.AddComponent <Tweener>();

            tweener.TweenTransform(trans, ttype, aVec, bVec, duration, delay, easingType, callback);
        }
Пример #4
0
        public static int getID(Ttype t, string n)
        {
            Token newT = new Token(t, n);

            for (int i = 0; i < tokens.Count; i++)
            {
                if (tokens[i] == newT)
                {
                    return(i);
                }
            }
            tokens.Add(newT);
            return(tokens.Count - 1);
        }
Пример #5
0
 public static void TweenTranfrom(this Transform trans, Ttype ttype, Easing.Type easingType,
                                  Vector3 aVec, Vector3 bVec, float duration, float delay = 0, Action callback = null)
 {
     TweenExtensions.Transform(trans, ttype, aVec, bVec, duration, delay, easingType, callback);
 }
 public void TweenTransform(Transform trans, Ttype ttype, Vector3 aVec, Vector3 bVec, float duration, float delay,
                            Easing.Type easingType, Action callback)
 {
     StartCoroutine(COTransform(trans, ttype, aVec, bVec, duration, delay, easingType, callback));
 }
Пример #7
0
 public override int GetHashCode()
 {
     return(Num + NumStr.GetHashCode() + Ttype.GetHashCode() + Axis * 100);
 }
Пример #8
0
 public Token(Ttype t, string n)
 {
     ttype = t;
     name  = n;
 }