Exemplo n.º 1
0
  private void handleClickView(Point point) {
    assert point != null;
    assert Game.hasInstance();
    assert !Game.getInstance().isPaused();
    assert GameView.hasInstance();
    assert !dragBoard;

    final GameView view = GameView.getInstance();

    if (view.hasActiveTile()) {
      // Continue moving the active tile.
      assert mouseLast != null;
      assert deactivateOnRelease;
      repaint();
      return;
    }

    final Tile tile = view.findPlayableTile(point);
    if (tile != null) {
      /*
       * The local user clicked on a playable tile.
       * Activate the tile and start dragging it around.
       */
      view.activate(tile);
      deactivateOnRelease = false;
      repaint();

    } else if (!view.isInHandRect(point) && !view.isInSwapRect(point)) {
      // Start dragging the board around.
      dragBoard = true;
      view.deactivate();
      dragBoardPixelCount = 0;
      setCursor(DRAG_CURSOR);
      repaint();
    }
  }