siege units won't show movement hints when set up, while packing up does not cost any movement points

This commit is contained in:
martin 2019-05-15 01:02:23 +02:00
parent f113f12265
commit b805993aac
4 changed files with 29 additions and 10 deletions

View File

@ -266,7 +266,11 @@
Simplified_Chinese:"架设"
Portuguese:"Montar"
Japanese:"セットアップ"
}
},
"Pack up": { // For siege units
"German": "Einpacken"
},
"Upgrade to [unitType] ([goldCost] gold)":{ // EG Upgrade to Cannon (140 gold)
Italian:"Aggiorna a [unitType] ([goldCost] oro)"

View File

@ -78,7 +78,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
val selectedUnit = worldScreen.bottomBar.unitTable.selectedUnit
if (selectedUnit != null && selectedUnit.getTile() != tileInfo
&& selectedUnit.canMoveTo(tileInfo) && selectedUnit.movementAlgs().canReach(tileInfo)) {
&& selectedUnit.canMoveTo(tileInfo) && selectedUnit.movementAlgs().canReach(tileInfo)
&& selectedUnit.action!="Set Up") {
// this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread
queueAddMoveHereButton(selectedUnit, tileInfo)
}
@ -207,8 +208,12 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
}
private fun updateTilegroupsForSelectedUnit(unit: MapUnit, playerViewableTilePositions: HashSet<Vector2>) {
tileGroups[unit.getTile()]!!.selectUnit(unit)
// units set up can't move unless packed together
if(unit.action=="Set Up") return
for (tile: TileInfo in unit.getDistanceToTiles().keys)
if (unit.canMoveTo(tile))
tileGroups[tile]!!.showCircle(colorFromRGB(0, 120, 215))

View File

@ -124,14 +124,23 @@ class UnitActions {
if(unit.hasUnique("Must set up to ranged attack") && !unit.isEmbarked()) {
val setUp = unit.action == "Set Up"
actionList+=UnitAction("Set up", unit.currentMovement >0 && !setUp, currentAction = setUp ) {
unit.action="Set Up"
// setting up uses up all movement points
// this is to avoid problems with the idle state:
// - unit should not be idle when setting up right now
// - unit should be idle when set up in the past
unit.currentMovement=0f
}.sound("setup")
if(!setUp) {
actionList += UnitAction("Set up", unit.currentMovement > 0) {
unit.action = "Set Up"
// setting up uses up all movement points
// this is to avoid problems with the idle state:
// - unit should not be idle when setting up right now
// - unit should be idle when set up in the past
unit.currentMovement = 0f
unitTable.selectedUnit = null
}.sound("setup")
}
else {
actionList += UnitAction("Pack up", true) {
// packing together does not take any movement points
unit.action = null
}.sound("setup")
}
}
if (unit.hasUnique("Founds a new city") && !unit.isEmbarked()) {

View File

@ -44,6 +44,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
"Conduct Trade Mission" -> return ImageGetter.getUnitIcon("Great Merchant")
"Construct Customs House" -> return ImageGetter.getImprovementIcon("Customs house")
"Set up" -> return ImageGetter.getUnitIcon("Catapult")
"Pack up" -> return ImageGetter.getUnitIcon("Catapult")
"Disband unit" -> return ImageGetter.getImage("OtherIcons/DisbandUnit")
"Sleep" -> return ImageGetter.getImage("OtherIcons/Sleep")
"Explore" -> return ImageGetter.getUnitIcon("Scout")