예제 #1
0
 private void walk(DecoratedRobot dr)
 {
     Point currentPosition = getRobotBoardCoordinates(dr);
     Point destinationPosition = getRelativeCoordinate(currentPosition, dr.getHeading());
     if (!isPointOnBoard(destinationPosition)) {
         board[currentPosition.X, currentPosition.Y] = null;
         robotIndex.Remove(dr);
         simulatorWindow.log(dr.getName() + " fell off the board!");
     } else if (isPositionEmpty(destinationPosition)) {
         board[currentPosition.X, currentPosition.Y] = null;
         board[destinationPosition.X, destinationPosition.Y] = dr;
     }
 }
예제 #2
0
 private RobotKillEvent kill(DecoratedRobot dr)
 {
     Point p = getRelativeCoordinate(getRobotBoardCoordinates(dr), dr.getHeading());
     SimulationActor target = board[p.X, p.Y];
     if (target != null && (target.getType() == SimulationActor.Type.ROBOT)) {
         DecoratedRobot victim = (DecoratedRobot)target;
         removeRobotFromSimulation(victim);
         simulatorWindow.log(dr.getName() + " killed " + victim.getName());
         return new RobotKillEvent();
     }
     return null;
 }