diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-05-03 15:31:32 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-05-03 15:31:32 +0200 |
commit | 79793cf2dd5cad2af5fa513a7213292d2ee53f86 (patch) | |
tree | 306e849be86d992a543e42c8e8ddec80d24795a6 /core/src/ch/asynk/rustanddust/engine | |
parent | cff800a98e8aec4e454c5dc84fd4249b7127a1fd (diff) | |
download | RustAndDust-79793cf2dd5cad2af5fa513a7213292d2ee53f86.zip RustAndDust-79793cf2dd5cad2af5fa513a7213292d2ee53f86.tar.gz |
OMG: add event queue, messages, replay, bounce animation, complete states rewrite ...
Diffstat (limited to 'core/src/ch/asynk/rustanddust/engine')
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/Board.java | 54 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/Move.java | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 12 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/Pawn.java | 30 |
4 files changed, 19 insertions, 87 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java index ace94d6..f7fed7e 100644 --- a/core/src/ch/asynk/rustanddust/engine/Board.java +++ b/core/src/ch/asynk/rustanddust/engine/Board.java @@ -18,9 +18,6 @@ import ch.asynk.rustanddust.engine.util.IterableSet; import ch.asynk.rustanddust.engine.util.Collection; import ch.asynk.rustanddust.engine.gfx.Moveable; import ch.asynk.rustanddust.engine.gfx.Animation; -import ch.asynk.rustanddust.engine.gfx.animations.AnimationSequence; -import ch.asynk.rustanddust.engine.gfx.animations.RunnableAnimation; -import ch.asynk.rustanddust.engine.gfx.animations.MoveToAnimation.MoveToAnimationCb; public abstract class Board implements Disposable, Animation { @@ -404,7 +401,7 @@ public abstract class Board implements Disposable, Animation } } - return entry.opposite(); + return entry; } public int objectivesCount(Faction faction) @@ -491,7 +488,6 @@ public abstract class Board implements Disposable, Animation public Pawn setPawnOnto(Pawn pawn, Move move) { - pawn.move(move); return setPawnOnto(pawn, move.to, move.orientation); } @@ -502,54 +498,6 @@ public abstract class Board implements Disposable, Animation return pawn; } - private RunnableAnimation getSetPawnOntoAnimation(final Pawn pawn) - { - return RunnableAnimation.get(pawn, new Runnable() { - @Override - public void run() { - Tile to = pawn.move.to; - if (!to.isOffMap()) - setPawnOnto(pawn, to, pawn.move.orientation); - } - }); - } - - protected void movePawn(final Pawn pawn, Move move, MoveToAnimationCb cb) - { - pawn.move(move); - removePawn(pawn); - - AnimationSequence seq = pawn.getMoveAnimation(move.iterator(), (move.steps() + 1), cb); - seq.addAnimation(getSetPawnOntoAnimation(pawn)); - addAnimation(seq); - } - - protected void enterPawn(final Pawn pawn, Move move) - { - pawn.move(move); - setPawnOnto(pawn, move.to, move.orientation); - } - - protected void revertLastPawnMove(final Pawn pawn, final Move move) - { - removePawn(pawn); - - revertclaim(pawn, move.to); - for (Tile tile : move.tiles) - revertclaim(pawn, tile); - claim(pawn, move.from); - - AnimationSequence seq = pawn.getRevertLastMoveAnimation(1); - seq.addAnimation(RunnableAnimation.get(pawn, new Runnable() { - @Override - public void run() { - pushPawnOnto(pawn, pawn.getTile()); - } - })); - addAnimation(seq); - pawn.revertLastMove(); - } - public void attack(final Pawn pawn, final Pawn target, boolean clearVisibility) { if (!pawn.canEngage(target) || !searchBoard.canAttack(pawn, target, clearVisibility)) diff --git a/core/src/ch/asynk/rustanddust/engine/Move.java b/core/src/ch/asynk/rustanddust/engine/Move.java index 09e7330..ff927c0 100644 --- a/core/src/ch/asynk/rustanddust/engine/Move.java +++ b/core/src/ch/asynk/rustanddust/engine/Move.java @@ -49,11 +49,10 @@ public class Move extends Path implements Iterable<Vector3>, Iterator movePool.clear(); } - public static Move getEnter(Pawn pawn, Tile to, Orientation orientation) + public static Move getEnter(Pawn pawn, Tile from, Tile to, Orientation orientation, Path path) { - Move m = get(pawn, null, to, orientation, null); + Move m = get(pawn, from, to, orientation, path); m.type = MoveType.ENTER; - m.cost = to.costFrom(pawn, orientation); return m; } @@ -122,11 +121,6 @@ public class Move extends Path implements Iterable<Vector3>, Iterator return (type == MoveType.REGULAR); } - public boolean isFinal() - { - return (type != MoveType.ENTER); - } - public int steps() { int steps = 0; diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index edac1c3..609fe8b 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -294,6 +294,18 @@ public class PathBuilder implements Disposable return Move.get(pawn, from, to, orientation, getPath(0)); } + public Move getEnterMove(Pawn pawn, Tile from) + { + // getPath(0).tiles.insert(this.from, 0); + // this.from = from; + int cost = pawn.getSpentMovementPoints(); + pawn.reset(); + Move move = getMove(); + move.type = Move.MoveType.ENTER; + move.cost = cost + ((this.from == this.to) ? 0 : move.cost); + return move; + } + public Move getExitMove() { Move move = getMove(); diff --git a/core/src/ch/asynk/rustanddust/engine/Pawn.java b/core/src/ch/asynk/rustanddust/engine/Pawn.java index fc0323f..d7c8749 100644 --- a/core/src/ch/asynk/rustanddust/engine/Pawn.java +++ b/core/src/ch/asynk/rustanddust/engine/Pawn.java @@ -115,20 +115,14 @@ public abstract class Pawn implements Moveable, Disposable { switch(move.type) { - case REGULAR: - if ((this.move != null) && (!this.move.isEnter())) - throw new RuntimeException("try to override an existing move instance"); + case SET: break; + case REGULAR: case ENTER: - if (this.move != null) - throw new RuntimeException("try to override an existing move instance"); - break; case EXIT: if (this.move != null) throw new RuntimeException("try to override an existing move instance"); break; - case SET: - break; default: throw new RuntimeException("unsupported MoveType"); } @@ -144,11 +138,6 @@ public abstract class Pawn implements Moveable, Disposable attack.distance = distance; } - public boolean justEntered() - { - return ((move != null) && move.isEnter()); - } - public boolean is(Faction faction) { return (this.faction == faction); @@ -333,28 +322,17 @@ public abstract class Pawn implements Moveable, Disposable return hasOverlayEnabled(); } - public AnimationSequence getRotateAnimation(float z, int size) - { - prevPosition.set(position); - AnimationSequence seq = AnimationSequence.get(1 + size); - seq.addAnimation(MoveToAnimation.get(this, position.x, position.y, z, MOVE_TIME)); - - return seq; - } - - public AnimationSequence getMoveAnimation(Iterator<Vector3> vectors, int size, MoveToAnimation.MoveToAnimationCb cb) + public AnimationSequence getMoveAnimation(Iterator<Vector3> vectors, AnimationSequence seq, MoveToAnimation.MoveToAnimationCb cb) { prevPosition.set(position); - AnimationSequence seq = AnimationSequence.get(size); while (vectors.hasNext()) seq.addAnimation(MoveToAnimation.get(this, vectors.next(), MOVE_TIME, cb)); return seq; } - public AnimationSequence getRevertLastMoveAnimation(int size) + public AnimationSequence getRevertLastMoveAnimation(AnimationSequence seq) { - AnimationSequence seq = AnimationSequence.get(2 + size); seq.addAnimation(MoveToAnimation.get(this, prevPosition, MOVE_TIME)); seq.addAnimation(RunnableAnimation.get(this, new Runnable() { @Override |