Gave up on the idea of the attack button - if the enemy moves we need to remove the button, and it's actually very difficult to determine this.
This commit is contained in:
parent
aea7d750fd
commit
42ca98efd2
2 changed files with 2 additions and 34 deletions
|
@ -21,8 +21,8 @@ android {
|
|||
applicationId "com.unciv.app"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 213
|
||||
versionName "2.13.12"
|
||||
versionCode 214
|
||||
versionName "2.13.13"
|
||||
}
|
||||
|
||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||
|
|
|
@ -10,8 +10,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
|||
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.automation.UnitAutomation
|
||||
import com.unciv.logic.battle.Battle
|
||||
import com.unciv.logic.battle.MapUnitCombatant
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.MapUnit
|
||||
|
@ -84,41 +82,11 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||
// 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)
|
||||
}
|
||||
if(selectedUnit!=null && selectedUnit.canAttack()
|
||||
&& UnitAutomation().getAttackableEnemies(selectedUnit, selectedUnit.getDistanceToTiles())
|
||||
.map { it.tileToAttack }.contains(tileInfo))
|
||||
addAttackButton(selectedUnit, tileInfo)
|
||||
|
||||
worldScreen.bottomBar.unitTable.tileSelected(tileInfo)
|
||||
worldScreen.shouldUpdate = true
|
||||
}
|
||||
|
||||
private fun addAttackButton(attacker: MapUnit, tileInfo: TileInfo) {
|
||||
val size = 60f
|
||||
val attackButton = Group().apply { width = size;height = size; }
|
||||
attackButton.addActor(ImageGetter.getCircle().apply { width = size; height = size })
|
||||
attackButton.addActor(ImageGetter.getUnitIcon("Swordsman")
|
||||
.apply { width = size / 2; height = size / 2; center(attackButton) })
|
||||
|
||||
val unitIcon = UnitGroup(attacker, size / 2)
|
||||
unitIcon.y = size - unitIcon.height
|
||||
attackButton.addActor(unitIcon)
|
||||
|
||||
val tileGroup = tileGroups[tileInfo]!!
|
||||
addOverlayOnTileGroup(tileGroup, attackButton)
|
||||
attackButton.y += tileGroup.height
|
||||
|
||||
val battlePlan = UnitAutomation().getAttackableEnemies(attacker, attacker.getDistanceToTiles())
|
||||
.first { it.tileToAttack==tileInfo }
|
||||
attackButton.onClick {
|
||||
val battle = Battle(worldScreen.gameInfo)
|
||||
battle.moveAndAttack(MapUnitCombatant(attacker), battlePlan)
|
||||
worldScreen.shouldUpdate=true
|
||||
removeUnitActionOverlay=true
|
||||
}
|
||||
unitActionOverlay = attackButton
|
||||
}
|
||||
|
||||
private fun queueAddMoveHereButton(selectedUnit: MapUnit, tileInfo: TileInfo) {
|
||||
thread {
|
||||
/** LibGdx sometimes has these weird errors when you try to edit the UI layout from 2 separate threads.
|
||||
|
|
Loading…
Reference in a new issue