Esempio n. 1
0
  public City getCityAt(Position p) {
    if (p.getRow() == 1 && p.getColumn() == 1) {
      return new City() {
        public Player getOwner() {
          return Player.RED;
        }

        public int getSize() {
          return 1;
        }

        public String getProduction() {
          return null;
        }

        public String getWorkforceFocus() {
          return null;
        }

        @Override
        public int getTreasure() {
          // TODO Auto-generated method stub
          return 0;
        }
      };
    }
    return null;
  }
  public City getCityAt(Position p) {
    if (p.getRow() == 1 && p.getColumn() == 1) {
      return new City() {
        public Player getOwner() {
          return Player.RED;
        }

        public int getSize() {
          return 1;
        }

        public String getProduction() {
          return null;
        }

        public String getWorkforceFocus() {
          return null;
        }

        public int getProductionCount() {
          return 0;
        }
      };
    }
    return null;
  }
Esempio n. 3
0
 public Tile getTileAt(Position p) {
   if (p.getRow() == 0 && p.getColumn() == 0) {
     return new StubTile(GameConstants.FOREST, 0, 0);
   }
   if (p.getRow() == 1 && p.getColumn() == 0) {
     return new StubTile(GameConstants.HILLS, 1, 0);
   }
   return new StubTile(GameConstants.PLAINS, 0, 1);
 }
 @Override
 public void mouseUp(MouseEvent e, int x, int y) {
   // If holding a unit then try to release it.
   if (unitOnTile && isDragging) {
     isDragging = false;
     to = GfxConstants.getPositionFromXY(x, y); // Get to position.
     game.moveUnit(from, to);
     editor.showStatus("Moved unit from " + from.toString() + " to " + to.toString());
   }
 }
 @Override
 public void mouseDown(MouseEvent e, int x, int y) {
   // Check if a unit has been selected.
   from = GfxConstants.getPositionFromXY(x, y); // Get from position.
   if (game.getUnitAt(from) != null && game.getUnitAt(from).getOwner() == game.getPlayerInTurn()) {
     unitOnTile = true;
     isDragging = true; // her tjekkes der ikke for, om der dragges. Dvs. hvis man
     // blot klikker på et unit og slipper igen på samme tile, kaldes moveUnit også
   }
   editor.showStatus("Mouse pressed at: " + from.toString());
 }
Esempio n. 6
0
 public Unit getUnitAt(Position p) {
   if (p.getRow() == 2 && p.getColumn() == 3
       || p.getRow() == 3 && p.getColumn() == 2
       || p.getRow() == 3 && p.getColumn() == 3) {
     return new StubUnit(GameConstants.ARCHER, Player.RED);
   }
   if (p.getRow() == 4 && p.getColumn() == 4) {
     return new StubUnit(GameConstants.ARCHER, Player.BLUE);
   }
   return null;
 }