Clear put piece and take more if hand is finished
This commit is contained in:
parent
4ec6b31eb1
commit
30f5a16e9d
1 changed files with 13 additions and 2 deletions
|
@ -41,6 +41,14 @@ public class PieceHolder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean handFinished() {
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
if (pieces[i] != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Pick the piece below the finger/mouse
|
// Pick the piece below the finger/mouse
|
||||||
public boolean pickPiece() {
|
public boolean pickPiece() {
|
||||||
Vector2 mouse = new Vector2(
|
Vector2 mouse = new Vector2(
|
||||||
|
@ -48,7 +56,7 @@ public class PieceHolder {
|
||||||
Gdx.graphics.getHeight() - Gdx.input.getY()); // Y axis is inverted
|
Gdx.graphics.getHeight() - Gdx.input.getY()); // Y axis is inverted
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (pieces[i].getRectangle().contains(mouse)) {
|
if (pieces[i] != null && pieces[i].getRectangle().contains(mouse)) {
|
||||||
heldPiece = i;
|
heldPiece = i;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -61,9 +69,12 @@ public class PieceHolder {
|
||||||
public boolean dropPiece(Board board) {
|
public boolean dropPiece(Board board) {
|
||||||
if (heldPiece > -1) {
|
if (heldPiece > -1) {
|
||||||
if (board.putScreenPiece(pieces[heldPiece])) {
|
if (board.putScreenPiece(pieces[heldPiece])) {
|
||||||
// TODO Remove the piece
|
pieces[heldPiece] = null;
|
||||||
}
|
}
|
||||||
heldPiece = -1;
|
heldPiece = -1;
|
||||||
|
if (handFinished())
|
||||||
|
takeMore();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue