diff --git a/android/Images/TileSets/FantasyHex/CivilianLandUnit.png b/android/Images/TileSets/FantasyHex/CivilianLandUnit.png new file mode 100644 index 0000000000..34516da16b Binary files /dev/null and b/android/Images/TileSets/FantasyHex/CivilianLandUnit.png differ diff --git a/android/Images/TileSets/FantasyHex/LandUnit.png b/android/Images/TileSets/FantasyHex/LandUnit.png new file mode 100644 index 0000000000..34516da16b Binary files /dev/null and b/android/Images/TileSets/FantasyHex/LandUnit.png differ diff --git a/android/Images/TileSets/FantasyHex/Settler.png b/android/Images/TileSets/FantasyHex/Settler.png new file mode 100644 index 0000000000..67809169a4 Binary files /dev/null and b/android/Images/TileSets/FantasyHex/Settler.png differ diff --git a/android/Images/TileSets/FantasyHex/WaterUnit.png b/android/Images/TileSets/FantasyHex/WaterUnit.png new file mode 100644 index 0000000000..d8cf3e15e7 Binary files /dev/null and b/android/Images/TileSets/FantasyHex/WaterUnit.png differ diff --git a/android/Images/TileSets/FantasyHex/Worker.png b/android/Images/TileSets/FantasyHex/Worker.png new file mode 100644 index 0000000000..9af6901e72 Binary files /dev/null and b/android/Images/TileSets/FantasyHex/Worker.png differ diff --git a/android/assets/game.atlas b/android/assets/game.atlas index 9287cf7487..378b15b0cd 100644 --- a/android/assets/game.atlas +++ b/android/assets/game.atlas @@ -2449,7 +2449,7 @@ TileSets/FantasyHex/TopRightBorder index: -1 TileSets/FantasyHex/Grassland+Forest rotate: false - xy: 226, 12 + xy: 294, 12 size: 31, 29 orig: 31, 29 offset: 0, 0 @@ -2489,23 +2489,30 @@ TileSets/FantasyHex/Lakes orig: 32, 28 offset: 0, 0 index: -1 +TileSets/FantasyHex/LandUnit + rotate: false + xy: 750, 1395 + size: 32, 28 + orig: 32, 28 + offset: 0, 0 + index: -1 TileSets/FantasyHex/Mountain rotate: false - xy: 750, 1387 + xy: 972, 1345 size: 32, 36 orig: 32, 36 offset: 0, 0 index: -1 TileSets/FantasyHex/Ocean rotate: false - xy: 972, 1353 + xy: 1698, 76 size: 32, 28 orig: 32, 28 offset: 0, 0 index: -1 TileSets/FantasyHex/Plains rotate: false - xy: 1698, 76 + xy: 666, 69 size: 32, 28 orig: 32, 28 offset: 0, 0 @@ -2519,46 +2526,53 @@ TileSets/FantasyHex/Plains+City index: -1 TileSets/FantasyHex/Plains+Forest rotate: false - xy: 666, 64 + xy: 570, 36 size: 32, 33 orig: 32, 33 offset: 0, 0 index: -1 TileSets/FantasyHex/Plains+Jungle rotate: false - xy: 570, 34 + xy: 874, 20 size: 32, 35 orig: 32, 35 offset: 0, 0 index: -1 TileSets/FantasyHex/TopBorder rotate: false - xy: 874, 27 + xy: 604, 17 size: 32, 28 orig: 32, 28 offset: 0, 0 index: -1 TileSets/FantasyHex/Tundra rotate: false - xy: 604, 13 + xy: 158, 10 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 TileSets/FantasyHex/Tundra+City rotate: false - xy: 158, 7 + xy: 192, 7 size: 32, 35 orig: 32, 35 offset: 0, 0 index: -1 TileSets/FantasyHex/Tundra+Forest rotate: false - xy: 192, 10 + xy: 226, 9 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 +TileSets/FantasyHex/WaterUnit + rotate: false + xy: 260, 15 + size: 32, 26 + orig: 32, 26 + offset: 0, 0 + index: -1 UnitIcons/Anti-Aircraft Gun rotate: false xy: 1344, 1433 diff --git a/android/assets/game.png b/android/assets/game.png index ba19db27f0..ccb08705ee 100644 Binary files a/android/assets/game.png and b/android/assets/game.png differ diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 585e877574..dfd9b46591 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -18,7 +18,6 @@ import com.unciv.ui.utils.center import com.unciv.ui.utils.centerX - open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) : Group() { val groupSize = 54f @@ -36,10 +35,11 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) protected var baseTerrainOverlayImage: Image? = null protected var baseTerrain:String="" - val featureLayerGroup = Group().apply { isTransform=false; setSize(groupSize,groupSize) } + val terrainFeatureLayerGroup = Group().apply { isTransform=false; setSize(groupSize,groupSize) } protected var terrainFeatureOverlayImage: Image? = null protected var terrainFeature:String?=null protected var cityImage: Image? = null + protected var pixelMilitaryUnitImage: Image? = null val miscLayerGroup = Group().apply { isTransform=false; setSize(groupSize,groupSize) } var resourceImage: Actor? = null @@ -72,7 +72,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) init { this.setSize(groupSize, groupSize) this.addActor(baseLayerGroup) - this.addActor(featureLayerGroup) + this.addActor(terrainFeatureLayerGroup) this.addActor(miscLayerGroup) this.addActor(unitLayerGroup) this.addActor(cityButtonLayerGroup) @@ -138,6 +138,16 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) return tileSetStrings.hexagon } + // Used for both the underlying tile and unit overlays, perhaps for other things in the future + // Parent should already be set when calling + fun setHexagonImageSize(hexagonImage:Image){ + val imageScale = groupSize * 1.5f / hexagonImage.width + // Using "scale" can get really confusing when positioning, how about no + hexagonImage.setSize(hexagonImage.width*imageScale, hexagonImage.height*imageScale) + hexagonImage.centerX(hexagonImage.parent) + hexagonImage.y = -groupSize/6 + } + private fun updateTileImage(isRevealed: Boolean) { val tileBaseImageLocation = getTileBaseImageLocation(isRevealed) if(tileBaseImageLocation==currentTileBaseImageLocation) return @@ -146,14 +156,9 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) tileBaseImage = ImageGetter.getImage(tileBaseImageLocation) currentTileBaseImageLocation = tileBaseImageLocation - val imageScale = groupSize * 1.5f / tileBaseImage.width - // Using "scale" can get really confusing when positioning, how about no - tileBaseImage.setSize(tileBaseImage.width*imageScale, tileBaseImage.height*imageScale) - tileBaseImage.centerX(this) - - tileBaseImage.y = -groupSize/6 - tileBaseImage.toBack() baseLayerGroup.addActor(tileBaseImage) + setHexagonImageSize(tileBaseImage) + tileBaseImage.toBack() } fun addAcquirableIcon(){ @@ -207,6 +212,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) updateTileImage(true) updateTerrainBaseImage() updateTerrainFeatureImage() + updatePixelMilitaryUnit(showMilitaryUnit) updateCityImage() updateTileColor(tileIsViewable) @@ -251,7 +257,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) return cityImage = ImageGetter.getImage(cityOverlayLocation) - featureLayerGroup.addActor(cityImage) + terrainFeatureLayerGroup.addActor(cityImage) cityImage!!.run { setSize(60f, 60f) center(this@TileGroup) @@ -358,7 +364,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) image.setOrigin(0f, 1f) // This is so that the rotation is calculated from the middle of the road and not the edge image.rotation = (180 / Math.PI * Math.atan2(relativeWorldPosition.y.toDouble(), relativeWorldPosition.x.toDouble())).toFloat() - featureLayerGroup.addActor(image) + terrainFeatureLayerGroup.addActor(image) } } @@ -382,7 +388,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) val terrainFeatureOverlayLocation = tileSetStrings.getTerrainFeatureOverlay(terrainFeature!!) if(!ImageGetter.imageExists(terrainFeatureOverlayLocation)) return terrainFeatureOverlayImage = ImageGetter.getImage(terrainFeatureOverlayLocation) - featureLayerGroup.addActor(terrainFeatureOverlayImage) + terrainFeatureLayerGroup.addActor(terrainFeatureOverlayImage) terrainFeatureOverlayImage!!.run { setSize(30f, 30f) setColor(1f, 1f, 1f, 0.5f) @@ -392,6 +398,30 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) } } + fun updatePixelMilitaryUnit(showMilitaryUnit: Boolean) { + if (tileInfo.militaryUnit==null || !showMilitaryUnit) { + if (pixelMilitaryUnitImage != null) { + pixelMilitaryUnitImage!!.remove() + pixelMilitaryUnitImage = null + } + } else { + if (pixelMilitaryUnitImage == null) { + var imageLocation = "" + if (tileInfo.militaryUnit!!.type.isLandUnit() && ImageGetter.imageExists(tileSetStrings.landUnit)) + imageLocation = tileSetStrings.landUnit + else if (tileInfo.militaryUnit!!.type.isWaterUnit() && ImageGetter.imageExists(tileSetStrings.waterUnit)) + imageLocation = tileSetStrings.waterUnit + + if (imageLocation != "") { + val pixelUnitImage = ImageGetter.getImage(imageLocation) + terrainFeatureLayerGroup.addActor(pixelUnitImage) + setHexagonImageSize(pixelUnitImage)// Treat this as A TILE, which gets overlayed on the base tile. + pixelMilitaryUnitImage=pixelUnitImage + } + } + } + } + private fun updateImprovementImage(showResourcesAndImprovements: Boolean) { if (improvementImage != null) { improvementImage!!.remove() diff --git a/core/src/com/unciv/ui/tilegroups/TileSetStrings.kt b/core/src/com/unciv/ui/tilegroups/TileSetStrings.kt index 9e15daed95..4b80873965 100644 --- a/core/src/com/unciv/ui/tilegroups/TileSetStrings.kt +++ b/core/src/com/unciv/ui/tilegroups/TileSetStrings.kt @@ -12,6 +12,9 @@ class TileSetStrings { val cityOverlay = tileSetLocation+"CityOverlay" val railroad = tileSetLocation+"Railroad" + val landUnit = tileSetLocation+"LandUnit" + val waterUnit = tileSetLocation+"WaterUnit" + private val baseTerrainToTile = HashMap() fun getBaseTerrainTile(baseTerrain:String): String { if(!baseTerrainToTile.containsKey(baseTerrain)) diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index d1bbbc1732..35cbfd247c 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -131,10 +131,8 @@ object ImageGetter { if(imageExists("UnitPromotionIcons/$basePromotionName")) { val icon = getImage("UnitPromotionIcons/$basePromotionName") icon.color = colorFromRGB(255,226,0) - var circle = icon.surroundWithCircle(30f) + val circle = icon.surroundWithCircle(30f) circle.circle.color = colorFromRGB(0,12,49) -// circle = circle.surroundWithCircle(40f) -// circle.circle.color = colorFromRGB(255,226,0) if(level!=0){ val starTable = Table().apply { defaults().pad(2f) } for(i in 1..level) starTable.add(getImage("OtherIcons/Star")).size(8f) diff --git a/core/src/com/unciv/ui/worldscreen/TileGroupMap.kt b/core/src/com/unciv/ui/worldscreen/TileGroupMap.kt index fb0bb134e2..65bb64a6c8 100644 --- a/core/src/com/unciv/ui/worldscreen/TileGroupMap.kt +++ b/core/src/com/unciv/ui/worldscreen/TileGroupMap.kt @@ -37,7 +37,7 @@ class TileGroupMap(val tileGroups:Collection, padding:Float): G for(group in tileGroups.sortedByDescending { it.tileInfo.position.x + it.tileInfo.position.y }){ // now, we steal the subgroups from all the tilegroups, that's how we form layers! baseLayers.add(group.baseLayerGroup.apply { setPosition(group.x,group.y) }) - featureLayers.add(group.featureLayerGroup.apply { setPosition(group.x,group.y) }) + featureLayers.add(group.terrainFeatureLayerGroup.apply { setPosition(group.x,group.y) }) miscLayers.add(group.miscLayerGroup.apply { setPosition(group.x,group.y) }) unitLayers.add(group.unitLayerGroup.apply { setPosition(group.x,group.y) }) cityButtonLayers.add(group.cityButtonLayerGroup.apply { setPosition(group.x,group.y) })