Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. namespace SF.GameObjects
  2. {
  3. public static class MineConstants
  4. {
  5. /* The levels in which you unlock each ore */
  6. public enum UnlockLevel
  7. {
  8. StartingLevel = 1,
  9. IronUnlockLevel = StartingLevel + 2 ^ 1,
  10. SilverUnlockLevel = IronUnlockLevel + 2 ^ 2,
  11. GoldUnlockLevel = SilverUnlockLevel + 2 ^ 3,
  12. UpperBoundUnlockLevel = int.MaxValue
  13. };
  14.  
  15. /* First dimension is level, second demension is ore type */
  16. public static int[][] Counts = (int[][]) SetupOreCounts().Clone();
  17.  
  18. /* Total number of levels for the mine */
  19. public static int TotalLevels = 20;
  20.  
  21. public static OreType[] OreTypes = new[]{OreType.Copper, OreType.Iron, OreType.Silver, OreType.Gold};
  22.  
  23. private static int[][] SetupOreCounts()
  24. {
  25. const int baseCopper = 3;
  26. var totalEnumCount = Enum.GetNames(typeof(OreType)).Length;
  27. var oreCounts = new int[TotalLevels][];
  28.  
  29. for (int level = 0; level < TotalLevels; level++)
  30. {
  31. oreCounts[level] = new int[totalEnumCount];
  32.  
  33. if (level == 0)
  34. {
  35. oreCounts[0][(int) OreType.Copper] = baseCopper;
  36. oreCounts[0][(int) OreType.Iron] = 0;
  37. oreCounts[0][(int) OreType.Silver] = 0;
  38. oreCounts[0][(int) OreType.Gold] = 0;
  39. }
  40. else
  41. {
  42. foreach (var oreType in OreTypes)
  43. {
  44. if (level != 0)
  45. {
  46. oreCounts[level][(int) oreType] = oreCounts[level - 1][(int) oreType];
  47. }
  48. }
  49. }
  50.  
  51. IncrementOreCountForLevel(oreCounts, level);
  52. }
  53.  
  54. return oreCounts;
  55. }
  56.  
  57. private static void IncrementOreCountForLevel(IReadOnlyList<int[]> oreCounts, int level)
  58. {
  59. if (level < (int) UnlockLevel.IronUnlockLevel)
  60. {
  61. oreCounts[level][(int) OreType.Copper] += 1;
  62. }
  63. else if (level >= (int) UnlockLevel.IronUnlockLevel && level < (int) UnlockLevel.SilverUnlockLevel)
  64. {
  65. oreCounts[level][(int) OreType.Iron] += 1;
  66. }
  67. else if (level >= (int) UnlockLevel.SilverUnlockLevel && level < (int) UnlockLevel.GoldUnlockLevel)
  68. {
  69. oreCounts[level][(int) OreType.Silver] += 1;
  70. }
  71. else if (level >= (int) UnlockLevel.GoldUnlockLevel)
  72. {
  73. oreCounts[level][(int) OreType.Gold] += 1;
  74. }
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement