Tiles.java 6.1 KB

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