diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-10-18 11:01:43 +0200 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-10-18 11:01:43 +0200 | 
| commit | 429be1b305dbef415387e9e6a5e56ad8e49fd4c0 (patch) | |
| tree | 5a1fdc9ce3e76304e0b4574c00eb69b0f878413a /core/src | |
| parent | d3518044868e4319430651cc29b627fa6bc507ba (diff) | |
| download | gdx-boardgame-429be1b305dbef415387e9e6a5e56ad8e49fd4c0.zip gdx-boardgame-429be1b305dbef415387e9e6a5e56ad8e49fd4c0.tar.gz | |
Path : add private Tile from and to
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/ch/asynk/gdx/boardgame/Path.java | 35 | 
1 files changed, 25 insertions, 10 deletions
| diff --git a/core/src/ch/asynk/gdx/boardgame/Path.java b/core/src/ch/asynk/gdx/boardgame/Path.java index 5bc46c3..de148ae 100644 --- a/core/src/ch/asynk/gdx/boardgame/Path.java +++ b/core/src/ch/asynk/gdx/boardgame/Path.java @@ -27,6 +27,8 @@ public class Path extends IterableArray<Tile> implements Disposable, Pool.Poolab      }      private Orientation finalOrientation; +    private Tile from; +    private Tile to;      private Path()      { @@ -41,6 +43,8 @@ public class Path extends IterableArray<Tile> implements Disposable, Pool.Poolab      @Override public void reset()      {          clear(); +        this.from = null; +        this.to = null;          this.finalOrientation = null;      } @@ -58,25 +62,36 @@ public class Path extends IterableArray<Tile> implements Disposable, Pool.Poolab          return s;      } -    public boolean nextVector(Piece piece, Vector3 v) +    public Tile from() +    { +        return from; +    } + +    public Tile to() +    { +        return to; +    } + +    public boolean nextPosition(Piece piece, Vector3 v)      {          if (hasNext()) { -            Tile cur = current(); -            if (piece.isOn(cur)) { +            to = current(); +            if (piece.isOn(to)) {                  // rotation ... +                from = to;                  next(); -                Orientation o = (hasNext() ? Orientation.fromTiles(cur, current()) : finalOrientation); -                // if already facing, transform into a move +                Orientation o = (hasNext() ? Orientation.fromTiles(from, current()) : finalOrientation); +                // if already facing, transform into a straight move                  if (piece.isFacing(o)) { -                    cur = current(); -                    if (cur == null) { +                    to = current(); +                    if (to == null) {                          return true;                      }                  } -                piece.getPosOn(cur, o, v); +                piece.getPosOn(to, o, v);              } else { -                // regular move, no rotation -                piece.getPosOn(cur, Orientation.fromR(v.z), v); +                // rotation finished, regular move +                piece.getPosOn(to, Orientation.fromR(v.z), v);              }              return false;          } | 
