54 lines
1.9 KiB
Java
54 lines
1.9 KiB
Java
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.*;
|
|
|
|
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);
|
|
}
|
|
} |