diff --git a/src/main/java/com/fossgalaxy/games/ggj2017/MoveAction.java b/src/main/java/com/fossgalaxy/games/ggj2017/MoveAction.java index ed3fdd87d682e315385d0960c3fb611c79392759..57253b37ebcfa130c6e70c790ffc9496a0fbd696 100644 --- a/src/main/java/com/fossgalaxy/games/ggj2017/MoveAction.java +++ b/src/main/java/com/fossgalaxy/games/ggj2017/MoveAction.java @@ -48,8 +48,7 @@ public class MoveAction implements GameAction { Area area = new Area(); range.forEach(h -> { - Entity e = s.getEntityAt(h.getCubeCoordinate()); - if (e != null) { + if (!isPossible(actor, s, h.getCubeCoordinate())) { return; } @@ -66,6 +65,26 @@ public class MoveAction implements GameAction { } + + @Override + public boolean isPossible(Entity entity, GameState s, CubeCoordinate co) { + + //movement is not possible if the space is occupied + Entity e = s.getEntityAt(co); + if (e != null) { + return false; + } + + //movement is not possible if it's too far away + int movementDist = entity.getType().getMovement(); + if (movementDist < s.getDistance(entity.getPos(), co)) { + return false; + } + + //movement might not be possible + return isPossible(entity); + } + @Override public Order generateOrder(CubeCoordinate co, GameState s) { return new DroneMovement(co); diff --git a/src/main/java/com/fossgalaxy/games/ggj2017/RangeAttackAction.java b/src/main/java/com/fossgalaxy/games/ggj2017/RangeAttackAction.java index 1aa8e833693a6339ed18f22ae3c3d65fcc15a473..79141cbcfe86a6b311b0e8670d5fe65f2d08bc05 100644 --- a/src/main/java/com/fossgalaxy/games/ggj2017/RangeAttackAction.java +++ b/src/main/java/com/fossgalaxy/games/ggj2017/RangeAttackAction.java @@ -6,6 +6,7 @@ import java.awt.Graphics2D; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Area; +import java.awt.image.BufferedImage; import java.util.Collection; import java.util.List; @@ -15,6 +16,7 @@ import org.codetome.hexameter.core.api.Hexagon; import com.fossgalaxy.games.rts.GameState; import com.fossgalaxy.games.rts.entity.Entity; import com.fossgalaxy.games.rts.entity.HexagonTile; +import com.fossgalaxy.games.rts.io.SpriteRegistry; import com.fossgalaxy.games.rts.order.AttackOrderRanged; import com.fossgalaxy.games.rts.order.MoveOrder; import com.fossgalaxy.games.rts.order.Order; @@ -31,6 +33,17 @@ public class RangeAttackAction implements GameAction { return; } + if (!JamApp.isZoneOfControl(s, actor)) { + SpriteRegistry sr = SpriteRegistry.INSTANCE; + BufferedImage img = sr.getImage("ui/no-signal"); + + Hexagon<HexagonTile> ht = s.cube2hex(actor.getPos()); + + g.drawImage(img, (int)ht.getCenterX() - 25, (int)ht.getCenterY() - 25, 50, 50, null); + + return; + } + Collection<Hexagon<HexagonTile>> range = s.getRange(actor.getPos(), actor.getType().getAttackRange()); System.out.println(range); diff --git a/src/main/resources/map.json b/src/main/resources/map.json index ca09137bdb4b260d6c491dae8d57c282089f486a..c89283a0ffa193e778263e134b4e728451534bb4 100644 --- a/src/main/resources/map.json +++ b/src/main/resources/map.json @@ -8,6 +8,11 @@ "name": "blue_base", "player": 1, "loc": "3,-3,1" + }, + { + "name": "red_base", + "player": 0, + "loc": "2,3" } ], "repeated": [ diff --git a/src/main/resources/types.json b/src/main/resources/types.json index 45e42a93f44b078581e2218eee2ccf704de1ac4a..5505d27b84a8e50ec9c137c5a7e556d4e7bc4145 100644 --- a/src/main/resources/types.json +++ b/src/main/resources/types.json @@ -88,6 +88,9 @@ "image": "red/ufoRed", "scale":0.25 }, + "properties": { + "controlSignal": 10 + }, "movement": 0, "health": 10, "attackRange": 2,