Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SF.GameObjects
- {
- public static class MineConstants
- {
- /* The levels in which you unlock each ore */
- public enum UnlockLevel
- {
- StartingLevel = 1,
- IronUnlockLevel = StartingLevel + 2 ^ 1,
- SilverUnlockLevel = IronUnlockLevel + 2 ^ 2,
- GoldUnlockLevel = SilverUnlockLevel + 2 ^ 3,
- UpperBoundUnlockLevel = int.MaxValue
- };
- /* First dimension is level, second demension is ore type */
- public static int[][] Counts = (int[][]) SetupOreCounts().Clone();
- /* Total number of levels for the mine */
- public static int TotalLevels = 20;
- public static OreType[] OreTypes = new[]{OreType.Copper, OreType.Iron, OreType.Silver, OreType.Gold};
- private static int[][] SetupOreCounts()
- {
- const int baseCopper = 3;
- var totalEnumCount = Enum.GetNames(typeof(OreType)).Length;
- var oreCounts = new int[TotalLevels][];
- for (int level = 0; level < TotalLevels; level++)
- {
- oreCounts[level] = new int[totalEnumCount];
- if (level == 0)
- {
- oreCounts[0][(int) OreType.Copper] = baseCopper;
- oreCounts[0][(int) OreType.Iron] = 0;
- oreCounts[0][(int) OreType.Silver] = 0;
- oreCounts[0][(int) OreType.Gold] = 0;
- }
- else
- {
- foreach (var oreType in OreTypes)
- {
- if (level != 0)
- {
- oreCounts[level][(int) oreType] = oreCounts[level - 1][(int) oreType];
- }
- }
- }
- IncrementOreCountForLevel(oreCounts, level);
- }
- return oreCounts;
- }
- private static void IncrementOreCountForLevel(IReadOnlyList<int[]> oreCounts, int level)
- {
- if (level < (int) UnlockLevel.IronUnlockLevel)
- {
- oreCounts[level][(int) OreType.Copper] += 1;
- }
- else if (level >= (int) UnlockLevel.IronUnlockLevel && level < (int) UnlockLevel.SilverUnlockLevel)
- {
- oreCounts[level][(int) OreType.Iron] += 1;
- }
- else if (level >= (int) UnlockLevel.SilverUnlockLevel && level < (int) UnlockLevel.GoldUnlockLevel)
- {
- oreCounts[level][(int) OreType.Silver] += 1;
- }
- else if (level >= (int) UnlockLevel.GoldUnlockLevel)
- {
- oreCounts[level][(int) OreType.Gold] += 1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement