Ejemplo n.º 1
0
        public static int[] RandomTotalProbabilities(int length, int total, int minValue = 1, int maxValue = 100)
        {
            if ((maxValue * length) < total)
            {
                throw new Exception($"Max ({maxValue}) value can't be smaller than ({(total / length) + 1})");
            }
            else if ((minValue * length) > total)
            {
                throw new Exception($"Min ({minValue}) value can't be larger than {total / length}");
            }
            else if (maxValue < minValue)
            {
                throw new Exception("Max value can't be smaller than min!");
            }

            int[] chances = new int[length];
            int   sum     = 0;

            maxValue = TPMath.Clamp(maxValue, ((total / length) + 1), total);
            minValue = TPMath.Clamp(minValue, 0, total / length);

            for (int index = 0; index < length; index++)
            {
                int lessTotal = total - sum;
                int counter   = length - 1 - index;
                int low       = TPMath.Clamp(lessTotal - (maxValue * counter), minValue, maxValue);
                int high      = TPMath.Clamp(lessTotal - (minValue * counter), minValue, maxValue);

                chances[index] = Range(low, high + 1);
                sum           += chances[index];
            }
            return(chances);
        }
Ejemplo n.º 2
0
 public static float EaseInOutQuint(float from, float to, float time, float duration)
 {
     time /= duration;
     return((time / 2) < 1
         ? to / 2 * time * time * time * time * time + from
         : to / 2 * (TPMath.Pow(time - 2, 5) + 2) + from);
 }
Ejemplo n.º 3
0
 public static float EaseInOutCirc(float from, float to, float time, float duration)
 {
     time /= duration;
     return((time / 2) < 1
         ? to / 2 * (1 - TPMath.Sqrt(1 - time * time)) + from
         : to / 2 * (TPMath.Sqrt(1 - (time -= 2) * time) + 1) + from);
 }
Ejemplo n.º 4
0
 public static float EaseInSine(float from, float to, float time, float duration)
 {
     return(to * (1 - TPMath.Cos(time / duration * (TPMath.PI / 2))) + from);
 }
Ejemplo n.º 5
0
 public static float EaseOutQuint(float from, float to, float time, float duration)
 {
     return(to * (TPMath.Pow(time / duration - 1, 5) + 1) + from);
 }
Ejemplo n.º 6
0
 public static float EaseOutQuart(float from, float to, float time, float duration)
 {
     return(-to * (TPMath.Pow(time / duration - 1, 4) - 1) + from);
 }
Ejemplo n.º 7
0
 public static float EaseOutCubic(float time, float from, float to, float duration)
 {
     time /= duration;
     return(to * (TPMath.Pow(time / duration - 1, 3) + 1) + from);
 }
Ejemplo n.º 8
0
 public static float EaseInCirc(float from, float to, float time, float duration)
 {
     time /= duration;
     return(to * (1 - TPMath.Sqrt(1 - time * time)) + from);
 }
Ejemplo n.º 9
0
 public static float EaseOutCirc(float from, float to, float time, float duration)
 {
     time /= duration;
     return(to * TPMath.Sqrt(1 - (time - 1) * time) + from);
 }
Ejemplo n.º 10
0
 public static float EaseInOutExpo(float from, float to, float time, float duration)
 {
     return((time /= duration / 2) < 1
         ? to / 2 * TPMath.Pow(2, 10 * (time - 1)) + from
         : to / 2 * (-TPMath.Pow(2, -10 * --time) + 2) + from);
 }
Ejemplo n.º 11
0
 public static float EaseOutExpo(float from, float to, float time, float duration)
 {
     return(to * (-TPMath.Pow(2, -10 * time / duration) + 1) + from);
 }
Ejemplo n.º 12
0
 public static float EaseInExpo(float from, float to, float time, float duration)
 {
     return(to * TPMath.Pow(2, 10 * (time / duration - 1)) + from);
 }
Ejemplo n.º 13
0
 public static float EaseInOutSine(float from, float to, float time, float duration)
 {
     return(to / 2 * (1 - TPMath.Cos(TPMath.PI * time / duration)) + from);
 }
Ejemplo n.º 14
0
 public static float EaseOutSine(float from, float to, float time, float duration)
 {
     return(to * TPMath.Sin(time / duration * (TPMath.PI / 2)) + from);
 }