ShopPlatform.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using UnityEngine;
  6. namespace ScrapYard.API
  7. {
  8. public class ShopPlatform
  9. {
  10. public readonly ShopPlatformSpacingType Type;
  11. public readonly string Title;
  12. internal List<ShopPlatformEntry> Entries = new List<ShopPlatformEntry>();
  13. internal static List<ShopPlatform> ShopPlatforms = new List<ShopPlatform>();
  14. public static ShopPlatform DefaultObjects
  15. {
  16. get => ShopPlatforms[0];
  17. }
  18. public static ShopPlatform DefaultBlocks
  19. {
  20. get => ShopPlatforms[1];
  21. }
  22. public static ShopPlatform DefaultWalls
  23. {
  24. get => ShopPlatforms[2];
  25. }
  26. public ShopPlatform(string title, ShopPlatformSpacingType spacingType = ShopPlatformSpacingType.Normal)
  27. {
  28. this.Type = spacingType;
  29. this.Title = title;
  30. }
  31. public virtual ShopPlatform Register()
  32. {
  33. ShopPlatforms.Add(this);
  34. return this;
  35. }
  36. public ShopPlatformSpacingType GetShopPlatformSpacingType()
  37. {
  38. return Type;
  39. }
  40. public void AddShopPlatformEntry(ShopPlatformEntry row)
  41. {
  42. Entries.Add(row);
  43. }
  44. public void RemoveShopPlatformEntry(ShopPlatformEntry row)
  45. {
  46. Entries.Remove(row);
  47. }
  48. public ShopPlatformEntry[] GetShopPlatformEntries()
  49. {
  50. return Entries.ToArray();
  51. }
  52. public static ShopPlatform[] GetShopPlatforms()
  53. {
  54. return ShopPlatforms.ToArray();
  55. }
  56. internal int GetSpacesPerRow()
  57. {
  58. int spaces = 0;
  59. switch (Type)
  60. {
  61. case ShopPlatformSpacingType.Normal:
  62. spaces = 7;
  63. break;
  64. case ShopPlatformSpacingType.Near:
  65. spaces = 13;
  66. break;
  67. case ShopPlatformSpacingType.Far:
  68. spaces = 3;
  69. break;
  70. }
  71. return spaces;
  72. }
  73. internal int GetRowsNeeded()
  74. {
  75. return ((Entries.Count - 1) / GetSpacesPerRow()) + 1;
  76. }
  77. }
  78. public enum ShopPlatformSpacingType
  79. {
  80. Normal,
  81. Near,
  82. Far
  83. }
  84. }