Examples of GamePiece


Examples of com.barrybecker4.game.common.board.GamePiece

    *
    * @param g2 graphics context
    * @param position the position of the piece to render
    */
   public void render(Graphics2D g2, BoardPosition position, int cellSize, int margin, Board b) {
        GamePiece piece = position.getPiece();
        // if there is no piece, then nothing to render
        if (piece == null)
            return;

        int pieceSize = getPieceSize(cellSize, piece);
        Point pos = getPosition(position, cellSize, pieceSize, margin);
        Ellipse2D circle = new Ellipse2D.Float( pos.x, pos.y, pieceSize + 1, pieceSize + 1 );
        int hlOffset = (int) (pieceSize / 2.3 + 0.5)//spec highlight offset
        RoundGradientPaint rgp = new RoundGradientPaint(
                pos.x + hlOffset, pos.y + hlOffset, Color.white, SPEC_HIGHLIGHT_RADIUS, getPieceColor(piece) );

        g2.setPaint( rgp );
        g2.fill( circle );

        // only draw the outline if we are not in a debug mode.
        // when in debug mode we want to emphasize other annotations instead of the piece
        if ( piece.getTransparency() == 0 && (GameContext.getDebugMode() == 0) ) {
            g2.setColor( Color.black );
            g2.drawOval( pos.x, pos.y, pieceSize + 1, pieceSize + 1 );
        }

        if ( piece.getAnnotation() != null ) {
            int offset = (cellSize - pieceSize) >> 1;
            g2.setColor( getTextColor(piece) );
            g2.setFont( BASE_FONT );
            g2.drawString( piece.getAnnotation(), pos.x + 2*offset, pos.y + 3*offset);
        }
   }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

        BoardPosition position = board.getPosition( loc );
        // if there is no piece or out of bounds, then return without doing anything
        if ( (position == null) || (position.isUnoccupied()) ) {
            return;
        }
        GamePiece piece = position.getPiece();
        if ( controller.isPlayer1sTurn() != piece.isOwnedByPlayer1() )
            return; // wrong players piece

        getRenderer().setDraggedPiece(position);
    }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

        TwoPlayerMove m = (TwoPlayerMove)move;
        if ( !m.isPassOrResignation() ) {
            BoardPosition pos = getPosition(m.getToLocation());
            assert(m.getPiece() != null) : "move's piece was null :" + m;
            pos.setPiece(m.getPiece());
            GamePiece piece = pos.getPiece();
            assert (piece != null):
                    "The piece was " + piece + ". Moved to " + m.getToRow() + ", " + m.getToCol();
            if ( GameContext.getDebugMode() > 0 ) {
                piece.setAnnotation( Integer.toString(getMoveList().getNumMoves()) );
            }
        }
        return true;
    }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

    protected Move createMoveFromToken( SGFToken token)
    {
        TwoPlayerMoveToken mvToken = (TwoPlayerMoveToken) token;
        boolean player1 = token instanceof Player1MoveToken;

        return TwoPlayerMove.createMove(mvToken.getToY(), mvToken.getToX(), 0, new GamePiece(player1));
    }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

        for ( int row = 1; row <= board.getNumRows(); row++ ) {
            for ( int col = 1; col <= board.getNumCols(); col++ ) {
                BlockadeBoardPosition pos = board.getPosition( row, col );
                if ( pos.isOccupied() ) {
                    GamePiece piece = pos.getPiece();

                    // should reuse cached path if still valid.
                    PathList paths = board.findShortestPaths(pos);

                    playerPaths.getPathLengthsForPlayer(piece.isOwnedByPlayer1()).updatePathLengths(paths);
                }
            }
        }
        return playerPaths;
    }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

        int baseOffset = Math.round(increment);
        for (int i=0; i<NUM_HOMES; i++) {
            int c = baseOffset + Math.round(i*increment);

            p1Homes_[i] = new BlockadeBoardPosition(new ByteLocation(homeRow1, c), null, null, null, true, false);
            p1Homes_[i].setPiece(new GamePiece(true));
            p2Homes_[i] = new BlockadeBoardPosition(new ByteLocation(homeRow2, c), null, null, null, false, true);
            p2Homes_[i].setPiece(new GamePiece(false));
        }
    }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

             wall = new BlockadeWall(new BlockadeBoardPosition(mvToken.getWallPoint1().y, mvToken.getWallPoint1().x),
                                                       new BlockadeBoardPosition(mvToken.getWallPoint2().y, mvToken.getWallPoint2().x));

         return BlockadeMove.createMove(new ByteLocation(mvToken.getFromY(), mvToken.getFromX()),
                 new ByteLocation(mvToken.getToY(), mvToken.getToX()),
                 0, new GamePiece(player1), wall);
    }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

        // if there is no piece, or out of bounds, then return without doing anything
        if ( (position == null) || (position.isUnoccupied()) ) {
            return;
        }
        GamePiece piece = position.getPiece();
        if ( viewer.get2PlayerController().isPlayer1sTurn() != piece.isOwnedByPlayer1() )
            return; // wrong players piece

        getRenderer().setDraggedPiece(position);
    }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

      */
    private boolean checkForWin(boolean player1) {

        BoardPosition[] homes = getBoard().getPlayerHomes(!player1);
        for (BoardPosition home : homes) {
            GamePiece p = home.getPiece();
            if (p != null && p.isOwnedByPlayer1() == player1)
                return true;
        }
        return false;
    }
View Full Code Here

Examples of com.barrybecker4.game.common.board.GamePiece

    /**
     * this draws the actual piece.
     */
    @Override
    public void render( Graphics2D g2, BoardPosition position, int cellSize, int margin, Board b) {
        GamePiece piece = position.getPiece();
        if (piece != null)  {
            // render the piece as normal
            super.render( g2, position, cellSize, margin, b);
        }
        // render the south and east walls if present
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.