@Test public void testInVisionRange() { Position anotherPos = new Position((byte) (X_POSITION + 20), (byte) (Y_POSITION + 20), pos.getMap()); assertFalse(pos.inVisionRange(anotherPos)); anotherPos.setX((byte) (X_POSITION + 5)); anotherPos.setY((byte) (Y_POSITION + 5)); assertTrue(pos.inVisionRange(anotherPos)); anotherPos.setMap(2); assertFalse(pos.inVisionRange(anotherPos)); }
public boolean inVisionRange(Position pos) { if (map != pos.map || Math.abs(x - pos.x) > WorldMap.VISIBLE_AREA_WIDTH || Math.abs(y - pos.y) > WorldMap.VISIBLE_AREA_HEIGHT) { return false; } return true; }
Position { public boolean inVisionRange(Position pos) { if (map != pos.map || Math.abs(x - pos.x) > WorldMap.VISIBLE_AREA_WIDTH || Math.abs(y - pos.y) > WorldMap.VISIBLE_AREA_HEIGHT) { return false; } return true; } }
Position { public boolean inVisionRange(Position pos) { if (map != pos.map || Math.abs(x - pos.x) > WorldMap.VISIBLE_AREA_WIDTH || Math.abs(y - pos.y) > WorldMap.VISIBLE_AREA_HEIGHT) { return false; } return true; } Position(byte x, byte y, int map); }
Position { public boolean inVisionRange(Position pos) { if (map != pos.map || Math.abs(x - pos.x) > WorldMap.VISIBLE_AREA_WIDTH || Math.abs(y - pos.y) > WorldMap.VISIBLE_AREA_HEIGHT) { return false; } return true; } Position(byte x, byte y, int map); byte getX(); void setX(byte x); byte getY(); void setY(byte y); int getMap(); void setMap(int map); void addToX(int positions); void addToY(int positions); int getDistance(Position pos); boolean inVisionRange(Position pos); @Override int hashCode(); @Override boolean equals(Object obj); }
Position { public boolean inVisionRange(Position pos) { if (map != pos.map || Math.abs(x - pos.x) > WorldMap.VISIBLE_AREA_WIDTH || Math.abs(y - pos.y) > WorldMap.VISIBLE_AREA_HEIGHT) { return false; } return true; } Position(byte x, byte y, int map); byte getX(); void setX(byte x); byte getY(); void setY(byte y); int getMap(); void setMap(int map); void addToX(int positions); void addToY(int positions); int getDistance(Position pos); boolean inVisionRange(Position pos); @Override int hashCode(); @Override boolean equals(Object obj);  }