Exemple #1
0
 /// <summary>
 /// Updates every tweens with a delta time ang handles the tween life-cycles
 /// automatically.
 /// </summary>
 /// <remarks>
 /// Updates every tweens with a delta time ang handles the tween life-cycles
 /// automatically. If a tween is finished, it will be removed from the
 /// manager. The delta time represents the elapsed time between now and the
 /// last update call. Each tween or timeline manages its local time, and adds
 /// this delta to its local time to update itself.
 /// <p/>
 /// Slow motion, fast motion and backward play can be easily achieved by
 /// tweaking this delta time. Multiply it by -1 to play the animation
 /// backward, or by 0.5 to play it twice slower than its normal speed.
 /// </remarks>
 public virtual void Update(float delta)
 {
     for (int i = objects.Count - 1; i >= 0; i--)
     {
         IBaseTween obj = objects[i];
         if (obj.IsFinished() && obj.isAutoRemoveEnabled)
         {
             objects.RemoveAt(i);
             obj.Free();
         }
     }
     if (!isPaused)
     {
         if (delta >= 0)
         {
             for (int i = 0, n = objects.Count; i < n; i++)
             {
                 objects[i].Update(delta);
             }
         }
         else
         {
             for (int i = objects.Count - 1; i >= 0; i--)
             {
                 objects[i].Update(delta);
             }
         }
     }
 }
Exemple #2
0
        // -------------------------------------------------------------------------
        // Overrides
        // -------------------------------------------------------------------------
        public override Timeline Build()
        {
            if (isBuilt)
            {
                return(this);
            }
            duration = 0;
            for (int i = 0; i < children.Count; i++)
            {
                IBaseTween obj = children[i];
                if (obj.GetRepeatCount() < 0)
                {
                    throw new InvalidOperationException("You can't push an object with infinite repetitions in a timeline");
                }
                obj._Build();
                switch (mode)
                {
                case Timeline.Modes.SEQUENCE:
                {
                    float tDelay = duration;
                    duration  += obj.GetFullDuration();
                    obj.delay += tDelay;
                    break;
                }

                case Timeline.Modes.PARALLEL:
                {
                    duration = Math.Max(duration, obj.GetFullDuration());
                    break;
                }
                }
            }
            isBuilt = true;
            return(this);
        }
Exemple #3
0
 protected internal override void ForceEndValues()
 {
     for (int i = 0, n = children.Count; i < n; i++)
     {
         IBaseTween obj = children[i];
         obj.ForceToEnd(duration);
     }
 }
Exemple #4
0
 // -------------------------------------------------------------------------
 // BaseTween impl.
 // -------------------------------------------------------------------------
 protected internal override void ForceStartValues()
 {
     for (int i = children.Count - 1; i >= 0; i--)
     {
         IBaseTween obj = children[i];
         obj.ForceToStart();
     }
 }
Exemple #5
0
 /// <summary>Kills every tweens associated to the given target and tween type.</summary>
 /// <remarks>
 /// Kills every tweens associated to the given target and tween type. Will
 /// also kill every timelines containing a tween associated to the given
 /// target and tween type.
 /// </remarks>
 public virtual void KillTarget(object target, int tweenType)
 {
     for (int i = 0, n = objects.Count; i < n; i++)
     {
         IBaseTween obj = objects[i];
         obj.KillTarget(target, tweenType);
     }
 }
Exemple #6
0
 /// <summary>Kills every managed tweens and timelines.</summary>
 /// <remarks>Kills every managed tweens and timelines.</remarks>
 public virtual void KillAll()
 {
     for (int i = 0, n = objects.Count; i < n; i++)
     {
         IBaseTween obj = objects[i];
         obj.Kill();
     }
 }
Exemple #7
0
 public override void Free()
 {
     for (int i = children.Count - 1; i >= 0; i--)
     {
         IBaseTween obj = children[i];
         children.RemoveAt(i);
         obj.Free();
     }
     pool.Free(this);
 }
Exemple #8
0
 public override Timeline Start()
 {
     base.Start();
     for (int i = 0; i < children.Count; i++)
     {
         IBaseTween obj = children[i];
         obj._Start();
     }
     return(this);
 }
Exemple #9
0
 protected internal override bool ContainsTarget(object target, int tweenType)
 {
     for (int i = 0, n = children.Count; i < n; i++)
     {
         IBaseTween obj = children[i];
         if (obj.ContainsTarget(target, tweenType))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #10
0
 /// <summary>
 /// Returns true if the manager contains any valid interpolation associated
 /// to the given target object.
 /// </summary>
 /// <remarks>
 /// Returns true if the manager contains any valid interpolation associated
 /// to the given target object.
 /// </remarks>
 public virtual bool ContainsTarget(object target)
 {
     for (int i = 0, n = objects.Count; i < n; i++)
     {
         IBaseTween obj = objects[i];
         if (obj.ContainsTarget(target))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #11
0
 // -------------------------------------------------------------------------
 // Public API
 // -------------------------------------------------------------------------
 /// <summary>Adds a tween or timeline to the manager and starts or restarts it.</summary>
 /// <remarks>Adds a tween or timeline to the manager and starts or restarts it.</remarks>
 /// <returns>The manager, for instruction chaining.</returns>
 public virtual TweenManager Add(IBaseTween tween)
 {
     if (!objects.Contains(tween))
     {
         objects.Add(tween);
     }
     if (tween.isAutoStartEnabled)
     {
         tween._Start();
     }
     return(this);
 }
Exemple #12
0
        private static int GetTimelinesCount(IList <IBaseTween> objs)
        {
            int cnt = 0;

            for (int i = 0, n = objs.Count; i < n; i++)
            {
                IBaseTween obj = objs[i];
                if (obj is Timeline)
                {
                    cnt += 1 + GetTimelinesCount(((Timeline)obj).GetChildren());
                }
            }
            return(cnt);
        }
Exemple #13
0
 /// <summary>
 /// Disables or enables the "auto start" mode of any tween manager for a
 /// particular tween or timeline.
 /// </summary>
 /// <remarks>
 /// Disables or enables the "auto start" mode of any tween manager for a
 /// particular tween or timeline. This mode is activated by default. If it
 /// is not enabled, add a tween or timeline to any manager won't start it
 /// automatically, and you'll need to call .start() manually on your object.
 /// </remarks>
 public static void SetAutoStart(IBaseTween @object, bool value)
 {
     @object.isAutoStartEnabled = value;
 }
Exemple #14
0
 // -------------------------------------------------------------------------
 // Static API
 // -------------------------------------------------------------------------
 /// <summary>
 /// Disables or enables the "auto remove" mode of any tween manager for a
 /// particular tween or timeline.
 /// </summary>
 /// <remarks>
 /// Disables or enables the "auto remove" mode of any tween manager for a
 /// particular tween or timeline. This mode is activated by default. The
 /// interest of desactivating it is to prevent some tweens or timelines from
 /// being automatically removed from a manager once they are finished.
 /// Therefore, if you update a manager backwards, the tweens or timelines
 /// will be played again, even if they were finished.
 /// </remarks>
 public static void SetAutoRemove(IBaseTween @object, bool value)
 {
     @object.isAutoRemoveEnabled = value;
 }