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;
|
import io.github.lonamiwebs.klooni.screens.TransitionScreen;
|
||||||
|
|
||||||
public class Klooni extends Game {
|
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
|
// ordered list of effects. index 0 will get default if VanishEffectFactory is removed from list
|
||||||
public final static IEffectFactory[] EFFECTS = {
|
public final static IEffectFactory[] EFFECTS = {
|
||||||
|
@ -51,31 +56,7 @@ public class Klooni extends Game {
|
||||||
new ExplodeEffectFactory(),
|
new ExplodeEffectFactory(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private Map<String, Sound> effectSounds;
|
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 Skin skin;
|
||||||
|
|
||||||
public final ShareChallenge shareChallenge;
|
public final ShareChallenge shareChallenge;
|
||||||
|
@ -158,6 +139,23 @@ public class Klooni extends Game {
|
||||||
|
|
||||||
//endregion
|
//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
|
//region Settings
|
||||||
|
|
||||||
private static Preferences prefs;
|
private static Preferences prefs;
|
||||||
|
|
|
@ -158,8 +158,7 @@ public class MoneyBuyBand extends Table {
|
||||||
if (shownText.length() > infoText.length()) {
|
if (shownText.length() > infoText.length()) {
|
||||||
// The old text was longer than the new one, so shorten it
|
// The old text was longer than the new one, so shorten it
|
||||||
shownText.setLength(shownText.length() - 1);
|
shownText.setLength(shownText.length() - 1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// It can't be equal length or we wouldn't be here,
|
// It can't be equal length or we wouldn't be here,
|
||||||
// so avoid checking shown.length() < info.length().
|
// so avoid checking shown.length() < info.length().
|
||||||
// We need to append the next character that we want to show
|
// We need to append the next character that we want to show
|
||||||
|
@ -180,8 +179,7 @@ public class MoneyBuyBand extends Table {
|
||||||
setTempText("cannot buy!");
|
setTempText("cannot buy!");
|
||||||
confirmButton.setVisible(false);
|
confirmButton.setVisible(false);
|
||||||
cancelButton.setVisible(false);
|
cancelButton.setVisible(false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.toBuy = toBuy;
|
this.toBuy = toBuy;
|
||||||
setText("confirm?");
|
setText("confirm?");
|
||||||
confirmButton.setVisible(true);
|
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)
|
// 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.
|
// 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.
|
// 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 usedItemUpdated();
|
||||||
|
|
||||||
public abstract void use();
|
public abstract void use();
|
||||||
|
|
||||||
public abstract boolean isBought();
|
public abstract boolean isBought();
|
||||||
|
|
||||||
public abstract boolean isUsed();
|
public abstract boolean isUsed();
|
||||||
|
|
||||||
public abstract float getPrice();
|
public abstract float getPrice();
|
||||||
|
|
||||||
public abstract void performBuy();
|
public abstract void performBuy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,13 +102,19 @@ public abstract class BaseScorer implements BinSerializable {
|
||||||
return currentScore;
|
return currentScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause() { }
|
public void pause() {
|
||||||
public void resume() { }
|
}
|
||||||
|
|
||||||
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
abstract public boolean isGameOver();
|
abstract public boolean isGameOver();
|
||||||
|
|
||||||
abstract protected boolean isNewRecord();
|
abstract protected boolean isNewRecord();
|
||||||
|
|
||||||
public String gameOverReason() { return ""; }
|
public String gameOverReason() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
abstract public void saveScore();
|
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
|
//endregion
|
||||||
|
|
||||||
|
|
|
@ -121,19 +121,28 @@ public class Piece {
|
||||||
private static Piece fromIndex(int colorIndex, int rotateCount) {
|
private static Piece fromIndex(int colorIndex, int rotateCount) {
|
||||||
switch (colorIndex) {
|
switch (colorIndex) {
|
||||||
// Squares
|
// Squares
|
||||||
case 0: return new Piece(1, 1, 0, colorIndex);
|
case 0:
|
||||||
case 1: return new Piece(2, 2, 0, colorIndex);
|
return new Piece(1, 1, 0, colorIndex);
|
||||||
case 2: return new Piece(3, 3, 0, colorIndex);
|
case 1:
|
||||||
|
return new Piece(2, 2, 0, colorIndex);
|
||||||
|
case 2:
|
||||||
|
return new Piece(3, 3, 0, colorIndex);
|
||||||
|
|
||||||
// Lines
|
// Lines
|
||||||
case 3: return new Piece(1, 2, rotateCount, colorIndex);
|
case 3:
|
||||||
case 4: return new Piece(1, 3, rotateCount, colorIndex);
|
return new Piece(1, 2, rotateCount, colorIndex);
|
||||||
case 5: return new Piece(1, 4, rotateCount, colorIndex);
|
case 4:
|
||||||
case 6: return new Piece(1, 5, rotateCount, colorIndex);
|
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
|
// L's
|
||||||
case 7: return new Piece(2, rotateCount, colorIndex);
|
case 7:
|
||||||
case 8: return new Piece(3, rotateCount, colorIndex);
|
return new Piece(2, rotateCount, colorIndex);
|
||||||
|
case 8:
|
||||||
|
return new Piece(3, rotateCount, colorIndex);
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Random function is broken.");
|
throw new RuntimeException("Random function is broken.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,9 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String gameOverReason() { return "time is up"; }
|
public String gameOverReason() {
|
||||||
|
return "time is up";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveScore() {
|
public void saveScore() {
|
||||||
|
|
|
@ -7,6 +7,8 @@ import io.github.lonamiwebs.klooni.game.Cell;
|
||||||
|
|
||||||
public interface IEffect {
|
public interface IEffect {
|
||||||
void setInfo(Cell deadCell, Vector2 culprit);
|
void setInfo(Cell deadCell, Vector2 culprit);
|
||||||
|
|
||||||
void draw(Batch batch);
|
void draw(Batch batch);
|
||||||
|
|
||||||
boolean isDone();
|
boolean isDone();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,17 @@ import io.github.lonamiwebs.klooni.game.Cell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IEffectEfactory interface has to be implemented for each effect.
|
* 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.
|
* It tells the name and the price of the effect and will create it, when needed.
|
||||||
*
|
*
|
||||||
* @see IEffect
|
* @see IEffect
|
||||||
*/
|
*/
|
||||||
public interface IEffectFactory {
|
public interface IEffectFactory {
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
public String getDisplay();
|
public String getDisplay();
|
||||||
|
|
||||||
public int getPrice();
|
public int getPrice();
|
||||||
|
|
||||||
public IEffect create(final Cell deadCell, final Vector2 culprit);
|
public IEffect create(final Cell deadCell, final Vector2 culprit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,13 +311,16 @@ class CustomizeScreen implements Screen {
|
||||||
//region Empty methods
|
//region Empty methods
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() { }
|
public void pause() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() { }
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() { }
|
public void hide() {
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,10 +258,12 @@ class GameScreen implements Screen, InputProcessor, BinSerializable {
|
||||||
//region Unused methods
|
//region Unused methods
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height) { }
|
public void resize(int width, int height) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() { }
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() { /* Hide can only be called if the menu was shown. Place logic there. */ }
|
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
|
// After it's been loaded, delete the save file
|
||||||
deleteSave();
|
deleteSave();
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException ignored) { }
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,13 +140,16 @@ public class MainMenuScreen extends InputListener implements Screen {
|
||||||
//region Unused methods
|
//region Unused methods
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() { }
|
public void pause() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() { }
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() { }
|
public void hide() {
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,19 +101,24 @@ class ShareScoreScreen implements Screen {
|
||||||
//region Empty methods
|
//region Empty methods
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height) { }
|
public void resize(int width, int height) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() { }
|
public void dispose() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() { }
|
public void pause() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() { }
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() { }
|
public void hide() {
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,7 @@ public class TransitionScreen implements Screen {
|
||||||
fadedElapsed = 0;
|
fadedElapsed = 0;
|
||||||
fadingOut = false;
|
fadingOut = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
toScreen.render(delta);
|
toScreen.render(delta);
|
||||||
opacity = Math.min(fadedElapsed * FADE_INVERSE_DELAY, 1);
|
opacity = Math.min(fadedElapsed * FADE_INVERSE_DELAY, 1);
|
||||||
}
|
}
|
||||||
|
@ -146,13 +145,16 @@ public class TransitionScreen implements Screen {
|
||||||
//region Unused methods
|
//region Unused methods
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() { }
|
public void pause() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() { }
|
public void resume() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() { }
|
public void hide() {
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,5 +23,6 @@ import java.io.IOException;
|
||||||
|
|
||||||
public interface BinSerializable {
|
public interface BinSerializable {
|
||||||
void write(final DataOutputStream out) throws IOException;
|
void write(final DataOutputStream out) throws IOException;
|
||||||
|
|
||||||
void read(final DataInputStream in) throws IOException;
|
void read(final DataInputStream in) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,8 @@ public class BinSerializer {
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
out.close();
|
out.close();
|
||||||
} catch (IOException ignored) { }
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +69,8 @@ public class BinSerializer {
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException ignored) { }
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue