public Mill(Tile tile) throws UnBuildableException { super(tile, "Mill", SpriteStore.get().getSprite("mühle1.png"), 2); panel.setBoundsWorkersPanel(100, 20, 100, 20); sprite = SpriteStore.get().getSprite("mühle1.png"); sprites = new Sprite[5]; for (int i = 0; i < 5; i++) { sprites[i] = SpriteStore.get().getSprite("mühle" + i + ".png"); } farms = new ArrayList(maxFarms); radius = 200; inStock = new Stock(new Point(tile.getXPos() + 22, tile.getYPos() + 40), 4); outStock = new Stock(new Point(tile.getXPos() + 28, tile.getYPos() + 40), 4); }
private void lookForFarms() { TileMap tileMap = GV.get().getTileMap(); for (int i = 0; i < radius * 2; i += GV.get().getXTileSize()) { for (int j = 0; j < radius * 2; j += GV.get().getYTileSize()) { int x = xPos - radius + j; int y = yPos - radius + i; Tile tileToShade = tileMap.getTileByPos(x, y); if (tileToShade.getType().compareTo("black") != 0 && tileToShade.getPos().distance(this.tile.getPos()) < radius) { if (tileToShade.getBuilding() instanceof Farm) { addFarm((Farm) tileToShade.getBuilding()); } } } } }
@Override public Building addBuilding(Tile tile) throws UnBuildableException { if (this.tile == null) { Mill mill = new Mill(); tile.addEntity(new Mill(tile)); return mill; } return null; }