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); }
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); }
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); }
public static float EaseInSine(float from, float to, float time, float duration) { return(to * (1 - TPMath.Cos(time / duration * (TPMath.PI / 2))) + from); }
public static float EaseOutQuint(float from, float to, float time, float duration) { return(to * (TPMath.Pow(time / duration - 1, 5) + 1) + from); }
public static float EaseOutQuart(float from, float to, float time, float duration) { return(-to * (TPMath.Pow(time / duration - 1, 4) - 1) + from); }
public static float EaseOutCubic(float time, float from, float to, float duration) { time /= duration; return(to * (TPMath.Pow(time / duration - 1, 3) + 1) + from); }
public static float EaseInCirc(float from, float to, float time, float duration) { time /= duration; return(to * (1 - TPMath.Sqrt(1 - time * time)) + from); }
public static float EaseOutCirc(float from, float to, float time, float duration) { time /= duration; return(to * TPMath.Sqrt(1 - (time - 1) * time) + from); }
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); }
public static float EaseOutExpo(float from, float to, float time, float duration) { return(to * (-TPMath.Pow(2, -10 * time / duration) + 1) + from); }
public static float EaseInExpo(float from, float to, float time, float duration) { return(to * TPMath.Pow(2, 10 * (time / duration - 1)) + from); }
public static float EaseInOutSine(float from, float to, float time, float duration) { return(to / 2 * (1 - TPMath.Cos(TPMath.PI * time / duration)) + from); }
public static float EaseOutSine(float from, float to, float time, float duration) { return(to * TPMath.Sin(time / duration * (TPMath.PI / 2)) + from); }