mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
Non-idle units are faded out, to show they can't move this turn
This commit is contained in:
@ -15,7 +15,6 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
protected var terrainFeatureImage:Image?=null
|
||||
|
||||
protected var resourceImage: Image? = null
|
||||
protected var unitImage: Group? = null
|
||||
protected var improvementImage: Image? =null
|
||||
private var improvementType: String? = null
|
||||
var populationImage: Image? = null
|
||||
@ -87,26 +86,6 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
addActor(resourceImage!!)
|
||||
}
|
||||
|
||||
if (tileInfo.unit != null && unitImage == null) {
|
||||
val unit = tileInfo.unit!!
|
||||
unitImage = getUnitImage(unit.name!!, unit.civInfo.getCivilization().getColor())
|
||||
addActor(unitImage!!)
|
||||
unitImage!!.setSize(20f, 20f)
|
||||
unitImage!!.setPosition(width/2 - unitImage!!.width/2,
|
||||
height/2 - unitImage!!.height/2 +20) // top
|
||||
}
|
||||
|
||||
if (tileInfo.unit == null && unitImage != null) {
|
||||
unitImage!!.remove()
|
||||
unitImage = null
|
||||
}
|
||||
|
||||
if (unitImage != null) {
|
||||
if (!tileInfo.hasIdleUnit())
|
||||
unitImage!!.color = Color.GRAY
|
||||
else
|
||||
unitImage!!.color = Color.WHITE
|
||||
}
|
||||
|
||||
|
||||
if (tileInfo.improvement != null && tileInfo.improvement != improvementType) {
|
||||
@ -186,21 +165,5 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
|
||||
}
|
||||
|
||||
private fun getUnitImage(unitType:String, color:Color): Group {
|
||||
val unitBaseImage = ImageGetter.getImage("UnitIcons/$unitType.png")
|
||||
.apply { setSize(15f,15f) }
|
||||
val background = ImageGetter.getImage("UnitIcons/Circle.png").apply {
|
||||
this.color = color
|
||||
setSize(20f,20f)
|
||||
}
|
||||
val group = Group().apply {
|
||||
setSize(background.width,background.height)
|
||||
addActor(background)
|
||||
}
|
||||
unitBaseImage.setPosition(group.width/2-unitBaseImage.width/2,
|
||||
group.height/2-unitBaseImage.height/2)
|
||||
group.addActor(unitBaseImage)
|
||||
return group
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,19 @@
|
||||
package com.unciv.ui.tilegroups
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Group
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.cityscreen.CityScreen
|
||||
import com.unciv.ui.cityscreen.addClickListener
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
|
||||
class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
var cityButton: TextButton? = null
|
||||
private var cityButton: TextButton? = null
|
||||
private var unitImage: Group? = null
|
||||
|
||||
fun setIsViewable(isViewable: Boolean) {
|
||||
if (isViewable) {
|
||||
@ -20,7 +24,6 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
setColor(0f, 0f, 0f, 0.6f)
|
||||
}
|
||||
|
||||
|
||||
fun update(worldScreen: WorldScreen) {
|
||||
super.update()
|
||||
|
||||
@ -51,5 +54,45 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
cityButton!!.zIndex = cityButton!!.parent.children.size // so city button is rendered over everything else in this tile
|
||||
}
|
||||
|
||||
|
||||
if (tileInfo.unit != null && unitImage == null) {
|
||||
val unit = tileInfo.unit!!
|
||||
unitImage = getUnitImage(unit.name!!, unit.civInfo.getCivilization().getColor())
|
||||
addActor(unitImage!!)
|
||||
unitImage!!.setSize(20f, 20f)
|
||||
unitImage!!.setPosition(width/2 - unitImage!!.width/2,
|
||||
height/2 - unitImage!!.height/2 +20) // top
|
||||
}
|
||||
|
||||
if (tileInfo.unit == null && unitImage != null) {
|
||||
unitImage!!.remove()
|
||||
unitImage = null
|
||||
}
|
||||
|
||||
if (unitImage != null) {
|
||||
if (!tileInfo.hasIdleUnit())
|
||||
unitImage!!.color = Color(1f,1f,1f,0.5f)
|
||||
else
|
||||
unitImage!!.color = Color.WHITE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun getUnitImage(unitType:String, color:Color): Group {
|
||||
val unitBaseImage = ImageGetter.getImage("UnitIcons/$unitType.png")
|
||||
.apply { setSize(15f,15f) }
|
||||
val background = ImageGetter.getImage("UnitIcons/Circle.png").apply {
|
||||
this.color = color
|
||||
setSize(20f,20f)
|
||||
}
|
||||
val group = Group().apply {
|
||||
setSize(background.width,background.height)
|
||||
addActor(background)
|
||||
}
|
||||
unitBaseImage.setPosition(group.width/2-unitBaseImage.width/2,
|
||||
group.height/2-unitBaseImage.height/2)
|
||||
group.addActor(unitBaseImage)
|
||||
return group
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user