Add icon for aquirable tiles in city screen.
This commit is contained in:
parent
26a4a37389
commit
f1c27ca0ea
8 changed files with 410 additions and 378 deletions
|
@ -377,4 +377,4 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
|
|||
* [Sleep](https://thenounproject.com/search/?q=sleep&i=1760085) By Saeful Muslim
|
||||
* [Banner](https://thenounproject.com/term/banner/866282/) By Emir Palavan for embarked units
|
||||
* [Arrow](https://thenounproject.com/term/arrow/18123/) By uzeir syarief for moving between idle units
|
||||
|
||||
* [Replace](https://thenounproject.com/search/?q=replace&i=17858) By Mike Rowe, AU
|
||||
|
|
BIN
android/Images/StatIcons/Acquire.png
Normal file
BIN
android/Images/StatIcons/Acquire.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 782 KiB After Width: | Height: | Size: 779 KiB |
|
@ -209,5 +209,16 @@ class CityInfo {
|
|||
cityConstructions.removeBuilding(building.name)
|
||||
isBeingRazed=false
|
||||
}
|
||||
|
||||
fun canAcquireTile(newTileInfo: TileInfo): Boolean {
|
||||
val owningCity = newTileInfo.getCity()
|
||||
if (owningCity!=null && owningCity!=this
|
||||
&& newTileInfo.getOwner()!!.isPlayerCivilization()
|
||||
&& newTileInfo.arialDistanceTo(getCenterTile()) <= 3
|
||||
&& newTileInfo.neighbors.any{it.getCity()==this}) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
//endregion
|
||||
}
|
|
@ -158,8 +158,13 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||
|
||||
// this needs to happen on update, because we can buy tiles, which changes the definition of the bought tiles...
|
||||
if (tileInfo.getCity()!=city) { // outside of city
|
||||
tileGroup.setColor(0f, 0f, 0f, 0.3f)
|
||||
tileGroup.yieldGroup.isVisible = false
|
||||
if(city.canAcquireTile(tileInfo)){
|
||||
tileGroup.addAcquirableIcon()
|
||||
tileGroup.yieldGroup.isVisible = false
|
||||
} else {
|
||||
tileGroup.setColor(0f, 0f, 0f, 0.3f)
|
||||
tileGroup.yieldGroup.isVisible = false
|
||||
}
|
||||
} else if(tileInfo !in tilesInRange){ // within city but not close enough to be workable
|
||||
tileGroup.yieldGroup.isVisible = false
|
||||
}
|
||||
|
@ -240,10 +245,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||
if(goldCostOfTile>city.civInfo.gold) buyTileButton.disable()
|
||||
tileTable.add(buyTileButton)
|
||||
}
|
||||
if(tile.getOwner()!=null && tile.getCity()!=city
|
||||
&& tile.getOwner()!!.isPlayerCivilization()
|
||||
&& tile.arialDistanceTo(city.getCenterTile()) <= 3
|
||||
&& tile.neighbors.any{it.getCity()==city}){
|
||||
if(city.canAcquireTile(tile)){
|
||||
val acquireTileButton = TextButton("Acquire".tr(),skin)
|
||||
acquireTileButton.onClick { city.expansion.takeOwnership(tile); game.screen = CityScreen(city); dispose() }
|
||||
tileTable.add(acquireTileButton)
|
||||
|
|
|
@ -46,7 +46,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(
|
|||
populationImage!!.setPosition(width / 2 - populationImage!!.width / 2,
|
||||
height * 0.85f - populationImage!!.height / 2)
|
||||
|
||||
if (tileInfo.isWorked()) {
|
||||
if (tileInfo.isWorked() || city.canAcquireTile(tileInfo)) {
|
||||
populationImage!!.color = Color.WHITE
|
||||
}
|
||||
else if(!tileInfo.isCityCenter()){
|
||||
|
|
|
@ -23,7 +23,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||
|
||||
var resourceImage: Actor? = null
|
||||
var improvementImage: Actor? = null
|
||||
var populationImage: Image? = null
|
||||
var populationImage: Image? = null //reuse for acquire icon
|
||||
private val roadImages = HashMap<TileInfo, RoadImage>()
|
||||
private val borderImages = HashMap<TileInfo, List<Image>>() // map of neighboring tile to border images
|
||||
protected var civilianUnitImage: Group? = null
|
||||
|
@ -100,6 +100,18 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||
addActor(hexagon)
|
||||
}
|
||||
|
||||
fun addAcquirableIcon(){
|
||||
this.
|
||||
populationImage = ImageGetter.getStatIcon("Acquire")
|
||||
populationImage!!.run {
|
||||
color = Color.GREEN.cpy().lerp(Color.BLACK, 0.5f)
|
||||
setSize(20f, 20f)
|
||||
center(this@TileGroup)
|
||||
x += 20 // right
|
||||
}
|
||||
addActor(populationImage)
|
||||
}
|
||||
|
||||
fun addPopulationIcon() {
|
||||
this.
|
||||
populationImage = ImageGetter.getStatIcon("Population")
|
||||
|
|
Loading…
Reference in a new issue