Tiles.java 5.6 KB

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