1 | package main;
|
---|
2 |
|
---|
3 | import java.awt.Graphics;
|
---|
4 |
|
---|
5 | public class Tile extends MapObject
|
---|
6 | {
|
---|
7 | private MapImage img;
|
---|
8 |
|
---|
9 | public Tile(final MapImage img, final int x, final int y, final int z) {
|
---|
10 | super(x, y, z);
|
---|
11 | this.img = img;
|
---|
12 | }
|
---|
13 |
|
---|
14 | public Tile(final MapImage img) {
|
---|
15 | super(0, 0, 0);
|
---|
16 | this.img = img;
|
---|
17 | }
|
---|
18 |
|
---|
19 | public Tile(final Tile baseTile, final int x, final int y, final int z) {
|
---|
20 | super(baseTile, x, y, z);
|
---|
21 | this.img = baseTile.img;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public MapImage getImg() {
|
---|
25 | return this.img;
|
---|
26 | }
|
---|
27 |
|
---|
28 | @Override
|
---|
29 | public int getBoundX() {
|
---|
30 | if (this.img.type == MapType.Ground) {
|
---|
31 | return super.getBoundX() + this.img.xDrawOffset;
|
---|
32 | }
|
---|
33 | return super.getBoundX();
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public int getBoundY() {
|
---|
38 | if (this.img.type == MapType.Ground) {
|
---|
39 | return super.getBoundY() + this.img.yDrawOffset;
|
---|
40 | }
|
---|
41 | return super.getBoundY();
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public int getSortX() {
|
---|
46 | return this.loc.x + this.img.getXSortOffset();
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public int getSortY() {
|
---|
51 | return this.loc.y + this.img.getYSortOffset();
|
---|
52 | }
|
---|
53 |
|
---|
54 | @Override
|
---|
55 | public double getSortZ() {
|
---|
56 | if (this.getImg().getType() == MapType.Ground) {
|
---|
57 | return super.getSortZ();
|
---|
58 | }
|
---|
59 | return super.getSortZ() + 1.0;
|
---|
60 | }
|
---|
61 |
|
---|
62 | @Override
|
---|
63 | public void draw(final Graphics g, final int x, final int y) {
|
---|
64 | this.img.draw(g, x + this.loc.x, y + this.loc.y);
|
---|
65 | }
|
---|
66 |
|
---|
67 | @Override
|
---|
68 | public boolean equals(final Object o) {
|
---|
69 | return this.img.key == ((Tile)o).img.key;
|
---|
70 | }
|
---|
71 | }
|
---|