Interface PieceCollection
- All Known Implementing Classes:
CompoundPieceCollection
,DefaultPieceCollection
,LayeredPieceCollection.Collection
,SimplePieceCollection
public interface PieceCollection
A PieceCollection generally holds a list of
In addition to providing a means to maintain a list of all the pieces in a map, this interface provides a means to manage the draw order of pieces, in part by grouping pieces into different visual layers for e.g. Game Piece Layer Control and Game Piece Layer components of a Map. Within each layer, pieces are also listed in the order they should be drawn (i.e. lowest index at the back/bottom, highest index at the front/top).
GamePiece
s on a Map
.
Each Map has a master CompoundPieceCollection
that contains all of its pieces, stacks, and decks -- usually
this will be a LayeredPieceCollection
but possibly a simpler DefaultPieceCollection
. Within a
CompoundPieceCollection, there may be several SimplePieceCollection
s, each containing the pieces in a single
visual layer.
In addition to providing a means to maintain a list of all the pieces in a map, this interface provides a means to manage the draw order of pieces, in part by grouping pieces into different visual layers for e.g. Game Piece Layer Control and Game Piece Layer components of a Map. Within each layer, pieces are also listed in the order they should be drawn (i.e. lowest index at the back/bottom, highest index at the front/top).
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a pieceboolean
Return true if the two pieces can be merged into a single stackvoid
clear()
Remove all piecesReturn all pieces in the collection, regardless of visibilityReturn all currently-visible pieces in the collection as a read-only arrayint
Returns the index of a piece.void
Reposition a piece to the back of all others in the same visual layervoid
Reposition a piece to the front of all others in the same visual layervoid
Removes the piece
-
Method Details
-
moveToFront
Reposition a piece to the front of all others in the same visual layer -
moveToBack
Reposition a piece to the back of all others in the same visual layer -
getPieces
GamePiece[] getPieces()Return all currently-visible pieces in the collection as a read-only array -
getAllPieces
GamePiece[] getAllPieces()Return all pieces in the collection, regardless of visibility -
canMerge
-
indexOf
Returns the index of a piece. When painting the map, pieces are drawn in order of index -- lowest index drawn first and therefore appearing "below" later pieces which are drawn on top of it. -
remove
Removes the piece -
add
Adds a piece -
clear
void clear()Remove all pieces
-