Automatic code reformat
This commit is contained in:
parent
d7db9b8f82
commit
ef2fb8fa84
23 changed files with 153 additions and 107 deletions
|
@ -40,7 +40,12 @@ import io.github.lonamiwebs.klooni.screens.MainMenuScreen;
|
|||
import io.github.lonamiwebs.klooni.screens.TransitionScreen;
|
||||
|
||||
public class Klooni extends Game {
|
||||
// region Effects
|
||||
|
||||
//region Members
|
||||
|
||||
// FIXME theme should NOT be static as it might load textures which will expose it to the race condition iff GDX got initialized before or not
|
||||
public static Theme theme;
|
||||
public IEffectFactory effect;
|
||||
|
||||
// ordered list of effects. index 0 will get default if VanishEffectFactory is removed from list
|
||||
public final static IEffectFactory[] EFFECTS = {
|
||||
|
@ -51,31 +56,7 @@ public class Klooni extends Game {
|
|||
new ExplodeEffectFactory(),
|
||||
};
|
||||
|
||||
|
||||
private Map<String, Sound> effectSounds;
|
||||
|
||||
private void loadEffectSound(final String effectName) {
|
||||
FileHandle soundFile = Gdx.files.internal("sound/effect_" + effectName + ".mp3");
|
||||
if (!soundFile.exists())
|
||||
soundFile = Gdx.files.internal("sound/effect_vanish.mp3");
|
||||
|
||||
effectSounds.put(effectName, Gdx.audio.newSound(soundFile));
|
||||
}
|
||||
|
||||
public void playEffectSound() {
|
||||
effectSounds.get(effect.getName())
|
||||
.play(MathUtils.random(0.7f, 1f), MathUtils.random(0.8f, 1.2f), 0);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
//region Members
|
||||
|
||||
// FIXME theme should NOT be static as it might load textures which will expose it to the race condition iff GDX got initialized before or not
|
||||
public static Theme theme;
|
||||
public IEffectFactory effect;
|
||||
|
||||
|
||||
public Skin skin;
|
||||
|
||||
public final ShareChallenge shareChallenge;
|
||||
|
@ -158,6 +139,23 @@ public class Klooni extends Game {
|
|||
|
||||
//endregion
|
||||
|
||||
// region Effects
|
||||
|
||||
private void loadEffectSound(final String effectName) {
|
||||
FileHandle soundFile = Gdx.files.internal("sound/effect_" + effectName + ".mp3");
|
||||
if (!soundFile.exists())
|
||||
soundFile = Gdx.files.internal("sound/effect_vanish.mp3");
|
||||
|
||||
effectSounds.put(effectName, Gdx.audio.newSound(soundFile));
|
||||
}
|
||||
|
||||
public void playEffectSound() {
|
||||
effectSounds.get(effect.getName())
|
||||
.play(MathUtils.random(0.7f, 1f), MathUtils.random(0.8f, 1.2f), 0);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
//region Settings
|
||||
|
||||
private static Preferences prefs;
|
||||
|
|
|
@ -158,8 +158,7 @@ public class MoneyBuyBand extends Table {
|
|||
if (shownText.length() > infoText.length()) {
|
||||
// The old text was longer than the new one, so shorten it
|
||||
shownText.setLength(shownText.length() - 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// It can't be equal length or we wouldn't be here,
|
||||
// so avoid checking shown.length() < info.length().
|
||||
// We need to append the next character that we want to show
|
||||
|
@ -180,8 +179,7 @@ public class MoneyBuyBand extends Table {
|
|||
setTempText("cannot buy!");
|
||||
confirmButton.setVisible(false);
|
||||
cancelButton.setVisible(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.toBuy = toBuy;
|
||||
setText("confirm?");
|
||||
confirmButton.setVisible(true);
|
||||
|
|
|
@ -73,12 +73,19 @@ public abstract class ShopCard extends Actor {
|
|||
// Showcases the current effect (the shop will be showcasing them, one by one)
|
||||
// This method should be called on the same card as long as it returns true.
|
||||
// It should return false once it's done so that the next card can be showcased.
|
||||
public boolean showcase(Batch batch, float yDisplacement) { return false; }
|
||||
public boolean showcase(Batch batch, float yDisplacement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract void usedItemUpdated();
|
||||
|
||||
public abstract void use();
|
||||
|
||||
public abstract boolean isBought();
|
||||
|
||||
public abstract boolean isUsed();
|
||||
|
||||
public abstract float getPrice();
|
||||
|
||||
public abstract void performBuy();
|
||||
}
|
||||
|
|
|
@ -102,13 +102,19 @@ public abstract class BaseScorer implements BinSerializable {
|
|||
return currentScore;
|
||||
}
|
||||
|
||||
public void pause() { }
|
||||
public void resume() { }
|
||||
public void pause() {
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
abstract public boolean isGameOver();
|
||||
|
||||
abstract protected boolean isNewRecord();
|
||||
|
||||
public String gameOverReason() { return ""; }
|
||||
public String gameOverReason() {
|
||||
return "";
|
||||
}
|
||||
|
||||
abstract public void saveScore();
|
||||
|
||||
|
|
|
@ -248,7 +248,9 @@ public class Board implements BinSerializable {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean effectsDone() { return effects.size == 0; }
|
||||
public boolean effectsDone() {
|
||||
return effects.size == 0;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
|
|
@ -121,19 +121,28 @@ public class Piece {
|
|||
private static Piece fromIndex(int colorIndex, int rotateCount) {
|
||||
switch (colorIndex) {
|
||||
// Squares
|
||||
case 0: return new Piece(1, 1, 0, colorIndex);
|
||||
case 1: return new Piece(2, 2, 0, colorIndex);
|
||||
case 2: return new Piece(3, 3, 0, colorIndex);
|
||||
case 0:
|
||||
return new Piece(1, 1, 0, colorIndex);
|
||||
case 1:
|
||||
return new Piece(2, 2, 0, colorIndex);
|
||||
case 2:
|
||||
return new Piece(3, 3, 0, colorIndex);
|
||||
|
||||
// Lines
|
||||
case 3: return new Piece(1, 2, rotateCount, colorIndex);
|
||||
case 4: return new Piece(1, 3, rotateCount, colorIndex);
|
||||
case 5: return new Piece(1, 4, rotateCount, colorIndex);
|
||||
case 6: return new Piece(1, 5, rotateCount, colorIndex);
|
||||
case 3:
|
||||
return new Piece(1, 2, rotateCount, colorIndex);
|
||||
case 4:
|
||||
return new Piece(1, 3, rotateCount, colorIndex);
|
||||
case 5:
|
||||
return new Piece(1, 4, rotateCount, colorIndex);
|
||||
case 6:
|
||||
return new Piece(1, 5, rotateCount, colorIndex);
|
||||
|
||||
// L's
|
||||
case 7: return new Piece(2, rotateCount, colorIndex);
|
||||
case 8: return new Piece(3, rotateCount, colorIndex);
|
||||
case 7:
|
||||
return new Piece(2, rotateCount, colorIndex);
|
||||
case 8:
|
||||
return new Piece(3, rotateCount, colorIndex);
|
||||
}
|
||||
throw new RuntimeException("Random function is broken.");
|
||||
}
|
||||
|
|
|
@ -114,7 +114,9 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String gameOverReason() { return "time is up"; }
|
||||
public String gameOverReason() {
|
||||
return "time is up";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveScore() {
|
||||
|
|
|
@ -7,6 +7,8 @@ import io.github.lonamiwebs.klooni.game.Cell;
|
|||
|
||||
public interface IEffect {
|
||||
void setInfo(Cell deadCell, Vector2 culprit);
|
||||
|
||||
void draw(Batch batch);
|
||||
|
||||
boolean isDone();
|
||||
}
|
||||
|
|
|
@ -23,14 +23,17 @@ import io.github.lonamiwebs.klooni.game.Cell;
|
|||
|
||||
/**
|
||||
* IEffectEfactory interface has to be implemented for each effect.
|
||||
*
|
||||
* <p>
|
||||
* It tells the name and the price of the effect and will create it, when needed.
|
||||
*
|
||||
* @see IEffect
|
||||
*/
|
||||
public interface IEffectFactory {
|
||||
public String getName();
|
||||
|
||||
public String getDisplay();
|
||||
|
||||
public int getPrice();
|
||||
|
||||
public IEffect create(final Cell deadCell, final Vector2 culprit);
|
||||
}
|
||||
|
|
|
@ -311,13 +311,16 @@ class CustomizeScreen implements Screen {
|
|||
//region Empty methods
|
||||
|
||||
@Override
|
||||
public void pause() { }
|
||||
public void pause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() { }
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() { }
|
||||
public void hide() {
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
|
|
@ -258,10 +258,12 @@ class GameScreen implements Screen, InputProcessor, BinSerializable {
|
|||
//region Unused methods
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) { }
|
||||
public void resize(int width, int height) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() { }
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() { /* Hide can only be called if the menu was shown. Place logic there. */ }
|
||||
|
@ -341,7 +343,8 @@ class GameScreen implements Screen, InputProcessor, BinSerializable {
|
|||
// After it's been loaded, delete the save file
|
||||
deleteSave();
|
||||
return true;
|
||||
} catch (IOException ignored) { }
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -140,13 +140,16 @@ public class MainMenuScreen extends InputListener implements Screen {
|
|||
//region Unused methods
|
||||
|
||||
@Override
|
||||
public void pause() { }
|
||||
public void pause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() { }
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() { }
|
||||
public void hide() {
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
|
|
@ -101,19 +101,24 @@ class ShareScoreScreen implements Screen {
|
|||
//region Empty methods
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) { }
|
||||
public void resize(int width, int height) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() { }
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() { }
|
||||
public void pause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() { }
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() { }
|
||||
public void hide() {
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
|
|
@ -96,8 +96,7 @@ public class TransitionScreen implements Screen {
|
|||
fadedElapsed = 0;
|
||||
fadingOut = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
toScreen.render(delta);
|
||||
opacity = Math.min(fadedElapsed * FADE_INVERSE_DELAY, 1);
|
||||
}
|
||||
|
@ -146,13 +145,16 @@ public class TransitionScreen implements Screen {
|
|||
//region Unused methods
|
||||
|
||||
@Override
|
||||
public void pause() { }
|
||||
public void pause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() { }
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() { }
|
||||
public void hide() {
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
|
|
@ -23,5 +23,6 @@ import java.io.IOException;
|
|||
|
||||
public interface BinSerializable {
|
||||
void write(final DataOutputStream out) throws IOException;
|
||||
|
||||
void read(final DataInputStream in) throws IOException;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ public class BinSerializer {
|
|||
} finally {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ignored) { }
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +69,8 @@ public class BinSerializer {
|
|||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException ignored) { }
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue