Tiles.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package pathgame.tilemap;
  2. import pathgame.gameplay.PlayerAbilities;
  3. public class Tiles {
  4. public final static Tile GRASS = buildGrass();
  5. public final static Tile GRASS_WITH_STONE = buildGrass();
  6. public final static Tile GRASS_WITH_6_BUSHES = buildGrass();
  7. public final static Tile GRASS_WITH_3_BUSHES = buildGrass();
  8. public final static Tile GRASS_WITH_FLOWERS_1 = buildGrass();
  9. public final static Tile GRASS_WITH_FLOWERS_2 = buildGrass();
  10. public final static Tile GRASS_WITH_FLOWERS_3 = buildGrass();
  11. public final static Tile GRASS_WITH_FLOWERS_4 = buildGrass();
  12. public final static Tile GRASS_WITH_HILL = buildGrass();
  13. public final static Tile GRASS_WITH_EARTH = buildGrass();
  14. public final static Tile[] GRASS_VARIANTS = new Tile[]{
  15. GRASS, GRASS_WITH_STONE, GRASS_WITH_6_BUSHES, GRASS_WITH_3_BUSHES,
  16. GRASS_WITH_FLOWERS_1, GRASS_WITH_FLOWERS_2, GRASS_WITH_FLOWERS_3,
  17. GRASS_WITH_FLOWERS_4, GRASS_WITH_HILL, GRASS_WITH_EARTH
  18. };
  19. public final static Tile FOREST = Tile.TileBuilder.create()
  20. .setEnergyCost(4)
  21. .setForestReplaceChance(0.0f)
  22. .setSpeedUp((p) -> p.getAbilities().getFasterForest())
  23. .pathHost()
  24. .build();
  25. public final static Tile SWAMP = buildSwamp();
  26. public final static Tile SWAMP_DECO = buildSwamp();
  27. public final static Tile SWAMP_TREE = buildSwamp();
  28. public final static Tile SWAMP_BONES = buildSwamp();
  29. public final static Tile SHALLOW_WATER = Tile.TileBuilder.create()
  30. .setEnergyCost(6)
  31. .setForestReplaceChance(0.0f)
  32. .setSpeedUp((p)
  33. -> {
  34. if(p.isSailing()) {
  35. if(p.getAbilities() == PlayerAbilities.SAILOR) {
  36. return 5;
  37. }
  38. return 4;
  39. }
  40. return p.getAbilities().getFasterShallowWater();
  41. })
  42. .noTown()
  43. .setRenderType(TileRenderType.WATER)
  44. .setType(TileType.SHALLOW_WATER)
  45. .build();
  46. public final static Tile DEEP_WATER = Tile.TileBuilder.create()
  47. .setEnergyCost(2)
  48. .setForestReplaceChance(0.0f)
  49. .setSpeedUp((p) -> p.getAbilities().getFasterDeepWater())
  50. .noTown()
  51. .setRenderType(TileRenderType.WATER)
  52. .setType(TileType.DEEP_WATER)
  53. .build();
  54. public final static Tile HILL = Tile.TileBuilder.create()
  55. .setEnergyCost(6)
  56. .setForestReplaceChance(0.5f)
  57. .setSpeedUp((p) -> p.getAbilities().getFasterHill())
  58. .pathHost()
  59. .build();
  60. public final static Tile MOUNTAIN = Tile.TileBuilder.create()
  61. .setEnergyCost(9)
  62. .setForestReplaceChance(0.0f)
  63. .setSpeedUp((p) -> p.getAbilities().getFasterMountain())
  64. .noTown()
  65. .build();
  66. public final static Tile TOWN = new TileTown();
  67. public final static Tile TOWN_BLOCKED_1 = buildBlockedTown();
  68. public final static Tile TOWN_BLOCKED_2 = buildBlockedTown();
  69. public final static Tile TOWN_BLOCKED_3 = buildBlockedTown();
  70. public final static Tile TOWN_BLOCKED_4 = buildBlockedTown();
  71. public final static Tile[] TOWN_BLOCKED = new Tile[]{
  72. TOWN_BLOCKED_1, TOWN_BLOCKED_2, TOWN_BLOCKED_3, TOWN_BLOCKED_4
  73. };
  74. public final static Tile PORT = new TilePort();
  75. private static Tile buildGrass() {
  76. return Tile.TileBuilder.create()
  77. .setSpeedUp((p) -> p.getAbilities().getFasterGrass())
  78. .pathHost()
  79. .setEnergyCost(3)
  80. .build();
  81. }
  82. private static Tile buildSwamp() {
  83. return Tile.TileBuilder.create()
  84. .setEnergyCost(5)
  85. .setForestReplaceChance(0.0f)
  86. .setRenderType(TileRenderType.SWAMP)
  87. .setSpeedUp((p) -> p.getAbilities().getFasterSwamp())
  88. .build();
  89. }
  90. private static Tile buildBlockedTown() {
  91. return Tile.TileBuilder.create()
  92. .setForestReplaceChance(0.0f)
  93. .noTown()
  94. .build();
  95. }
  96. public final static Tile HOME_TOWN = new TileHomeTown();
  97. private static Tile buildPath() {
  98. return Tile.TileBuilder.create()
  99. .setForestReplaceChance(0.0f)
  100. .path()
  101. .build();
  102. }
  103. public final static Tile PATH_N_E_S_W = buildPath();
  104. public final static Tile PATH_N_E_S = buildPath();
  105. public final static Tile PATH_N_E_W = buildPath();
  106. public final static Tile PATH_N_E = buildPath();
  107. public final static Tile PATH_N_S_W = buildPath();
  108. public final static Tile PATH_N_S = buildPath();
  109. public final static Tile PATH_N_W = buildPath();
  110. public final static Tile PATH_N = buildPath();
  111. public final static Tile PATH_E_S_W = buildPath();
  112. public final static Tile PATH_E_S = buildPath();
  113. public final static Tile PATH_E_W = buildPath();
  114. public final static Tile PATH_E = buildPath();
  115. public final static Tile PATH_S_W = buildPath();
  116. public final static Tile PATH_S = buildPath();
  117. public final static Tile PATH_W = buildPath();
  118. public final static Tile[] PATH = new Tile[]{
  119. PATH_N_E_S_W, PATH_N_E_S, PATH_N_E_W, PATH_N_E,
  120. PATH_N_S_W, PATH_N_S, PATH_N_W, PATH_N,
  121. PATH_E_S_W, PATH_E_S, PATH_E_W, PATH_E,
  122. PATH_S_W, PATH_S, PATH_W, GRASS
  123. };
  124. public static Tile getPath(boolean north, boolean east, boolean south, boolean west) {
  125. return PATH[(north ? 0 : 8) + (east ? 0 : 4) + (south ? 0 : 2) + (west ? 0 : 1)];
  126. }
  127. }