1 package de.lathanda.eos.robot;
3 import de.lathanda.eos.base.MutableColor;
4 import de.lathanda.eos.base.util.Direction;
5 import de.lathanda.eos.robot.exceptions.CubeImmutableException;
6 import de.lathanda.eos.robot.exceptions.CubeMissingException;
7 import de.lathanda.eos.robot.exceptions.RobotException;
8 import de.lathanda.eos.robot.exceptions.RobotMovementFailedException;
9 import de.lathanda.eos.robot.exceptions.RobotVoidException;
10 import de.lathanda.eos.robot.gui.Configuration;
11 import de.lathanda.eos.robot.gui.Configuration.ConfigurationListener;
23 public static final int SIZE = 3;
93 return getColumn(direction);
100 private Column getColumn(Direction d)
throws RobotVoidException {
102 return world.
getColumn(
new Coordinate(x + d.dx, y + d.dy));
104 throw new RobotVoidException();
111 private Column getColumn(
int x,
int y)
throws RobotVoidException {
113 return world.
getColumn(
new Coordinate(x, y));
115 throw new RobotVoidException();
122 private Column getColumn() throws RobotVoidException {
124 return world.
getColumn(
new Coordinate(x, y));
126 throw new RobotVoidException();
135 private void setPosition(
int x,
int y,
int z) {
200 for (
int i = n; i --> 0; ) {
224 direction = direction.
getLeft();
246 Column columnTo = getColumn(d);
249 setPosition(x + d.dx, y + d.dy, newZ);
251 throw new RobotMovementFailedException();
259 stepDirection(direction);
268 for(
int i = count; i --> 0; ) {
278 stepDirection(direction.
getBack());
285 stepDirection(direction.
getLeft());
293 stepDirection(direction.
getRight());
309 return isObstacleDirection(direction);
317 return isObstacleDirection(direction.
getLeft());
325 return isObstacleDirection(direction.
getRight());
333 return isObstacleDirection(direction.
getBack());
342 private void flyDirection(
int dx,
int dy,
int dz)
throws RobotException {
345 setPosition(x + dx, y + dy, z+dz);
347 throw new RobotMovementFailedException();
356 flyDirection(0,0,-1);
372 flyDirection(direction.
dx, direction.
dy, 0);
405 private boolean isFreeDirection(
int dx,
int dy,
int dz)
throws RobotException {
406 return getColumn(x+dx, y+dy).
isFree(z+dz,
SIZE);
413 return isFreeDirection(direction.
dx, direction.
dy, 0);
441 return isFreeDirection(0,0,1);
448 return isFreeDirection(0,0,-1);
493 return frontColumn().
hasCube();
502 return frontColumn().
hasCube(n);
537 this.robotColor = robotColor;
static final MutableColor BLUE
static final MutableColor RED
boolean isFree(int level, int size)
void setMark(boolean mark)
void dropCube(int level, Cube cube)
void setCube(int level, Cube cube)
void removeCube(int level)
MutableColor stoneColor(int level)
int isReachable(int level, int size, int climb, int fall)
static Cube createStone(MutableColor stoneColor)
boolean isRightObstacle()
final void setMark(MutableColor c)
final boolean isMarked(MutableColor c)
void setStoneColor(MutableColor c)
final MutableColor stoneColor()
void robotConfigurationChanged(int fallheight, int jumpheight)
final void dropStone(MutableColor c)
void placeStone(int n, MutableColor c)
void initialize(World world, int x, int y, int z, Direction d)
void setRobotColor(MutableColor robotColor)
MutableColor getRobotColor()
MutableColor getStoneColor()
Column getColumn(int x, int y)
synchronized void addConfigurationListener(ConfigurationListener cf)
static final Configuration def
final Direction getRight()
final Direction getLeft()