コード例 #1
0
        /// <summary>Send the tween to the given position in time</summary>
        /// <param name="to">Time position to reach
        /// (if higher than the whole tween duration the tween will simply reach its end)</param>
        /// <param name="andPlay">If TRUE will play the tween after reaching the given position, otherwise it will pause it</param>
        public static void Goto(this Tween t, float to, bool andPlay = false)
        {
            if (t == null)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogNullTween(t);
                }
                return;
            }
            else if (!t.active)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogInvalidTween(t);
                }
                return;
            }
            else if (t.isSequenced)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogInvalidTween(t);
                }
                return;
            }

            if (to < 0)
            {
                to = 0;
            }
            TweenManager.Goto(t, to, andPlay);
        }
コード例 #2
0
 public static void Goto(this Tween t, float to, bool andPlay = false)
 {
     if (t == null)
     {
         if (Debugger.logPriority > 1)
         {
             Debugger.LogNullTween(t);
         }
     }
     else if (!t.active)
     {
         if (Debugger.logPriority > 1)
         {
             Debugger.LogInvalidTween(t);
         }
     }
     else if (t.isSequenced)
     {
         if (Debugger.logPriority > 1)
         {
             Debugger.LogNestedTween(t);
         }
     }
     else
     {
         if (to < 0f)
         {
             to = 0f;
         }
         TweenManager.Goto(t, to, andPlay, UpdateMode.Goto);
     }
 }
