Exemple #1
0
        private static IEnumerator Loop(GameObject gameObject, string coroutineKey, bool isLooping, float maxTime,
                                        AnimationFunc animationFunc)
        {
            var runner = gameObject.AddOrGetComponent <Runner>();

            var elapsedTime = 0f;

            while (isLooping || elapsedTime < maxTime)
            {
                animationFunc(elapsedTime);

                if (isLooping)
                {
                    elapsedTime += Time.deltaTime;
                }
                else
                {
                    elapsedTime = Mathf.Min(elapsedTime + Time.deltaTime, maxTime);
                }

                yield return(null);
            }

            animationFunc(elapsedTime);

            runner.RemoveCoroutine(coroutineKey);
        }
Exemple #2
0
 public static void LogAnimation(int beginValue, int endValue, int duration, AnimationFunc scene)
 {
     using (Animation a = new Animation())
     {
         a.Mode = AnimationMode.Log;
         a.Acceleration = 0.05f;
         a.BeginValue = beginValue;
         a.EndValue = endValue;
         a.Duration = duration;
         a.Scene += new EventHandler<AnimationEventArgs>(scene);
         a.StartModal();
     }
 }
 public static void LogAnimation(int beginValue, int endValue, int duration, AnimationFunc scene)
 {
     using (Animation a = new Animation())
     {
         a.Mode         = AnimationMode.Log;
         a.Acceleration = 0.05f;
         a.BeginValue   = beginValue;
         a.EndValue     = endValue;
         a.Duration     = duration;
         a.Scene       += new EventHandler <AnimationEventArgs>(scene);
         a.StartModal();
     }
 }
Exemple #4
0
 public static Animation AsyncLogAnimation(int beginValue, int endValue, int duration, AnimationFunc scene, CompletedFunc completed, object data)
 {
     Animation a = new Animation();
     a.Mode = AnimationMode.Log;
     a.Acceleration = 0.05f;
     a.BeginValue = beginValue;
     a.EndValue = endValue;
     a.Duration = duration;
     a.Data = data;
     if (completed != null) a.Completed += new EventHandler(completed);
     a.Scene += new EventHandler<AnimationEventArgs>(scene);
     a.Start();
     return a;
 }
Exemple #5
0
 public static void AnimateModal(int index, int beginValue, int endValue, int duration, AnimationFunc func)
 {
     using (ListBoxAnimation a = new ListBoxAnimation())
     {
         a.Index = index;
         a.BeginValue = beginValue;
         a.EndValue = endValue;
         a.Duration = duration;
         a.Scene +=new EventHandler<AnimationEventArgs>(func);
         a.Mode = AnimationMode.Log;
         a.Acceleration = 0.05f;
         a.StartModal();
     }
 }
Exemple #6
0
 /// <summary>
 /// Performs a modal animation of a listbox item.
 /// </summary>
 /// <param name="index">The index of the listbox item.</param>
 /// <param name="beginValue">The intial animation value.</param>
 /// <param name="endValue">The final animation value.</param>
 /// <param name="duration">The duration of the animation.</param>
 /// <param name="func">The AnimationFunc.</param>
 public static void AnimateModal(int index, int beginValue, int endValue, int duration, AnimationFunc func)
 {
     using (ListBoxAnimation a = new ListBoxAnimation())
     {
         a.Index        = index;
         a.BeginValue   = beginValue;
         a.EndValue     = endValue;
         a.Duration     = duration;
         a.Scene       += new EventHandler <AnimationEventArgs>(func);
         a.Mode         = AnimationMode.Log;
         a.Acceleration = 0.05f;
         a.StartModal();
     }
 }
        public static Animation AsyncLogAnimation(int beginValue, int endValue, int duration, AnimationFunc scene, CompletedFunc completed, object data)
        {
            Animation a = new Animation();

            a.Mode         = AnimationMode.Log;
            a.Acceleration = 0.05f;
            a.BeginValue   = beginValue;
            a.EndValue     = endValue;
            a.Duration     = duration;
            a.Data         = data;
            if (completed != null)
            {
                a.Completed += new EventHandler(completed);
            }
            a.Scene += new EventHandler <AnimationEventArgs>(scene);
            a.Start();
            return(a);
        }