summaryrefslogtreecommitdiffstats
path: root/test/src/ch/asynk/gdx
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/ch/asynk/gdx')
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/HexScreen.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java b/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java
index 1d5947c..b6c7f28 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/HexScreen.java
@@ -1,5 +1,7 @@
package ch.asynk.gdx.boardgame.test;
+import com.badlogic.gdx.math.MathUtils;
+
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
@@ -35,7 +37,7 @@ public class HexScreen extends AbstractScreen
private enum Terrain
{
- WOODS, CITY, HILL, PLAIN;
+ WOODS(0,1), CITY(0,2), HILL(2,0), PLAIN(0,0);
static private int[] cv = {23, 74};
static private int[] hv = {68, 78, 79, 15, 45, 46};
@@ -46,6 +48,13 @@ public class HexScreen extends AbstractScreen
static public boolean v = true;
+ public int elevation;
+ public int height;
+ private Terrain(int elevation, int height) {
+ this.elevation = elevation;
+ this.height = height;
+ }
+
static public Terrain get(int k)
{
if (v) {
@@ -89,10 +98,19 @@ public class HexScreen extends AbstractScreen
this.terrain = terrain;
}
- @Override public boolean blockLos(final Tile from, final Tile to)
+ @Override public boolean blockLos(final Tile from, final Tile to, float d, float dt)
{
- if (terrain != Terrain.PLAIN) return true;
- return false;
+ int h = terrain.elevation + terrain.height;
+ if (h == 0) return false;
+
+ int e = ((Hex)from).terrain.elevation;
+ if (e > h) {
+ if (((Hex)to).terrain.elevation > h) return false;
+ return (h * dt / (e - h)) >= (d - dt);
+ } else {
+ h -= e;
+ return (h * d / dt) >= (((Hex)to).terrain.elevation - e);
+ }
}
public String toString()