Math.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using UnityEngine;
  3. namespace wf
  4. {
  5. public static class Math
  6. {
  7. public static int Round2(int num)
  8. {
  9. return Math.Min(Math.Max(num, 0), 99);
  10. }
  11. public static int Round3(int num)
  12. {
  13. return Math.Min(Math.Max(num, 0), 999);
  14. }
  15. public static int Round4(int num)
  16. {
  17. return Math.Min(Math.Max(num, 0), 9999);
  18. }
  19. public static int Round5(int num)
  20. {
  21. return Math.Min(Math.Max(num, 0), 99999);
  22. }
  23. public static long Round4(long num)
  24. {
  25. return Math.Min(Math.Max(num, 0L), 9999L);
  26. }
  27. public static long Round6(long num)
  28. {
  29. return Math.Min(Math.Max(num, 0L), 999999L);
  30. }
  31. public static int RoundMinMax(int num, int min, int max)
  32. {
  33. return Math.Min(Math.Max(num, min), max);
  34. }
  35. public static float RoundMinMax(float num, float min, float max)
  36. {
  37. return Math.Min(Math.Max(num, min), max);
  38. }
  39. public static long RoundMinMax(long num, long min, long max)
  40. {
  41. return Math.Min(Math.Max(num, min), max);
  42. }
  43. public static bool Approximately(Vector2 objA, Vector2 objB)
  44. {
  45. return Mathf.Approximately(objA.x, objB.x) && Mathf.Approximately(objA.y, objB.y);
  46. }
  47. public static bool Approximately(Vector3 objA, Vector3 objB)
  48. {
  49. return Mathf.Approximately(objA.x, objB.x) && Mathf.Approximately(objA.y, objB.y) && Mathf.Approximately(objA.z, objB.z);
  50. }
  51. }
  52. }