Tiles.java 5.7 KB

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