diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-04-01 01:00:58 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-04-01 01:00:58 +0200 |
commit | f8ffea3395563f3964c260e0a7176b9c42d12cca (patch) | |
tree | 67858acee031bed9c1f3dba7e08b2776e7fb5625 /core/src/ch/asynk | |
parent | 9b55cf33c8765b97138472a41754203fb062020e (diff) | |
download | RustAndDust-f8ffea3395563f3964c260e0a7176b9c42d12cca.zip RustAndDust-f8ffea3395563f3964c260e0a7176b9c42d12cca.tar.gz |
Ctrl: code reorder
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/Ctrl.java | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java index 4d73c17..eba5e39 100644 --- a/core/src/ch/asynk/rustanddust/game/Ctrl.java +++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java @@ -165,6 +165,54 @@ public abstract class Ctrl implements Disposable freeEvents.clear(); } + // JSON + + protected boolean isLoading() + { + return (stateType == StateType.LOADING); + } + + protected void load(Marshal.Mode mode, String payload) + { + JsonValue root = new JsonReader().parse(payload); + battle.load(mode, root); + } + + protected String unload(Marshal.Mode mode) + { + Json json = new Json(OutputType.json); + writer.getBuffer().setLength(0); + json.setWriter(writer); + battle.unload(mode, json); + writer.flush(); + return writer.toString(); + } + + // INPUTS + + public boolean drag(float x, float y, int dx, int dy) + { + if (!blockHud && hud.drag(x, y, dx, dy)) + return true; + return false; + } + + public void touchDown(float hudX, float hudY, float mapX, float mapY) + { + boolean inAnimation = (this.stateType == StateType.ANIMATION); + + if (!blockHud && hud.hit(hudX, hudY, inAnimation)) + return; + + touchedHex = (blockMap ? null : map.getHexAt(mapX, mapY)); + } + + public void touchUp(float hudX, float hudY, float mapX, float mapY) + { + if (!blockMap && (touchedHex != null) && (touchedHex == map.getHexAt(mapX, mapY))) + state.touch(touchedHex); + } + // EVENTS private Event getEvent() @@ -236,54 +284,6 @@ public abstract class Ctrl implements Disposable freeEvents.push(evt); } - // JSON - - protected boolean isLoading() - { - return (stateType == StateType.LOADING); - } - - protected void load(Marshal.Mode mode, String payload) - { - JsonValue root = new JsonReader().parse(payload); - battle.load(mode, root); - } - - protected String unload(Marshal.Mode mode) - { - Json json = new Json(OutputType.json); - writer.getBuffer().setLength(0); - json.setWriter(writer); - battle.unload(mode, json); - writer.flush(); - return writer.toString(); - } - - // INPUTS - - public boolean drag(float x, float y, int dx, int dy) - { - if (!blockHud && hud.drag(x, y, dx, dy)) - return true; - return false; - } - - public void touchDown(float hudX, float hudY, float mapX, float mapY) - { - boolean inAnimation = (this.stateType == StateType.ANIMATION); - - if (!blockHud && hud.hit(hudX, hudY, inAnimation)) - return; - - touchedHex = (blockMap ? null : map.getHexAt(mapX, mapY)); - } - - public void touchUp(float hudX, float hudY, float mapX, float mapY) - { - if (!blockMap && (touchedHex != null) && (touchedHex == map.getHexAt(mapX, mapY))) - state.touch(touchedHex); - } - // State callbacks public void setAfterAnimationState(StateType after) |