コード例 #3
0
        // ===================================================================================
        // METHODS ---------------------------------------------------------------------------

        // Returns TRUE if the tween needs to be killed
        static bool ApplyInternalCycle(Sequence s, float fromPos, float toPos, UpdateMode updateMode, bool useInverse, bool prevPosIsInverse, bool multiCycleStep = false)
        {
            bool isBackwardsUpdate = toPos < fromPos;

//            Debug.Log(Time.frameCount + " " + s.id + " " + (multiCycleStep ? "<color=#FFEC03>Multicycle</color> > " : "Cycle > ") + s.position + "/" + s.duration + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + " - UpdateMode: " + updateMode + ", isPlaying: " + s.isPlaying + ", completedLoops: " + s.completedLoops);
            if (isBackwardsUpdate)
            {
                int len = s._sequencedObjs.Count - 1;
                for (int i = len; i > -1; --i)
                {
                    if (!s.active)
                    {
                        return(true);           // Killed by some internal callback
                    }
                    ABSSequentiable sequentiable = s._sequencedObjs[i];
                    if (sequentiable.sequencedEndPosition < toPos || sequentiable.sequencedPosition > fromPos)
                    {
                        continue;
                    }
                    if (sequentiable.tweenType == TweenType.Callback)
                    {
                        if (updateMode == UpdateMode.Update && prevPosIsInverse)
                        {
//                            Debug.Log("<color=#FFEC03>BACKWARDS Callback > " + s.id + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + "</color>");
                            OnTweenCallback(sequentiable.onStart);
                        }
                    }
                    else
                    {
                        // Nested Tweener/Sequence
                        float gotoPos = toPos - sequentiable.sequencedPosition;
//                        float gotoPos = (float)((decimal)toPos - (decimal)sequentiable.sequencedPosition);
                        if (gotoPos < 0)
                        {
                            gotoPos = 0;
                        }
                        Tween t = (Tween)sequentiable;
                        if (!t.startupDone)
                        {
                            continue;                 // since we're going backwards and this tween never started just ignore it
                        }
                        t.isBackwards = true;
                        if (TweenManager.Goto(t, gotoPos, false, updateMode))
                        {
                            return(true);
                        }

                        // Fixes nested callbacks not being called correctly if main sequence has loops and nested ones don't
                        if (multiCycleStep && t.tweenType == TweenType.Sequence)
                        {
                            if (s.position <= 0 && s.completedLoops == 0)
                            {
                                t.position = 0;
                            }
                            else
                            {
                                bool toZero = s.completedLoops == 0 || s.isBackwards && (s.completedLoops < s.loops || s.loops == -1);
                                if (t.isBackwards)
                                {
                                    toZero = !toZero;
                                }
                                if (useInverse)
                                {
                                    toZero = !toZero;
                                }
                                if (s.isBackwards && !useInverse && !prevPosIsInverse)
                                {
                                    toZero = !toZero;
                                }
                                t.position = toZero ? 0 : t.duration;
                            }
                        }
                    }
                }
            }
            else
            {
                int len = s._sequencedObjs.Count;
                for (int i = 0; i < len; ++i)
                {
                    if (!s.active)
                    {
                        return(true);           // Killed by some internal callback
                    }
                    ABSSequentiable sequentiable = s._sequencedObjs[i];
//                    if (sequentiable.sequencedPosition > toPos || sequentiable.sequencedEndPosition < fromPos) continue;
                    // Fix rare case with high FPS when a tween/callback might happen in same exact time as it's set
                    // This fixes it but should check for backwards tweens and loops
                    if (
                        sequentiable.sequencedPosition > toPos ||
                        sequentiable.sequencedPosition > 0 && sequentiable.sequencedEndPosition <= fromPos ||
                        sequentiable.sequencedPosition <= 0 && sequentiable.sequencedEndPosition < fromPos
                        )
                    {
                        continue;
                    }
                    if (sequentiable.tweenType == TweenType.Callback)
                    {
                        if (updateMode == UpdateMode.Update)
                        {
//                            Debug.Log("<color=#FFEC03>FORWARD Callback > " + s.id + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + "</color>");
                            bool fire = !s.isBackwards && !useInverse && !prevPosIsInverse ||
                                        s.isBackwards && useInverse && !prevPosIsInverse;
                            if (fire)
                            {
                                OnTweenCallback(sequentiable.onStart);
                            }
                        }
                    }
                    else
                    {
                        // Nested Tweener/Sequence
                        float gotoPos = toPos - sequentiable.sequencedPosition;
//                        float gotoPos = (float)((decimal)toPos - (decimal)sequentiable.sequencedPosition);
                        if (gotoPos < 0)
                        {
                            gotoPos = 0;
                        }
                        Tween t = (Tween)sequentiable;
                        // Fix for final nested tween not calling OnComplete in some cases
                        if (toPos >= sequentiable.sequencedEndPosition)
                        {
                            if (!t.startupDone)
                            {
                                TweenManager.ForceInit(t, true);
                            }
                            if (gotoPos < t.fullDuration)
                            {
                                gotoPos = t.fullDuration;
                            }
                        }
                        //
                        t.isBackwards = false;
                        if (TweenManager.Goto(t, gotoPos, false, updateMode))
                        {
                            return(true);
                        }

                        // Fixes nested callbacks not being called correctly if main sequence has loops and nested ones don't
                        if (multiCycleStep && t.tweenType == TweenType.Sequence)
                        {
                            if (s.position <= 0 && s.completedLoops == 0)
                            {
                                t.position = 0;
                            }
                            else
                            {
                                bool toZero = s.completedLoops == 0 || !s.isBackwards && (s.completedLoops < s.loops || s.loops == -1);
                                if (t.isBackwards)
                                {
                                    toZero = !toZero;
                                }
                                if (useInverse)
                                {
                                    toZero = !toZero;
                                }
                                if (s.isBackwards && !useInverse && !prevPosIsInverse)
                                {
                                    toZero = !toZero;
                                }
                                t.position = toZero ? 0 : t.duration;
                            }
                        }
                    }
                }
            }
            return(false);
        }
