From 62106616cb709d8e5253424a8ca1e0d05ed80e7b Mon Sep 17 00:00:00 2001 From: forteri76 Date: Tue, 13 May 2014 00:24:50 +0000 Subject: [PATCH] Fixed network game issues. --- src/org/jfedor/frozenbubble/Compressor.java | 12 ++++++++---- src/org/jfedor/frozenbubble/FrozenBubble.java | 8 ++++++++ src/org/jfedor/frozenbubble/FrozenGame.java | 15 +++++++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/org/jfedor/frozenbubble/Compressor.java b/src/org/jfedor/frozenbubble/Compressor.java index 8b733f7..26f34eb 100644 --- a/src/org/jfedor/frozenbubble/Compressor.java +++ b/src/org/jfedor/frozenbubble/Compressor.java @@ -58,14 +58,13 @@ public class Compressor { private BmpWrap compressorHead; private BmpWrap compressor; - double moveDown; - int steps; + private double moveDown; + private int steps; public Compressor(BmpWrap compressorHead, BmpWrap compressor) { this.compressorHead = compressorHead; this.compressor = compressor; - this.moveDown = 0.; - this.steps = 0; + init(); } public double getMoveDown() { @@ -76,6 +75,11 @@ public int getSteps() { return steps; } + public void init() { + moveDown = 0.; + steps = 0; + } + public void moveDown() { moveDown += 28.; steps++; diff --git a/src/org/jfedor/frozenbubble/FrozenBubble.java b/src/org/jfedor/frozenbubble/FrozenBubble.java index 5f6f5a3..2e7b102 100644 --- a/src/org/jfedor/frozenbubble/FrozenBubble.java +++ b/src/org/jfedor/frozenbubble/FrozenBubble.java @@ -448,6 +448,7 @@ public synchronized static int getCollision() { public synchronized static void setCollision(int newCollision) { collision = newCollision; + BubbleSprite.setCollisionThreshold(collision); } public synchronized static boolean getCompressor() { @@ -839,6 +840,9 @@ private void playMusic(boolean startPlaying) allowUnpause = true; } + /** + * Load the game options from the saved shared preferences. + */ private void restoreGamePrefs() { SharedPreferences mConfig = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); @@ -853,6 +857,10 @@ private void restoreGamePrefs() { soundOn = mConfig.getBoolean("soundOn", true ); targetMode = mConfig.getInt ("targetMode", POINT_TO_SHOOT ); + /* + * Some game options require additional handling to fully implement + * changes to game play. + */ BubbleSprite.setCollisionThreshold(collision); setTargetModeOrientation(); } diff --git a/src/org/jfedor/frozenbubble/FrozenGame.java b/src/org/jfedor/frozenbubble/FrozenGame.java index e49afbf..975f433 100644 --- a/src/org/jfedor/frozenbubble/FrozenGame.java +++ b/src/org/jfedor/frozenbubble/FrozenGame.java @@ -365,14 +365,16 @@ private boolean checkLost() { lost = true; } } - + + int steps = compressor.getSteps(); + for (int i = 0; i < 8; i++) { - if (bubblePlay[i][12 - compressor.steps] != null) { + if (bubblePlay[i][12 - steps] != null) { lost = true; break; } } - + if (lost) { penguin.updateState(PenguinSprite.STATE_GAME_LOST); if (highscoreManager != null) @@ -459,7 +461,7 @@ public int getAttackBarBubbles() { } public int getCompressorSteps() { - return compressor.steps; + return compressor.getSteps(); } public int getCurrentColor() { @@ -1306,6 +1308,11 @@ public void setGrid(byte[][] newGrid) { } } } + int steps = compressor.getSteps(); + compressor.init(); + for (int index = 0; index < steps; index++) { + lowerCompressor(false); + } } public void setLaunchBubbleColors(int current, int next, int newNext) {