@Override
 public void generateWorld(GameImpl game) {
   String line;
   for (int r = 0; r < GameConstants.WORLDSIZE; r++) {
     line = layout[r];
     for (int c = 0; c < GameConstants.WORLDSIZE; c++) {
       char tileChar = line.charAt(c);
       String type = "error";
       if (tileChar == '.') {
         type = GameConstants.OCEANS;
       }
       if (tileChar == 'o') {
         type = GameConstants.PLAINS;
       }
       if (tileChar == 'M') {
         type = GameConstants.MOUNTAINS;
       }
       if (tileChar == 'f') {
         type = GameConstants.FOREST;
       }
       if (tileChar == 'h') {
         type = GameConstants.HILLS;
       }
       Position p = new Position(r, c);
       TileImpl t = (TileImpl) game.getTileAt(p);
       t.setTypeString(type);
     }
   }
 }
 @Override
 public void performUnitAction(GameImpl game, Position p) {
   if (game.getUnitAt(p).getTypeString() == GameConstants.SETTLER) {
     CityImpl city = new CityImpl(game.getUnitAt(p).getOwner());
     game.unitMap.remove(p);
     game.cityMap.put(p, city);
   }
   if (game.getUnitAt(p).getTypeString() == GameConstants.ARCHER) {
     game.getUnitAt(p).fortify();
   }
   if (game.getUnitAt(p).getTypeString() == ThetaCiv.CHARIOT) {
     game.getUnitAt(p).fortify();
   }
 }
Ejemplo n.º 3
0
 @Override
 public void mouseDown(MouseEvent e, int x, int y) {
   game.setTileFocus(GfxConstants.getPositionFromXY(x, y));
 }