コード例 #4
0
        // Token: 0x06000074 RID: 116 RVA: 0x00003310 File Offset: 0x00001510
        public static void GotoWaypoint(this Tween t, int waypointIndex, bool andPlay = false)
        {
            if (t == null)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogNullTween(t);
                }
                return;
            }
            if (!t.active)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogInvalidTween(t);
                }
                return;
            }
            if (t.isSequenced)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogNestedTween(t);
                }
                return;
            }
            TweenerCore <Vector3, Path, PathOptions> tweenerCore = t as TweenerCore <Vector3, Path, PathOptions>;

            if (tweenerCore == null)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogNonPathTween(t);
                }
                return;
            }
            if (!t.startupDone)
            {
                TweenManager.ForceInit(t);
            }
            if (waypointIndex < 0)
            {
                waypointIndex = 0;
            }
            else if (waypointIndex > tweenerCore.changeValue.wps.Length - 1)
            {
                waypointIndex = tweenerCore.changeValue.wps.Length - 1;
            }
            float num = 0f;

            for (int i = 0; i < waypointIndex + 1; i++)
            {
                num += tweenerCore.changeValue.wpLengths[i];
            }
            float num2 = num / tweenerCore.changeValue.length;

            if (t.loopType == LoopType.Yoyo && ((t.position < t.duration) ? (t.completedLoops % 2 != 0) : (t.completedLoops % 2 == 0)))
            {
                num2 = 1f - num2;
            }
            float to = (float)(t.isComplete ? (t.completedLoops - 1) : t.completedLoops) * t.duration + num2 * t.duration;

            TweenManager.Goto(t, to, andPlay, UpdateMode.Goto);
        }
