Now shows which tile the city will next expand to
This commit is contained in:
parent
75f4301004
commit
fd5aaaeee1
5 changed files with 43 additions and 30 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.unciv.logic.city
|
package com.unciv.logic.city
|
||||||
|
|
||||||
import com.unciv.logic.Automation
|
import com.unciv.logic.Automation
|
||||||
|
import com.unciv.logic.map.TileInfo
|
||||||
|
|
||||||
class CityExpansionManager {
|
class CityExpansionManager {
|
||||||
|
|
||||||
|
@ -29,13 +30,18 @@ class CityExpansionManager {
|
||||||
private fun addNewTileWithCulture() {
|
private fun addNewTileWithCulture() {
|
||||||
cultureStored -= getCultureToNextTile()
|
cultureStored -= getCultureToNextTile()
|
||||||
|
|
||||||
for (i in 2..3) {
|
val chosenTile = getNewTile()
|
||||||
|
cityInfo.tiles.add(chosenTile!!.position)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getNewTile(): TileInfo? {
|
||||||
|
for (i in 2..5) {
|
||||||
val tiles = cityInfo.getCenterTile().getTilesInDistance(i).filter { it.getOwner() == null }
|
val tiles = cityInfo.getCenterTile().getTilesInDistance(i).filter { it.getOwner() == null }
|
||||||
if (tiles.isEmpty()) continue
|
if (tiles.isEmpty()) continue
|
||||||
val chosenTile = tiles.maxBy { Automation().rankTile(it,cityInfo.civInfo) }
|
val chosenTile = tiles.maxBy { Automation().rankTile(it,cityInfo.civInfo) }
|
||||||
cityInfo.tiles.add(chosenTile!!.position)
|
return chosenTile
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextTurn(culture: Float) {
|
fun nextTurn(culture: Float) {
|
||||||
|
|
|
@ -95,9 +95,15 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
||||||
|
|
||||||
|
|
||||||
private fun updateTileGroups() {
|
private fun updateTileGroups() {
|
||||||
|
val nextTile = city.expansion.getNewTile()
|
||||||
for (HG in tileGroups) {
|
for (HG in tileGroups) {
|
||||||
HG.update()
|
HG.update()
|
||||||
|
if(HG.tileInfo == nextTile){
|
||||||
|
HG.showCircle(Color.PURPLE)
|
||||||
|
HG.setColor(0f,0f,0f,0.7f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateCityPickerTable() {
|
private fun updateCityPickerTable() {
|
||||||
|
|
|
@ -11,29 +11,42 @@ import com.unciv.ui.utils.ImageGetter
|
||||||
|
|
||||||
open class TileGroup(var tileInfo: TileInfo) : Group() {
|
open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||||
|
|
||||||
protected var hexagon: Image
|
protected val hexagon = ImageGetter.getImage("TerrainIcons/Hexagon.png")
|
||||||
protected var terrainFeatureImage:Image?=null
|
protected var terrainFeatureImage:Image?=null
|
||||||
|
|
||||||
protected var resourceImage: Image? = null
|
protected var resourceImage: Image? = null
|
||||||
protected var improvementImage: Image? =null
|
protected var improvementImage: Image? =null
|
||||||
private var improvementType: String? = null
|
private var improvementType: String? = null
|
||||||
var populationImage: Image? = null
|
var populationImage: Image? = null
|
||||||
private var roadImages = HashMap<String, Image>()
|
private val roadImages = HashMap<String, Image>()
|
||||||
private var borderImages = ArrayList<Image>()
|
private val borderImages = ArrayList<Image>()
|
||||||
protected var unitImage: Group? = null
|
protected var unitImage: Group? = null
|
||||||
|
private val circleImage = ImageGetter.getImage("UnitIcons/Circle.png") // for blue and red circles on the tile
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val groupSize = 50f
|
val groupSize = 50f
|
||||||
this.setSize(groupSize,groupSize)
|
this.setSize(groupSize,groupSize)
|
||||||
hexagon = ImageGetter.getImage("TerrainIcons/Hexagon.png")
|
addHexagon(groupSize)
|
||||||
|
addCircleImage()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addCircleImage() {
|
||||||
|
circleImage.width = 50f
|
||||||
|
circleImage.height = 50f
|
||||||
|
circleImage.setPosition(width / 2 - circleImage.width / 2,
|
||||||
|
height / 2 - circleImage.height / 2)
|
||||||
|
addActor(circleImage)
|
||||||
|
circleImage.isVisible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addHexagon(groupSize: Float) {
|
||||||
val imageScale = groupSize * 1.5f / hexagon.width
|
val imageScale = groupSize * 1.5f / hexagon.width
|
||||||
hexagon.setScale(imageScale)
|
hexagon.setScale(imageScale)
|
||||||
hexagon.setOrigin(Align.center)
|
hexagon.setOrigin(Align.center)
|
||||||
hexagon.setPosition((width - hexagon.width) / 2,
|
hexagon.setPosition((width - hexagon.width) / 2,
|
||||||
(height - hexagon.height) / 2)
|
(height - hexagon.height) / 2)
|
||||||
this.addActor(hexagon)
|
|
||||||
hexagon.zIndex = 0
|
hexagon.zIndex = 0
|
||||||
|
addActor(hexagon)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPopulationIcon() {
|
fun addPopulationIcon() {
|
||||||
|
@ -58,6 +71,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hideCircle()
|
||||||
updateTerrainFeatureImage()
|
updateTerrainFeatureImage()
|
||||||
updateTileColor(isViewable)
|
updateTileColor(isViewable)
|
||||||
updateResourceImage()
|
updateResourceImage()
|
||||||
|
@ -69,7 +83,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||||
|
|
||||||
private fun updateBorderImages() {
|
private fun updateBorderImages() {
|
||||||
for (border in borderImages) border.remove() //clear
|
for (border in borderImages) border.remove() //clear
|
||||||
borderImages = arrayListOf()
|
borderImages.clear()
|
||||||
|
|
||||||
if (tileInfo.getOwner() != null) {
|
if (tileInfo.getOwner() != null) {
|
||||||
for (neighbor in tileInfo.neighbors.filter { it.getOwner() != tileInfo.getOwner() }) {
|
for (neighbor in tileInfo.neighbors.filter { it.getOwner() != tileInfo.getOwner() }) {
|
||||||
|
@ -221,4 +235,11 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun showCircle(color:Color){
|
||||||
|
circleImage.isVisible = true
|
||||||
|
color.a = 0.3f
|
||||||
|
circleImage.color = color
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hideCircle(){circleImage.isVisible=false}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package com.unciv.ui.tilegroups
|
package com.unciv.ui.tilegroups
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
|
@ -15,16 +14,6 @@ import com.unciv.ui.utils.ImageGetter
|
||||||
|
|
||||||
class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||||
var cityButton: Table? = null
|
var cityButton: Table? = null
|
||||||
private var circleImage = ImageGetter.getImage("UnitIcons/Circle.png") // for blue and red circles on the tile
|
|
||||||
|
|
||||||
init{
|
|
||||||
circleImage.width = 50f
|
|
||||||
circleImage.height = 50f
|
|
||||||
circleImage.setPosition(width/2-circleImage.width/2,
|
|
||||||
height/2-circleImage.height/2)
|
|
||||||
addActor(circleImage)
|
|
||||||
circleImage.isVisible = false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addWhiteCircleAroundUnit(){
|
fun addWhiteCircleAroundUnit(){
|
||||||
val whiteCircle = ImageGetter.getImage("UnitIcons/Circle.png")
|
val whiteCircle = ImageGetter.getImage("UnitIcons/Circle.png")
|
||||||
|
@ -35,14 +24,6 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||||
whiteCircle.toBack()
|
whiteCircle.toBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showCircle(color:Color){
|
|
||||||
circleImage.isVisible = true
|
|
||||||
color.a = 0.3f
|
|
||||||
circleImage.color = color
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hideCircle(){circleImage.isVisible=false}
|
|
||||||
|
|
||||||
|
|
||||||
override fun update(isViewable: Boolean) {
|
override fun update(isViewable: Boolean) {
|
||||||
super.update(isViewable)
|
super.update(isViewable)
|
||||||
|
|
|
@ -85,7 +85,6 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||||
|
|
||||||
internal fun updateTiles() {
|
internal fun updateTiles() {
|
||||||
for (WG in tileGroups.values){
|
for (WG in tileGroups.values){
|
||||||
WG.hideCircle()
|
|
||||||
WG.update(false)
|
WG.update(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue