package ruscz.game.gameOfProd.Cells; import ruscz.game.gameOfProd.Image.ImageCell; import ruscz.game.gameOfProd.Map.Map; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import java.awt.*; import java.util.Objects; public class Block extends Cell { private ImageCell imageCell; private boolean paint; private String partial; public Block(int x, int y, Map map, boolean paint) { super(x, y, WindowOfFreeMove.CELL_SIZE, Color.BLUE); this.imageCell = map.getImageCell(); this.paint = paint; this.partial = ""; } public Block(int x, int y, Map map, String partial, boolean paint) { super(x, y, WindowOfFreeMove.CELL_SIZE, Color.BLUE); this.imageCell = map.getImageCell(); this.partial = partial; this.paint = paint; } public boolean isInBlock(int x, int y) { return (this.getX() == x) && (this.getY() == y); } public boolean isInBlock(int x, int y, boolean half) { return (this.getX() == x) && (this.getY() == y) && !(partial.equals("d")); } public boolean isPartial() { return !(partial.equals("")); } @Override public void paint(Graphics2D g) { super.paint(g); if (paint) if (partial.equals("u")) g.drawImage(imageCell.getImagesOfTiles().get(imageCell.getImageFromCellMap("BLOCK")), getX() * getSize(), getY() * getSize() - (getSize() / 2), getSize(), getSize(), null); else if (partial.equals("d")) g.drawImage(imageCell.getImagesOfTiles().get(imageCell.getImageFromCellMap("BLOCK")), getX() * getSize(), getY() * getSize() + (getSize() / 2), getSize(), getSize(), null); else g.drawImage(imageCell.getImagesOfTiles().get(imageCell.getImageFromCellMap("BLOCK")), getX() * getSize(), getY() * getSize(), getSize(), getSize(), null); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; Block block = (Block) o; return paint == block.paint && Objects.equals(partial, block.partial); } }