summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-04-01 01:00:58 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-04-01 01:00:58 +0200
commitf8ffea3395563f3964c260e0a7176b9c42d12cca (patch)
tree67858acee031bed9c1f3dba7e08b2776e7fb5625 /core/src/ch
parent9b55cf33c8765b97138472a41754203fb062020e (diff)
downloadRustAndDust-f8ffea3395563f3964c260e0a7176b9c42d12cca.zip
RustAndDust-f8ffea3395563f3964c260e0a7176b9c42d12cca.tar.gz
Ctrl: code reorder
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Ctrl.java96
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)