Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ApplePriceTiers.cs 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. namespace UnityEditor.Purchasing
  2. {
  3. internal static class ApplePriceTiers
  4. {
  5. internal const int kNumTiers = 88;
  6. // Cache
  7. private static string[] s_Strings;
  8. private static int[] s_Dollars;
  9. internal static string[] Strings
  10. {
  11. get
  12. {
  13. GenerateAppleTierData();
  14. return s_Strings;
  15. }
  16. }
  17. internal static int[] RoundedDollars
  18. {
  19. get
  20. {
  21. GenerateAppleTierData();
  22. return s_Dollars;
  23. }
  24. }
  25. internal static double ActualDollarsForAppleTier(int tier)
  26. {
  27. if (RoundedDollars[tier] == 0)
  28. {
  29. return 0;
  30. }
  31. return RoundedDollars[tier] - 0.01;
  32. }
  33. private static void GenerateAppleTierData()
  34. {
  35. if (s_Strings == null || s_Dollars == null)
  36. {
  37. s_Strings = new string[kNumTiers];
  38. s_Dollars = new int[kNumTiers];
  39. var i = 0;
  40. s_Dollars[i] = 0;
  41. s_Strings[i++] = "Free";
  42. var dollars = 1;
  43. for (; i < kNumTiers; ++i)
  44. {
  45. if (i == 63)
  46. {
  47. s_Strings[i] = CreateApplePriceTierString(i, 125);
  48. s_Dollars[i] = 125;
  49. }
  50. else if (i == 69)
  51. {
  52. s_Strings[i] = CreateApplePriceTierString(i, 175);
  53. s_Dollars[i] = 175;
  54. }
  55. else
  56. {
  57. s_Strings[i] = CreateApplePriceTierString(i, dollars);
  58. s_Dollars[i] = dollars;
  59. if (i >= 82)
  60. { // 82 - 87 USD $100 increments to $1000
  61. dollars += 100;
  62. }
  63. else if (i >= 77)
  64. { // 77 - 82 USD $50 increments to $500
  65. dollars += 50;
  66. }
  67. else if (i >= 60)
  68. { // 60 - 77 $10 increments to $250, except 63 = $125 and 69 = $175
  69. dollars += 10;
  70. }
  71. else if (i >= 50)
  72. { // 50 - 59 USD $5 increments
  73. dollars += 5;
  74. }
  75. else
  76. { // 1 - 49 USD $1 increments
  77. dollars++;
  78. }
  79. }
  80. }
  81. }
  82. }
  83. private static string CreateApplePriceTierString(int tier, int roundedDollars)
  84. {
  85. return string.Format("Tier {0} - USD {1:0.00}", tier, roundedDollars - 0.01f);
  86. }
  87. }
  88. }