예제 #1
0
 public void AddNodule(TweenNodule nodule)
 {
     if (_nodules == null)
     {
         _nodules = new List <TweenNodule>();
     }
     _nodules.Add(nodule);
 }
예제 #2
0
        public static TweenNodule Vector4To(Vector4 p_startValue, Vector4 p_finalValue, float p_duration, TweenEase p_easeType, float p_delay, bool p_useUnityTime, Action <Vector4> p_callbackUpdate)
        {
            TweenNodule __temp = ATween.FloatTo(0, 1, p_duration, p_easeType, p_delay, p_useUnityTime, delegate(float newFloat)
            {
                p_callbackUpdate(Vector4.Lerp(p_startValue, p_finalValue, newFloat));
            });

            return(__temp);
        }
예제 #3
0
        public static TweenNodule ColorTo(Color p_startColor, Color p_finalColor, float p_duration, TweenEase p_easeType, float p_delay, bool p_useUnityTime, Action <Color> p_callbackUpdate)
        {
            TweenNodule __temp = ATween.FloatTo(0, 1, p_duration, p_easeType, p_delay, p_useUnityTime, delegate(float newFloat)
            {
                p_callbackUpdate(Color.Lerp(p_startColor, p_finalColor, newFloat));
            });

            return(__temp);
        }
예제 #4
0
        public static TweenNodule QuaternionTo(Quaternion p_startValue, Quaternion p_finalValue, float p_duration, TweenEase p_easeType, float p_delay, bool p_useUnityTime, Action <Quaternion> p_callbackUpdate)
        {
            TweenNodule nodule = ATween.FloatTo(0, 1, p_duration, p_easeType, p_delay, p_useUnityTime, delegate(float newFloat)
            {
                p_callbackUpdate(Quaternion.Lerp(p_startValue, p_finalValue, newFloat));
            });

            return(nodule);
        }
예제 #5
0
        public static TweenNodule RectTo(Rect p_startValue, Rect p_finalValue, float p_duration, TweenEase p_easeType, float p_delay, bool p_useUnityTime, Action <Rect> p_callbackUpdate)
        {
            TweenNodule __temp = ATween.FloatTo(0, 1, p_duration, p_easeType, p_delay, p_useUnityTime, delegate(float newFloat)
            {
                p_callbackUpdate(new Rect(
                                     Mathf.Lerp(p_startValue.x, p_finalValue.x, newFloat),
                                     Mathf.Lerp(p_startValue.y, p_finalValue.y, newFloat),
                                     Mathf.Lerp(p_startValue.width, p_finalValue.width, newFloat),
                                     Mathf.Lerp(p_startValue.height, p_finalValue.height, newFloat)
                                     ));
            });

            return(__temp);
        }
예제 #6
0
        private static TweenNodule FloatTo(float p_startValue, float p_finalValue, float p_duration, TweenEase p_easeType, float p_delay, bool p_useUnityTime, bool p_isLoop, Action <float> p_callbackUpdate)
        {
            TweenNodule __nodule = new TweenNodule();

            float __startValue    = p_startValue;
            float __counter       = 0f;
            float __timeNow       = Time.time;
            float __ableToStartIn = __timeNow + p_delay;

            __nodule.args   = new float[] { __counter };
            __nodule.onLoop = p_isLoop;

            if (p_useUnityTime)
            {
                __nodule.onResume += delegate()
                {
                    __nodule.args[1] = Time.realtimeSinceStartup;
                }
            }
            ;

            //Delegates the function that must be executed at each update
            __nodule.toDo += delegate()
            {
                if (__ableToStartIn <= Time.time)
                {
                    if (!__nodule.paused)
                    {
                        //Rescue variables from class
                        float ___counter = __nodule.args[0];

                        float __currentValue;

                        if (___counter < p_duration)
                        {
                            //Increment counter
                            if (!p_useUnityTime)
                            {
                                ___counter += Timer.realDeltaTime;
                            }
                            else
                            {
                                ___counter += Time.deltaTime;
                            }
                            float __normalizedTime = Mathf.Min(___counter / p_duration, 1f);

                            //Increment the returned value on callback depending on ease style
                            __currentValue = EaseMathsTween.GetTransaction(__startValue, p_finalValue, __normalizedTime, p_easeType);


                            //Call the callback
                            p_callbackUpdate(__currentValue);

                            //Save necessary vars into the class for further calculations
                            __nodule.args[0] = ___counter;
                        }
                        else
                        {
                            if (__nodule.onLoop)
                            {
                                __nodule.args[0] = 0;
                                __ableToStartIn  = Time.realtimeSinceStartup + p_delay;
                            }
                            else
                            {
                                __nodule.finished = true;
                            }
                        }
                    }
                }
            };

            CoreTween.aTweenInstance.AddNodule(__nodule);

            return(__nodule);
        }