コード例 #5
0
 // Token: 0x06000097 RID: 151 RVA: 0x0000403C File Offset: 0x0000223C
 private static bool ApplyInternalCycle(Sequence s, float fromPos, float toPos, UpdateMode updateMode, bool useInverse, bool prevPosIsInverse, bool multiCycleStep = false)
 {
     if (toPos < fromPos)
     {
         for (int i = s._sequencedObjs.Count - 1; i > -1; i--)
         {
             if (!s.active)
             {
                 return(true);
             }
             ABSSequentiable abssequentiable = s._sequencedObjs[i];
             if (abssequentiable.sequencedEndPosition >= toPos && abssequentiable.sequencedPosition <= fromPos)
             {
                 if (abssequentiable.tweenType == TweenType.Callback)
                 {
                     if (updateMode == UpdateMode.Update && prevPosIsInverse)
                     {
                         Tween.OnTweenCallback(abssequentiable.onStart);
                     }
                 }
                 else
                 {
                     float num = toPos - abssequentiable.sequencedPosition;
                     if (num < 0f)
                     {
                         num = 0f;
                     }
                     Tween tween = (Tween)abssequentiable;
                     if (tween.startupDone)
                     {
                         tween.isBackwards = true;
                         if (TweenManager.Goto(tween, num, false, updateMode))
                         {
                             return(true);
                         }
                         if (multiCycleStep && tween.tweenType == TweenType.Sequence)
                         {
                             if (s.position <= 0f && s.completedLoops == 0)
                             {
                                 tween.position = 0f;
                             }
                             else
                             {
                                 bool flag = s.completedLoops == 0 || (s.isBackwards && (s.completedLoops < s.loops || s.loops == -1));
                                 if (tween.isBackwards)
                                 {
                                     flag = !flag;
                                 }
                                 if (useInverse)
                                 {
                                     flag = !flag;
                                 }
                                 if (s.isBackwards && !useInverse && !prevPosIsInverse)
                                 {
                                     flag = !flag;
                                 }
                                 tween.position = (flag ? 0f : tween.duration);
                             }
                         }
                     }
                 }
             }
         }
     }
     else
     {
         int count = s._sequencedObjs.Count;
         for (int j = 0; j < count; j++)
         {
             if (!s.active)
             {
                 return(true);
             }
             ABSSequentiable abssequentiable2 = s._sequencedObjs[j];
             if (abssequentiable2.sequencedPosition <= toPos && abssequentiable2.sequencedEndPosition >= fromPos)
             {
                 if (abssequentiable2.tweenType == TweenType.Callback)
                 {
                     if (updateMode == UpdateMode.Update && ((!s.isBackwards && !useInverse && !prevPosIsInverse) || (s.isBackwards && useInverse && !prevPosIsInverse)))
                     {
                         Tween.OnTweenCallback(abssequentiable2.onStart);
                     }
                 }
                 else
                 {
                     float num2 = toPos - abssequentiable2.sequencedPosition;
                     if (num2 < 0f)
                     {
                         num2 = 0f;
                     }
                     Tween tween2 = (Tween)abssequentiable2;
                     tween2.isBackwards = false;
                     if (TweenManager.Goto(tween2, num2, false, updateMode))
                     {
                         return(true);
                     }
                     if (multiCycleStep && tween2.tweenType == TweenType.Sequence)
                     {
                         if (s.position <= 0f && s.completedLoops == 0)
                         {
                             tween2.position = 0f;
                         }
                         else
                         {
                             bool flag2 = s.completedLoops == 0 || (!s.isBackwards && (s.completedLoops < s.loops || s.loops == -1));
                             if (tween2.isBackwards)
                             {
                                 flag2 = !flag2;
                             }
                             if (useInverse)
                             {
                                 flag2 = !flag2;
                             }
                             if (s.isBackwards && !useInverse && !prevPosIsInverse)
                             {
                                 flag2 = !flag2;
                             }
                             tween2.position = (flag2 ? 0f : tween2.duration);
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }
コード例 #6
0
        /// <summary>Send a path tween to the given waypoint.
        /// Has no effect if this is not a path tween.
        /// <para>BEWARE, this is a special utility method:
        /// it works only with Linear eases. Also, the lookAt direction might be wrong after calling this and might need to be set manually
        /// (because it relies on a smooth path movement and doesn't work well with jumps that encompass dramatic direction changes)</para></summary>
        /// <param name="waypointIndex">Waypoint index to reach
        /// (if higher than the max waypoint index the tween will simply go to the last one)</param>
        /// <param name="andPlay">If TRUE will play the tween after reaching the given waypoint, otherwise it will pause it</param>
        public static void GotoWaypoint(this Tween t, int waypointIndex, bool andPlay = false)
        {
            if (t == null)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogNullTween(t);
                }
                return;
            }
            else if (!t.active)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogInvalidTween(t);
                }
                return;
            }
            else if (t.isSequenced)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogNestedTween(t);
                }
                return;
            }

            TweenerCore <Vector3, Path, PathOptions> pathTween = t as TweenerCore <Vector3, Path, PathOptions>;

            if (pathTween == null)
            {
                if (Debugger.logPriority > 1)
                {
                    Debugger.LogNonPathTween(t);
                }
                return;
            }

            if (!t.startupDone)
            {
                TweenManager.ForceInit(t);                 // Initialize the tween if it's not initialized already (required)
            }
            if (waypointIndex < 0)
            {
                waypointIndex = 0;
            }
            else if (waypointIndex > pathTween.changeValue.wps.Length - 1)
            {
                waypointIndex = pathTween.changeValue.wps.Length - 1;
            }
            // Find path percentage relative to given waypoint
            float wpLength = 0; // Total length from start to the given waypoint

            for (int i = 0; i < waypointIndex + 1; i++)
            {
                wpLength += pathTween.changeValue.wpLengths[i];
            }
            float wpPerc = wpLength / pathTween.changeValue.length;
            // Convert to time taking eventual inverse direction into account
            bool useInversePosition = t.loopType == LoopType.Yoyo &&
                                      (t.position < t.duration ? t.completedLoops % 2 != 0 : t.completedLoops % 2 == 0);

            if (useInversePosition)
            {
                wpPerc = 1 - wpPerc;
            }
            float to = (t.isComplete ? t.completedLoops - 1 : t.completedLoops) * t.duration + wpPerc * t.duration;

            TweenManager.Goto(t, to, andPlay);
        }
