/// adds the given amount of credits to this player /// use negative amounts for substraction /// DO NOT call this method when animationsAreDone() == false /// (an animation is used to add the amount over time) public void addCreditAmount(int amount) { if (amount != 0) { creditsToAdd += amount; creditAnimationState = creditsToAdd > 0 ? GainingAnimation.START_GAINING : GainingAnimation.START_LOSING; } }
private void animateCreditBobbing() { creditClock += Time.deltaTime; switch (creditAnimationState) { case GainingAnimation.START_GAINING: credit.setBobbing(true); creditsToAdd--; credits++; controller.PlayGainCreditSound(); creditAnimationState = GainingAnimation.BOBBING; break; case GainingAnimation.START_LOSING: credit.setBobbing(true); creditsToAdd++; credits--; controller.PlayLoseCreditSound(); creditAnimationState = GainingAnimation.BOBBING; break; case GainingAnimation.BOBBING: if (creditClock > 0.4) { credit.setBobbing(false); creditAnimationState = GainingAnimation.PAUSE; } break; case GainingAnimation.PAUSE: if (creditClock > 0.5) { if (creditsToAdd != 0) { // add/remove the next credit creditAnimationState = creditsToAdd > 0 ? GainingAnimation.START_GAINING : GainingAnimation.START_LOSING; creditClock -= 0.5; } else { // the desired amount of credits was added/removed creditAnimationState = GainingAnimation.STOP; } } break; case GainingAnimation.STOP: creditClock = 0.0; // prevent ugly large values break; } }
private void animateBrickBobbing() { brickClock += Time.deltaTime; switch (brickAnimationState) { case GainingAnimation.START_GAINING: brick.setBobbing(true); bricksToAdd--; bricks++; brickAnimationState = GainingAnimation.BOBBING; break; case GainingAnimation.START_LOSING: brick.setBobbing(true); bricksToAdd++; bricks--; brickAnimationState = GainingAnimation.BOBBING; break; case GainingAnimation.BOBBING: if (brickClock > 0.4) { brick.setBobbing(false); brickAnimationState = GainingAnimation.PAUSE; } break; case GainingAnimation.PAUSE: if (brickClock > 0.5) { if (bricksToAdd != 0) { brickAnimationState = bricksToAdd > 0 ? GainingAnimation.START_GAINING : GainingAnimation.START_LOSING; brickClock -= 0.5; } else { brickAnimationState = GainingAnimation.STOP; } } break; case GainingAnimation.STOP: brickClock = 0.0; // prevent ugly large values break; } }
/// gives this player a golden brick /// DO NOT call this method when animationsAreDone() == false /// (an animation is used to add the brick) public void addGoldenBrick() { bricksToAdd++; brickAnimationState = GainingAnimation.START_GAINING; controller.PlayPickupBrickSound(); }
/// gives this player a golden brick /// DO NOT call this method when animationsAreDone() == false /// (an animation is used to add the brick) public void addGoldenBrick() { bricksToAdd++; brickAnimationState = GainingAnimation.START_GAINING; }