mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 02:09:21 +07:00
Merge pull request #305 from ninjatao/fix_acquire
Add icon for aquirable tiles in city screen.
This commit is contained in:
@ -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
|
* [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
|
* [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
|
* [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)
|
cityConstructions.removeBuilding(building.name)
|
||||||
isBeingRazed=false
|
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
|
//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...
|
// 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
|
if (tileInfo.getCity()!=city) { // outside of city
|
||||||
tileGroup.setColor(0f, 0f, 0f, 0.3f)
|
if(city.canAcquireTile(tileInfo)){
|
||||||
tileGroup.yieldGroup.isVisible = false
|
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
|
} else if(tileInfo !in tilesInRange){ // within city but not close enough to be workable
|
||||||
tileGroup.yieldGroup.isVisible = false
|
tileGroup.yieldGroup.isVisible = false
|
||||||
}
|
}
|
||||||
@ -240,10 +245,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
if(goldCostOfTile>city.civInfo.gold) buyTileButton.disable()
|
if(goldCostOfTile>city.civInfo.gold) buyTileButton.disable()
|
||||||
tileTable.add(buyTileButton)
|
tileTable.add(buyTileButton)
|
||||||
}
|
}
|
||||||
if(tile.getOwner()!=null && tile.getCity()!=city
|
if(city.canAcquireTile(tile)){
|
||||||
&& tile.getOwner()!!.isPlayerCivilization()
|
|
||||||
&& tile.arialDistanceTo(city.getCenterTile()) <= 3
|
|
||||||
&& tile.neighbors.any{it.getCity()==city}){
|
|
||||||
val acquireTileButton = TextButton("Acquire".tr(),skin)
|
val acquireTileButton = TextButton("Acquire".tr(),skin)
|
||||||
acquireTileButton.onClick { city.expansion.takeOwnership(tile); game.screen = CityScreen(city); dispose() }
|
acquireTileButton.onClick { city.expansion.takeOwnership(tile); game.screen = CityScreen(city); dispose() }
|
||||||
tileTable.add(acquireTileButton)
|
tileTable.add(acquireTileButton)
|
||||||
|
@ -46,7 +46,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(
|
|||||||
populationImage!!.setPosition(width / 2 - populationImage!!.width / 2,
|
populationImage!!.setPosition(width / 2 - populationImage!!.width / 2,
|
||||||
height * 0.85f - populationImage!!.height / 2)
|
height * 0.85f - populationImage!!.height / 2)
|
||||||
|
|
||||||
if (tileInfo.isWorked()) {
|
if (tileInfo.isWorked() || city.canAcquireTile(tileInfo)) {
|
||||||
populationImage!!.color = Color.WHITE
|
populationImage!!.color = Color.WHITE
|
||||||
}
|
}
|
||||||
else if(!tileInfo.isCityCenter()){
|
else if(!tileInfo.isCityCenter()){
|
||||||
|
@ -23,7 +23,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
|
|
||||||
var resourceImage: Actor? = null
|
var resourceImage: Actor? = null
|
||||||
var improvementImage: 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 roadImages = HashMap<TileInfo, RoadImage>()
|
||||||
private val borderImages = HashMap<TileInfo, List<Image>>() // map of neighboring tile to border images
|
private val borderImages = HashMap<TileInfo, List<Image>>() // map of neighboring tile to border images
|
||||||
protected var civilianUnitImage: Group? = null
|
protected var civilianUnitImage: Group? = null
|
||||||
@ -100,6 +100,18 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
addActor(hexagon)
|
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() {
|
fun addPopulationIcon() {
|
||||||
this.
|
this.
|
||||||
populationImage = ImageGetter.getStatIcon("Population")
|
populationImage = ImageGetter.getStatIcon("Population")
|
||||||
|
Reference in New Issue
Block a user