Example #1
0
 private void drawCellWithColor(Graphics2D g2d, TileCell cell, Color color) {
   g2d.setColor(color);
   g2d.fill(
       new Rectangle(cell.getX() + 2, cell.getY() + 2, TileCell.WIDTH - 3, TileCell.HEIGHT - 3));
   g2d.setColor(Color.BLACK);
   g2d.drawRect(cell.getX(), cell.getY(), TileCell.WIDTH, TileCell.HEIGHT);
 }
Example #2
0
 private void drawCellG(Graphics2D g2d, TileCell cell) {
   if (!cell.isShow() || cell.getG() < 0) {
     return;
   }
   g2d.drawString("" + cell.getG(), cell.getX(), (cell.getY() + TileCell.WIDTH / 2));
   // System.out.println("draw... g=" +
   // cell.getG()+", x="+cell.getX()+", y="+ (cell.getY()+RECT_SIZE/2));
 }
Example #3
0
  @Override
  public void mousePressed(MouseEvent e) {
    mousePressedPoint = e.getPoint();

    TileCell targetCell = map.getCell(TileCell.transformCellPoint(e.getPoint()));
    if (targetCell == null || !targetCell.isCanPass()) {
      return;
    }

    if (isMouseLeftKey(e)) {
      recollectActors(targetCell);
      return;
    }
    // System.out.println(targetCell);

    actorsCancelTaskAndSubmitNew(targetCell);
  }
Example #4
0
 private void recollectActors(TileCell targetCell) {
   actors.clear();
   for (Player player : players) {
     if (!player.isCollision(targetCell.getRectangle())) {
       continue;
     }
     actors.add(player);
   }
 }
Example #5
0
 private void drawMap(Graphics2D g2d, TileMap map) {
   for (TileCell[] columns : map.getCells()) {
     for (TileCell cell : columns) {
       if (cell.isEnd()) {
         drawCellWithColor(g2d, cell, Color.GREEN);
       } else if (cell.isPath()) {
         if (!cell.isStart()) {
           drawCellWithColor(g2d, cell, Color.YELLOW);
         }
         drawCellG(g2d, cell);
       } else if (!cell.isCanPass()) {
         drawCellWithColor(g2d, cell, Color.DARK_GRAY);
       } else {
         g2d.setColor(Color.BLACK);
         g2d.drawRect(cell.getX(), cell.getY(), TileCell.WIDTH, TileCell.HEIGHT);
         drawCellG(g2d, cell);
       }
     }
   }
 }