diff --git a/android/assets/TerrainIcons/Flood plains.png b/android/assets/TerrainIcons/Flood plains.png new file mode 100644 index 0000000000..59680f4325 Binary files /dev/null and b/android/assets/TerrainIcons/Flood plains.png differ diff --git a/android/assets/TerrainIcons/Forest.png b/android/assets/TerrainIcons/Forest.png new file mode 100644 index 0000000000..1b549eccfe Binary files /dev/null and b/android/assets/TerrainIcons/Forest.png differ diff --git a/android/assets/TerrainIcons/Jungle.png b/android/assets/TerrainIcons/Jungle.png new file mode 100644 index 0000000000..a0e4443215 Binary files /dev/null and b/android/assets/TerrainIcons/Jungle.png differ diff --git a/android/assets/TerrainIcons/Marsh.png b/android/assets/TerrainIcons/Marsh.png new file mode 100644 index 0000000000..4fd3b59225 Binary files /dev/null and b/android/assets/TerrainIcons/Marsh.png differ diff --git a/android/assets/TerrainIcons/Oasis.png b/android/assets/TerrainIcons/Oasis.png new file mode 100644 index 0000000000..8101291e7d Binary files /dev/null and b/android/assets/TerrainIcons/Oasis.png differ diff --git a/android/assets/jsons/Terrains.json b/android/assets/jsons/Terrains.json index cbd41d6ae2..289836cb21 100644 --- a/android/assets/jsons/Terrains.json +++ b/android/assets/jsons/Terrains.json @@ -4,25 +4,29 @@ name:"Grassland", type:"BaseTerrain", food:2, - movementCost:1 + movementCost:1, + RGB: [109,139,53] }, { name:"Plains", type:"BaseTerrain", food:1, production:1, - movementCost:1 + movementCost:1, + RGB: [200,208,161] }, { name:"Tundra", type:"BaseTerrain", food:1, - movementCost:1 + movementCost:1, + RGB: [125,122,113] }, { name:"Desert", type:"BaseTerrain", - movementCost:1 + movementCost:1, + RGB: [188,189,145] }, { name:"Lakes", @@ -35,7 +39,8 @@ name:"Hill", type:"BaseTerrain", production:2, - movementCost:2 + movementCost:2, + RGB: [74,81,40] }, // Terrain features diff --git a/core/src/com/unciv/models/gamebasics/Terrain.kt b/core/src/com/unciv/models/gamebasics/Terrain.kt index 89376799dd..34569577f8 100644 --- a/core/src/com/unciv/models/gamebasics/Terrain.kt +++ b/core/src/com/unciv/models/gamebasics/Terrain.kt @@ -5,27 +5,32 @@ import com.unciv.models.stats.NamedStats class Terrain : NamedStats(), ICivilopedia { override val description: String get() = this.clone().toString() - @JvmField var type: TerrainType? = null // BaseTerrain or TerrainFeature + lateinit var type: TerrainType - @JvmField var overrideStats = false + var overrideStats = false /*** * If true, other terrain layers can come over this one. For mountains, lakes etc. this is false */ - @JvmField var canHaveOverlay = true + var canHaveOverlay = true /*** * If true, nothing can be built here - not even resource improvements */ - @JvmField var unbuildable = false + var unbuildable = false /*** * For terrain features */ - @JvmField var occursOn: Collection? = null + var occursOn: Collection? = null - @JvmField var movementCost = 1 + /** + * RGB color of base terrain + */ + var RGB: List? = null + + var movementCost = 1 } diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 0f157dfb7c..abbf4efa27 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -5,42 +5,47 @@ import com.badlogic.gdx.scenes.scene2d.Group import com.badlogic.gdx.scenes.scene2d.ui.Container import com.badlogic.gdx.scenes.scene2d.ui.Image import com.badlogic.gdx.scenes.scene2d.ui.TextButton +import com.badlogic.gdx.utils.Align import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.TileInfo import com.unciv.ui.utils.HexMath import com.unciv.ui.utils.ImageGetter open class TileGroup(var tileInfo: TileInfo) : Group() { - protected var terrainImage: Image - private var terrainType: String + + protected var hexagon: Image + protected var terrainFeatureImage:Image?=null + protected var resourceImage: Image? = null protected var unitImage: Image? = null protected var improvementImage: Image? =null private var improvementType: String? = null var populationImage: Image? = null private var roadImages = HashMap() - protected var hexagon: Image? = null protected var cityButton: Container? = null init { - - terrainType = tileInfo.lastTerrain.name - val terrainFileName = "TerrainIcons/" + terrainType.replace(' ', '_') + "_(Civ5).png" - terrainImage = ImageGetter.getImage(terrainFileName) - val groupSize = 50 - terrainImage.setSize(groupSize.toFloat(), groupSize.toFloat()) - this.setSize(groupSize.toFloat(), groupSize.toFloat()) - this.addActor(terrainImage) + val groupSize = 50f + this.setSize(groupSize,groupSize) + hexagon = ImageGetter.getImage("TerrainIcons/Hexagon.png") + val imageScale = groupSize * 1.3f / hexagon.width + hexagon.setScale(imageScale) + hexagon.setOrigin(Align.center) + hexagon.setPosition((width - hexagon.width) / 2, + (height - hexagon.height) / 2) + this.addActor(hexagon) + hexagon.zIndex = 0 } fun addPopulationIcon() { populationImage = ImageGetter.getImage("StatIcons/populationGreen.png") populationImage!!.run { setSize(20f, 20f) - moveBy(0f, terrainImage.height - populationImage!!.height) + setPosition(this@TileGroup.width/2 - width/2, + this@TileGroup.height/2 - height/2 - 15) } // top left - addActor(populationImage!!) + addActor(populationImage) } protected fun removePopulationIcon() { @@ -51,30 +56,45 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { open fun update() { if (!tileInfo.explored) { - terrainImage.color = Color.BLACK + hexagon.color = Color.BLACK return } - terrainImage.color = Color.WHITE + if(terrainFeatureImage==null && tileInfo.terrainFeature!=null){ + terrainFeatureImage = ImageGetter.getImage("TerrainIcons/${tileInfo.terrainFeature}.png") + addActor(terrainFeatureImage) + terrainFeatureImage!!.run { + setSize(30f,30f) + setColor(1f,1f,1f,0.5f) + setPosition(this@TileGroup.width /2-width/2, + this@TileGroup.height/2-height/2) + } - if (terrainType != tileInfo.lastTerrain.name) { - terrainType = tileInfo.lastTerrain.name - val terrainFileName = "TerrainIcons/" + terrainType.replace(' ', '_') + "_(Civ5).png" - terrainImage.drawable = ImageGetter.getDrawable(terrainFileName) // In case we e.g. removed a jungle } + if(terrainFeatureImage!=null && tileInfo.terrainFeature==null){ + terrainFeatureImage!!.remove() + terrainFeatureImage=null + } + + val RGB= tileInfo.getBaseTerrain().RGB!! + hexagon.color = Color(RGB[0]/255f,RGB[1]/255f,RGB[2]/255f,1f) + if (tileInfo.hasViewableResource(tileInfo.tileMap!!.gameInfo!!.getPlayerCivilization()) && resourceImage == null) { // Need to add the resource image! val fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png" resourceImage = ImageGetter.getImage(fileName) resourceImage!!.setSize(20f, 20f) - resourceImage!!.moveBy(terrainImage.width - resourceImage!!.width, 0f) // bottom right + resourceImage!!.setPosition(width/2 - resourceImage!!.width/2-20f, + height/2 - resourceImage!!.height/2) // left addActor(resourceImage!!) } if (tileInfo.unit != null && unitImage == null) { unitImage = ImageGetter.getImage("UnitIcons/" + tileInfo.unit!!.name!!.replace(" ", "_") + "_(Civ5).png") addActor(unitImage!!) - unitImage!!.setSize(20f, 20f) // not moved - is at bottom left + unitImage!!.setSize(20f, 20f) + unitImage!!.setPosition(width/2 - unitImage!!.width/2, + height/2 - unitImage!!.height/2 +15) // top } if (tileInfo.unit == null && unitImage != null) { @@ -95,9 +115,10 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { addActor(improvementImage) improvementImage!!.run { setSize(20f, 20f) - moveBy(terrainImage.width - width, - terrainImage.height - height) - } // top right + + setPosition(this@TileGroup.width/2 - width/2+20f, + this@TileGroup.height/2 - height/2) // right + } improvementType = tileInfo.improvement } @@ -154,7 +175,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { // Here, we want to have the roads start HALFWAY THERE and extend towards the tiles, so we give them a position of 0.8*25. image.moveBy(-relativeWorldPosition.x * 0.8f * 25f, -relativeWorldPosition.y * 0.8f * 25f) - image.setColor(Color.RED) + image.color = Color.RED image.setOrigin(image.width/2, image.height/2) // This is so that the rotation is calculated from the middle of the road and not the edge image.rotation = (90 + 180 / Math.PI * Math.atan2(relativeWorldPosition.y.toDouble(), relativeWorldPosition.x.toDouble())).toFloat() addActor(image) diff --git a/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt b/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt index de2fcb033d..64fee11abf 100644 --- a/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt @@ -6,7 +6,6 @@ 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 @@ -29,17 +28,6 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) { if (tileInfo.workingCity == null && populationImage != null) removePopulationIcon() - if (tileInfo.owner != null && hexagon == null) { - hexagon = ImageGetter.getImage("TerrainIcons/Hexagon.png") - val imageScale = terrainImage.width * 1.3f / hexagon!!.width - hexagon!!.setScale(imageScale) - hexagon!!.setPosition((width - hexagon!!.width * imageScale) / 2, - (height - hexagon!!.height * imageScale) / 2) - addActor(hexagon!!) - hexagon!!.zIndex = 0 - } - - val city = tileInfo.city if (tileInfo.isCityCenter) { val buttonScale = 0.7f