package main; import java.awt.Graphics; public class Tile extends MapObject { private MapImage img; public Tile(final MapImage img, final int x, final int y, final int z) { super(x, y, z); this.img = img; } public Tile(final MapImage img) { super(0, 0, 0); this.img = img; } public Tile(final Tile baseTile, final int x, final int y, final int z) { super(baseTile, x, y, z); this.img = baseTile.img; } public MapImage getImg() { return this.img; } @Override public int getBoundX() { if (this.img.type == MapType.Ground) { return super.getBoundX() + this.img.xDrawOffset; } return super.getBoundX(); } @Override public int getBoundY() { if (this.img.type == MapType.Ground) { return super.getBoundY() + this.img.yDrawOffset; } return super.getBoundY(); } @Override public int getSortX() { return this.loc.x + this.img.getXSortOffset(); } @Override public int getSortY() { return this.loc.y + this.img.getYSortOffset(); } @Override public double getSortZ() { if (this.getImg().getType() == MapType.Ground) { return super.getSortZ(); } return super.getSortZ() + 1.0; } @Override public void draw(final Graphics g, final int x, final int y) { this.img.draw(g, x + this.loc.x, y + this.loc.y); } @Override public boolean equals(final Object o) { return this.img.key == ((Tile)o).img.key; } }