mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 02:42:16 -04:00
When displaying tiles that unit can move to, we now mark those tiles with a blue circle rather than "gray out" all other tiles - gives a much better visual cue
This commit is contained in:
parent
8798f02217
commit
2bac292ce6
@ -17,6 +17,25 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
var cityButton: Table? = null
|
||||
private var unitImage: Group? = null
|
||||
|
||||
private var circleImage = ImageGetter.getImage("UnitIcons/Circle.png")
|
||||
|
||||
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 showCircle(color:Color){
|
||||
circleImage.isVisible = true
|
||||
color.a = 0.3f
|
||||
circleImage.setColor(color)
|
||||
}
|
||||
|
||||
fun hideCircle(){circleImage.isVisible=false}
|
||||
|
||||
fun setIsViewable(isViewable: Boolean) {
|
||||
if (isViewable) {
|
||||
setColor(0f, 0f, 0f, 1f) // Only alpha really changes anything
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.unciv.ui.worldscreen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.badlogic.gdx.scenes.scene2d.Group
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent
|
||||
@ -82,16 +83,19 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
}
|
||||
|
||||
internal fun updateTiles() {
|
||||
for (WG in tileGroups.values) WG.setIsViewable(false) // also updates them
|
||||
for (WG in tileGroups.values){
|
||||
WG.setIsViewable(false)
|
||||
WG.hideCircle()
|
||||
} // also updates them
|
||||
|
||||
val viewablePositions: List<Vector2>
|
||||
if(worldScreen.unitTable.currentlyExecutingAction == null)
|
||||
viewablePositions = civInfo.getViewableTiles().map { it.position }
|
||||
else
|
||||
viewablePositions = worldScreen.unitTable.getViewablePositionsForExecutingAction()
|
||||
|
||||
for (string in viewablePositions.map { it.toString() }.filter { tileGroups.containsKey(it) })
|
||||
for (string in civInfo.getViewableTiles()
|
||||
.map { it.position.toString() }
|
||||
.filter { tileGroups.containsKey(it) })
|
||||
tileGroups[string]!!.setIsViewable(true)
|
||||
|
||||
if(worldScreen.unitTable.currentlyExecutingAction!=null)
|
||||
for(tile: TileInfo in worldScreen.unitTable.getTilesForCurrentlyExecutingAction())
|
||||
tileGroups[tile.position.toString()]!!.showCircle(Color(0f,120/255f,215/255f,1f))
|
||||
}
|
||||
|
||||
fun setCenterPosition(vector: Vector2) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.unciv.ui.worldscreen.unit
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
@ -38,14 +37,6 @@ class UnitActions {
|
||||
&& (unit.action==null || !unit.action!!.startsWith("moveTo") )){
|
||||
actionList += getUnitActionButton(unit, "Move unit", true, {
|
||||
unitTable.currentlyExecutingAction = "moveTo"
|
||||
// Set all tiles transparent except those in unit range
|
||||
for (TG in tileMapHolder.tileGroups.values) TG.setColor(0f, 0f, 0f, 0.3f)
|
||||
|
||||
val distanceToTiles = unitTable.selectedUnit!!.getDistanceToTiles()
|
||||
|
||||
for (tileInRange in distanceToTiles.keys) {
|
||||
tileMapHolder.tileGroups[tileInRange.position.toString()]!!.color = Color.WHITE
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.unciv.ui.worldscreen.unit
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.logic.map.MapUnit
|
||||
@ -76,10 +75,10 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
selectedUnit= selectedTile.unit
|
||||
}
|
||||
|
||||
fun getViewablePositionsForExecutingAction(): List<Vector2>
|
||||
fun getTilesForCurrentlyExecutingAction(): Set<TileInfo>
|
||||
{
|
||||
if(currentlyExecutingAction == "moveTo")
|
||||
return selectedUnit!!.getDistanceToTiles().keys.map { it.position }
|
||||
return emptyList()
|
||||
return selectedUnit!!.getDistanceToTiles().keys
|
||||
return emptySet()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user