mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 21:03:15 -04:00
City health is only visible for cities in visible tiles, not explored tiles
This commit is contained in:
parent
135a502990
commit
4c3231a3fe
@ -44,7 +44,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
addPopulationIcon()
|
addPopulationIcon()
|
||||||
|
|
||||||
if (tileInfo.tileMap.gameInfo.getPlayerCivilization().exploredTiles.contains(tileInfo.position)
|
if (tileInfo.tileMap.gameInfo.getPlayerCivilization().exploredTiles.contains(tileInfo.position)
|
||||||
|| viewEntireMapForDebug) updateCityButton(city) // needs to be before the update so the units will be above the city button
|
|| viewEntireMapForDebug) updateCityButton(city, isViewable) // needs to be before the update so the units will be above the city button
|
||||||
|
|
||||||
super.update(isViewable)
|
super.update(isViewable)
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
yieldGroup.setStats(tileInfo.getTileStats(UnCivGame.Current.gameInfo.getPlayerCivilization()))
|
yieldGroup.setStats(tileInfo.getTileStats(UnCivGame.Current.gameInfo.getPlayerCivilization()))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateCityButton(city: CityInfo?) {
|
private fun updateCityButton(city: CityInfo?, viewable: Boolean) {
|
||||||
if(city==null && cityButton!=null)// there used to be a city here but it was razed
|
if(city==null && cityButton!=null)// there used to be a city here but it was razed
|
||||||
{
|
{
|
||||||
cityButton!!.remove()
|
cityButton!!.remove()
|
||||||
@ -79,19 +79,22 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
|
|
||||||
cityButton!!.run {
|
cityButton!!.run {
|
||||||
clear()
|
clear()
|
||||||
val healthBarSize=100f
|
if(viewable) {
|
||||||
val healthPercent = city.health/city.getMaxHealth().toFloat()
|
val healthBarSize = 100f
|
||||||
|
val healthPercent = city.health / city.getMaxHealth().toFloat()
|
||||||
val healthBar = Table()
|
val healthBar = Table()
|
||||||
val healthPartOfBar = ImageGetter.getImage(ImageGetter.WhiteDot)
|
val healthPartOfBar = ImageGetter.getImage(ImageGetter.WhiteDot)
|
||||||
healthPartOfBar.color = when{
|
healthPartOfBar.color = when {
|
||||||
healthPercent>2/3f -> Color.GREEN
|
healthPercent > 2 / 3f -> Color.GREEN
|
||||||
healthPercent>1/3f -> Color.ORANGE
|
healthPercent > 1 / 3f -> Color.ORANGE
|
||||||
else -> Color.RED
|
else -> Color.RED
|
||||||
}
|
}
|
||||||
val emptyPartOfBar = ImageGetter.getImage(ImageGetter.WhiteDot).apply { color= Color.BLACK }
|
val emptyPartOfBar = ImageGetter.getImage(ImageGetter.WhiteDot).apply { color = Color.BLACK }
|
||||||
healthBar.add(healthPartOfBar).width(healthBarSize*healthPercent).height(5f)
|
healthBar.add(healthPartOfBar).width(healthBarSize * healthPercent).height(5f)
|
||||||
healthBar.add(emptyPartOfBar).width(healthBarSize*(1-healthPercent)).height(5f)
|
healthBar.add(emptyPartOfBar).width(healthBarSize * (1 - healthPercent)).height(5f)
|
||||||
add(healthBar).colspan(2).row()
|
add(healthBar).colspan(2).row()
|
||||||
|
}
|
||||||
|
|
||||||
if(city.isCapital()){
|
if(city.isCapital()){
|
||||||
val starImage = Image(ImageGetter.getDrawable("OtherIcons/Star.png").tint(Color.LIGHT_GRAY))
|
val starImage = Image(ImageGetter.getDrawable("OtherIcons/Star.png").tint(Color.LIGHT_GRAY))
|
||||||
add(starImage).size(20f).padLeft(10f)
|
add(starImage).size(20f).padLeft(10f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user