Only allow unit actions if adjacent to that unit
This commit is contained in:
parent
e5e6fef3cc
commit
2db1135447
1 changed files with 8 additions and 6 deletions
|
@ -194,12 +194,14 @@ public class GameScreen implements Screen {
|
||||||
|
|
||||||
for(Unit unit : units) {
|
for(Unit unit : units) {
|
||||||
if(unit.positionX == x && unit.positionY == y) {
|
if(unit.positionX == x && unit.positionY == y) {
|
||||||
if(unit.team != currentUnit.team) {
|
if(isAdjacent(currentUnit, unit)) {
|
||||||
actions.add(new AttackAction(currentUnit, unit));
|
if (unit.team != currentUnit.team) {
|
||||||
} else {
|
actions.add(new AttackAction(currentUnit, unit));
|
||||||
// you can't trade with yourself!
|
} else {
|
||||||
if(unit != currentUnit) {
|
// you can't trade with yourself!
|
||||||
actions.add(new TradeAction());
|
if (unit != currentUnit) {
|
||||||
|
actions.add(new TradeAction());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue