Add icon for aquirable tiles in city screen.

This commit is contained in:
Duan Tao 2018-12-05 15:13:06 +08:00
parent 26a4a37389
commit f1c27ca0ea
8 changed files with 410 additions and 378 deletions

View file

@ -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

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

View file

@ -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
}

View file

@ -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)

View file

@ -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()){

View file

@ -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")