Level.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package pathgame.gameplay;
  2. import pathgame.tilemap.TileMap;
  3. import pathgame.tilemap.TileMapGenerator;
  4. public final class Level
  5. {
  6. private final Player player = new Player();
  7. private int level = 1;
  8. private TileMap map = null;
  9. private boolean showScoreMenu = false;
  10. private boolean showAfterScore = false;
  11. public Level()
  12. {
  13. reset();
  14. }
  15. public void tick(Gamestate gamestate)
  16. {
  17. map.tick();
  18. if(gamestate.is(Gamestates.GAMEPLAY) && !showScoreMenu)
  19. {
  20. player.tick(map);
  21. }
  22. if(gamestate.is(Gamestates.GAMEPLAY) && !showScoreMenu && (player.hasLost() || player.hasWon()))
  23. {
  24. showScoreMenu = true;
  25. }
  26. else if(showScoreMenu && Keys.CONFIRM_KEY.getTime() == 1)
  27. {
  28. showScoreMenu = false;
  29. showAfterScore = true;
  30. }
  31. }
  32. public void nextLevel()
  33. {
  34. level++;
  35. reset();
  36. }
  37. public void reset()
  38. {
  39. player.reset();
  40. map = TileMapGenerator.getMap(5 + 5 * level, 5 + 5 * level, level, 2 + level);
  41. player.setEnergySupply(100); // ToDo: insert value of algorithm
  42. player.setObjectivesAmount(map.getNumberOfTowns());
  43. }
  44. public TileMap getMap()
  45. {
  46. return map;
  47. }
  48. public Player getPlayer()
  49. {
  50. return player;
  51. }
  52. public int getLevel()
  53. {
  54. return level;
  55. }
  56. public boolean getShowAfterScore()
  57. {
  58. return showAfterScore;
  59. }
  60. public void setShowAfterScore(boolean show)
  61. {
  62. showAfterScore = show;
  63. }
  64. public boolean getShowScoreMenu()
  65. {
  66. return showScoreMenu;
  67. }
  68. }