/** * After the user clicked on a pit the seeds should be distributed in an animated fashion * * @param chosenPitIndex the index the user chose to distribute the seeds from * @param oldState the state before the user chose his pit */ void makeAnimatedMove(int chosenPitIndex, State oldState) { // disable board until the animation is over disableBoard(); state.makeMove(chosenPitIndex); PlayerColor whoseTurn = oldState.getWhoseTurn(); PlayerColor sideToPlaceSeedOn = whoseTurn; int seedAmount = oldState.getPitsOfWhoseTurn()[chosenPitIndex]; boolean lastAnimation = false; int indexToPlaceSeedIn = chosenPitIndex; int maxIndex = 6; for (int i = 1; i <= seedAmount; i++) { indexToPlaceSeedIn++; maxIndex = whoseTurn.equals(sideToPlaceSeedOn) ? 6 : 5; if ((indexToPlaceSeedIn) > maxIndex) { sideToPlaceSeedOn = sideToPlaceSeedOn.getOpposite(); indexToPlaceSeedIn = 0; } if (i == seedAmount) lastAnimation = true; graphics.animateFromPitToPit( whoseTurn, chosenPitIndex, sideToPlaceSeedOn, indexToPlaceSeedIn, 400 * (i - 1), lastAnimation); } if (this.state.getLastMoveWasOppositeCapture()) { // graphics.oppositeCaptureSound(); // TODO: give this it's own animation // //int[] opposingPits = whoseTurn.isNorth() ? // this.state.getSouthPits() : state.getNorthPits(); // int seedAmountInOpposingPit = this.state.getOppositeSeeds(); // // graphics.animateFromPitToPit(whoseTurn, indexToPlaceSeedIn, // whoseTurn, 6, seedAmount * 400 + 1400); // for(int i = 0; i < seedAmountInOpposingPit; i++) // graphics.animateFromPitToPit(whoseTurn.getOpposite(), // State.getMirrorIndex(indexToPlaceSeedIn, 5), whoseTurn, 6, // seedAmount * 400 + 1000 + 400 * i); } }