diff --git a/core/src/com/redstrate/watersymbol/screens/GameScreen.java b/core/src/com/redstrate/watersymbol/screens/GameScreen.java index 6b48f9c..4297cc1 100644 --- a/core/src/com/redstrate/watersymbol/screens/GameScreen.java +++ b/core/src/com/redstrate/watersymbol/screens/GameScreen.java @@ -342,8 +342,27 @@ public class GameScreen implements Screen { if(currentlyAwaitingAuxilaryAction) { if (currentUnit.team == Unit.Team.Enemy) { + Unit closestUnit = null; + float closestDistance = 999; + for(Unit unit : units) { + if(unit.team == Unit.Team.Player) { + float dist = Vector2.dst(unit.positionX, unit.positionY, currentUnit.positionX, currentUnit.positionY); + if(dist < closestDistance) { + closestUnit = unit; + closestDistance = dist; + } + } + } + currentlyAwaitingAuxilaryAction = false; - advanceTurn(); + + if(isAdjacent(closestUnit, currentUnit)) { + AttackAction action = new AttackAction(currentUnit, closestUnit); + executeAction(action); + } else { + advanceTurn(); + } + } else { Vector3 mousePos = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);