This commit is contained in:
Stephan Richter
2020-12-09 23:19:30 +01:00
parent d02f66ddff
commit da7fd17f21
11 changed files with 79 additions and 44 deletions

View File

@@ -0,0 +1,33 @@
package de.srsoftware.web4rail.tiles;
import java.util.Vector;
import de.srsoftware.web4rail.BaseClass;
public class TileWithShadow extends Tile {
private Vector<Id> shadows = new Vector<Id>();
public void add(Shadow shadow) {
shadows.add(shadow.id());
}
@Override
public boolean move(int dx, int dy) {
boolean moved = super.move(dx, dy);
if (moved) placeShadows();
return moved;
}
public void placeShadows() {
removeShadows();
for (int dx=1; dx<width(); dx++) plan.place(new Shadow(this, x+dx, y));
for (int dy=1; dy<height(); dy++) plan.place(new Shadow(this, x, y+dy));
}
protected void removeShadows() {
while (!shadows.isEmpty()) {
Tile tile = BaseClass.get(shadows.remove(0));
if (tile instanceof Shadow) tile.remove();
}
}
}