Node2D.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package pathgame.algorithm;
  2. import pathgame.tilemap.TileType;
  3. import java.util.ArrayList;
  4. public class Node2D {
  5. private final int weight;
  6. private int costSoFar = Integer.MAX_VALUE;
  7. private char prevOfPath = '\0';
  8. private int prevBoatPath = -1;
  9. private TileType type = TileType.LAND;
  10. private boolean isQAdded = false;
  11. private boolean hasExtraPaths = false;
  12. private boolean isBlocked = false;
  13. private boolean isTown = false;
  14. private final ArrayList<ExtraPath> extraPaths = new ArrayList<>();
  15. public Node2D(int weight) {
  16. this.weight = weight;
  17. }
  18. public int getWeight() {
  19. return weight;
  20. }
  21. public int getCostSoFar() {
  22. return costSoFar;
  23. }
  24. public void setCostSoFar(int costSoFar) {
  25. this.costSoFar = costSoFar;
  26. }
  27. public char getPrevOfPath() {
  28. return prevOfPath;
  29. }
  30. public void setPrevOfPath(char prevOfPath) {
  31. this.prevOfPath = prevOfPath;
  32. }
  33. public ArrayList<ExtraPath> getExtraPaths() {
  34. return extraPaths;
  35. }
  36. public void addExtraPath(Coord dest, int pathWeight, ArrayList<Coord> pathCoords) {
  37. hasExtraPaths = true;
  38. extraPaths.add(new ExtraPath(dest.getX(), dest.getY(), pathWeight, pathCoords));
  39. }
  40. public boolean hasExtraPaths() {
  41. return hasExtraPaths;
  42. }
  43. public boolean isQAdded() {
  44. return isQAdded;
  45. }
  46. public void setQAdded(boolean QAdded) {
  47. isQAdded = QAdded;
  48. }
  49. public boolean isBlocked() {
  50. return isBlocked;
  51. }
  52. public void setBlocked(boolean blocked) {
  53. isBlocked = blocked;
  54. }
  55. public TileType getType() {
  56. return type;
  57. }
  58. public void setType(TileType type) {
  59. this.type = type;
  60. }
  61. public int getPrevBoatPath() {
  62. return prevBoatPath;
  63. }
  64. public void setPrevBoatPath(int prevBoatPath) {
  65. this.prevBoatPath = prevBoatPath;
  66. }
  67. public boolean isTown() {
  68. return isTown;
  69. }
  70. public void setTown(boolean town) {
  71. isTown = town;
  72. }
  73. }