// Update choices with new tile private void setMove(String move) { for (int i = 0; i < 3; i++) { if (mWorld.getMoves()[i] == "add") { mWorld.setMoves(i, move); mWorld.setTurn(mWorld.getTurn() + 1); if (i != 2) { add.changeX((add.getX() + 11)); } break; } } mWorld.ready(false); }
// See if button was meant to be clicked @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { screenX = scaleX(screenX); screenY = scaleY(screenY); if (mWorld.isMenu()) { if (start.isTouchUp(screenX, screenY)) { mWorld.ready(true); return true; } } else if (mWorld.isRunning()) { if (add.isTouchUp(screenX, screenY)) { mWorld.choice(); } } else if (mWorld.isChoice()) { if (upLeft.isTouchUp(screenX, screenY)) { setMove("upLeft"); } if (up.isTouchUp(screenX, screenY)) { setMove("up"); } if (upRight.isTouchUp(screenX, screenY)) { setMove("upRight"); } if (down.isTouchUp(screenX, screenY)) { setMove("down"); } if (downLeft.isTouchUp(screenX, screenY)) { setMove("downLeft"); } if (downRight.isTouchUp(screenX, screenY)) { setMove("downRight"); } if (left.isTouchUp(screenX, screenY)) { setMove("left"); } if (right.isTouchUp(screenX, screenY)) { setMove("right"); } if (sUpLeft.isTouchUp(screenX, screenY)) { setMove("sUpLeft"); } if (sUp.isTouchUp(screenX, screenY)) { setMove("sUp"); } if (sUpRight.isTouchUp(screenX, screenY)) { setMove("sUpRight"); } if (sDown.isTouchUp(screenX, screenY)) { setMove("sDown"); } if (sDownLeft.isTouchUp(screenX, screenY)) { setMove("sDownLeft"); } if (sDownRight.isTouchUp(screenX, screenY)) { setMove("sDownRight"); } if (sLeft.isTouchUp(screenX, screenY)) { setMove("sLeft"); } if (sRight.isTouchUp(screenX, screenY)) { setMove("sRight"); } if (swap.isTouchUp(screenX, screenY)) { if (mWorld.getMoves()[0] == "add" || mWorld.getMoves()[1] == "add") { System.out.println("Not enough tiles available to swap"); } else { System.out.println("Swapped a tile"); swapMove(); setMove("swap"); } } for (int i = 0; i < 3; i++) { System.out.println("Move " + i + " is " + mWorld.getMoves()[i]); } System.out.println("Current turn is: " + mWorld.getTurn()); } return false; }
private void swapMove() { String temp = mWorld.getMoves()[0]; mWorld.setMoves(0, mWorld.getMoves()[1]); mWorld.setMoves(1, temp); }