コード例 #7
0
        // ===================================================================================
        // METHODS ---------------------------------------------------------------------------

        // Returns TRUE if the tween needs to be killed
        static bool ApplyInternalCycle(Sequence s, float fromPos, float toPos, UpdateMode updateMode, bool useInverse, bool prevPosIsInverse, bool multiCycleStep = false)
        {
            bool isBackwardsUpdate = toPos < fromPos;

//            Debug.Log((multiCycleStep ? "<color=#FFEC03>Multicycle</color> > " : "Cycle > ") + s.position + "/" + s.duration + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos);
            if (isBackwardsUpdate)
            {
                int len = s._sequencedObjs.Count - 1;
                for (int i = len; i > -1; --i)
                {
                    if (!s.active)
                    {
                        return(true);           // Killed by some internal callback
                    }
                    ABSSequentiable sequentiable = s._sequencedObjs[i];
                    if (sequentiable.sequencedEndPosition < toPos || sequentiable.sequencedPosition > fromPos)
                    {
                        continue;
                    }
                    if (sequentiable.tweenType == TweenType.Callback)
                    {
                        if (updateMode == UpdateMode.Update && prevPosIsInverse)
                        {
//                            Debug.Log("<color=#FFEC03>BACKWARDS Callback > " + s.id + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + "</color>");
                            sequentiable.onStart();
                        }
                    }
                    else
                    {
                        // Nested Tweener/Sequence
                        float gotoPos = toPos - sequentiable.sequencedPosition;
                        if (gotoPos < 0)
                        {
                            gotoPos = 0;
                        }
                        Tween t = (Tween)sequentiable;
                        if (!t.startupDone)
                        {
                            continue;                 // since we're going backwards and this tween never started just ignore it
                        }
                        t.isBackwards = true;
                        if (TweenManager.Goto(t, gotoPos, false, updateMode))
                        {
                            return(true);
                        }

                        // Fixes nested callbacks not being called correctly if main sequence has loops and nested ones don't
                        if (multiCycleStep && t.tweenType == TweenType.Sequence)
                        {
                            if (s.position <= 0 && s.completedLoops == 0)
                            {
                                t.position = 0;
                            }
                            else
                            {
                                bool toZero = s.completedLoops == 0 || s.isBackwards && (s.completedLoops < s.loops || s.loops == -1);
                                if (t.isBackwards)
                                {
                                    toZero = !toZero;
                                }
                                if (useInverse)
                                {
                                    toZero = !toZero;
                                }
                                if (s.isBackwards && !useInverse && !prevPosIsInverse)
                                {
                                    toZero = !toZero;
                                }
                                t.position = toZero ? 0 : t.duration;
                            }
                        }
                    }
                }
            }
            else
            {
                // Debug
                int len = s._sequencedObjs.Count;
                for (int i = 0; i < len; ++i)
                {
                    if (!s.active)
                    {
                        return(true);           // Killed by some internal callback
                    }
                    ABSSequentiable sequentiable = s._sequencedObjs[i];
                    if (sequentiable.sequencedPosition > toPos || sequentiable.sequencedEndPosition < fromPos)
                    {
                        continue;
                    }
                    if (sequentiable.tweenType == TweenType.Callback)
                    {
                        if (updateMode == UpdateMode.Update)
                        {
//                            Debug.Log("<color=#FFEC03>FORWARD Callback > " + s.id + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + "</color>");
                            bool fire = !s.isBackwards && !useInverse && !prevPosIsInverse ||
                                        s.isBackwards && useInverse && !prevPosIsInverse;
                            if (fire)
                            {
                                sequentiable.onStart();
                            }
                        }
                    }
                    else
                    {
                        // Nested Tweener/Sequence
                        float gotoPos = toPos - sequentiable.sequencedPosition;
                        if (gotoPos < 0)
                        {
                            gotoPos = 0;
                        }
                        Tween t = (Tween)sequentiable;
                        t.isBackwards = false;
                        if (TweenManager.Goto(t, gotoPos, false, updateMode))
                        {
                            return(true);
                        }

                        // Fixes nested callbacks not being called correctly if main sequence has loops and nested ones don't
                        if (multiCycleStep && t.tweenType == TweenType.Sequence)
                        {
                            if (s.position <= 0 && s.completedLoops == 0)
                            {
                                t.position = 0;
                            }
                            else
                            {
                                bool toZero = s.completedLoops == 0 || !s.isBackwards && (s.completedLoops < s.loops || s.loops == -1);
                                if (t.isBackwards)
                                {
                                    toZero = !toZero;
                                }
                                if (useInverse)
                                {
                                    toZero = !toZero;
                                }
                                if (s.isBackwards && !useInverse && !prevPosIsInverse)
                                {
                                    toZero = !toZero;
                                }
                                t.position = toZero ? 0 : t.duration;
                            }
                        }
                    }
                }
            }
            return(false);
        }