Added unit icons with the background according to owner
BIN
android/assets/UnitIcons/Circle.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
android/assets/UnitIcons/Great Artist.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
android/assets/UnitIcons/Great Engineer.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
android/assets/UnitIcons/Great Merchant.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
android/assets/UnitIcons/Great Scientist.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
android/assets/UnitIcons/Scout.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
android/assets/UnitIcons/Settler.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
android/assets/UnitIcons/Warrior.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
android/assets/UnitIcons/Worker.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
6
android/assets/jsons/Civilizations.json
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
name:"Babylon",
|
||||
RGB:[220,20,60]
|
||||
}
|
||||
]
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.math.Vector2
|
||||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.models.gamebasics.Civilization
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ResourceType
|
||||
import com.unciv.models.gamebasics.TileResource
|
||||
@ -28,6 +29,8 @@ class CivilizationInfo {
|
||||
|
||||
var cities = ArrayList<CityInfo>()
|
||||
|
||||
fun getCivilization(): Civilization {return GameBasics.Civilizations[civName]!!}
|
||||
|
||||
val capital: CityInfo
|
||||
get() = cities.first { it.cityConstructions.isBuilt("Palace") }
|
||||
|
||||
|
12
core/src/com/unciv/models/gamebasics/Civilization.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package com.unciv.models.gamebasics
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.models.stats.INamed
|
||||
|
||||
class Civilization : INamed {
|
||||
override lateinit var name: String
|
||||
lateinit var RGB: List<Int>
|
||||
fun getColor(): Color {
|
||||
return Color(RGB[0]/256f, RGB[1]/256f, RGB[2]/256f, 1f)
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ object GameBasics {
|
||||
val Technologies = LinkedHashMap<String, Technology>()
|
||||
val Helps = LinkedHashMap<String, BasicHelp>()
|
||||
val Units = LinkedHashMap<String, Unit>()
|
||||
val Civilizations = LinkedHashMap<String, Civilization>()
|
||||
val PolicyBranches = LinkedHashMap<String, PolicyBranch>()
|
||||
val Tutorials = LinkedHashMap<String, List<String>>()
|
||||
}
|
@ -25,6 +25,11 @@ class UnCivGame : Game() {
|
||||
if (GameSaver.GetSave("Autosave").exists()) {
|
||||
try {
|
||||
GameSaver.LoadGame(this, "Autosave")
|
||||
gameInfo.getPlayerCivilization().civName="Babylon"
|
||||
gameInfo.tileMap.values.forEach {
|
||||
if (it.owner == "Player") it.owner = "Babylon"
|
||||
if (it.unit != null && it.unit!!.owner == "Player") it.unit!!.owner = "Babylon"
|
||||
}
|
||||
} catch (ex: Exception) { // silent fail if we can't read the autosave
|
||||
startNewGame()
|
||||
}
|
||||
@ -38,7 +43,7 @@ class UnCivGame : Game() {
|
||||
fun startNewGame() {
|
||||
gameInfo = GameInfo()
|
||||
gameInfo.tileMap = TileMap(20)
|
||||
gameInfo.civilizations.add(CivilizationInfo("Player", Vector2.Zero, gameInfo))
|
||||
gameInfo.civilizations.add(CivilizationInfo("Babylon", Vector2.Zero, gameInfo))
|
||||
gameInfo.setTransients()
|
||||
|
||||
worldScreen = WorldScreen()
|
||||
@ -71,12 +76,13 @@ class UnCivGame : Game() {
|
||||
GameBasics.Helps += createHashmap(getFromJson(Array<BasicHelp>::class.java, "BasicHelp"))
|
||||
GameBasics.Units += createHashmap(getFromJson(Array<Unit>::class.java, "Units"))
|
||||
GameBasics.PolicyBranches += createHashmap(getFromJson(Array<PolicyBranch>::class.java, "Policies"))
|
||||
GameBasics.Civilizations += createHashmap(getFromJson(Array<Civilization>::class.java, "Civilizations"))
|
||||
|
||||
// ...Yes. Total Voodoo. I wish I didn't have to do this.
|
||||
val x = LinkedHashMap<String,com.badlogic.gdx.utils.Array<com.badlogic.gdx.utils.Array<String>>>()
|
||||
val tutorials = getFromJson(x.javaClass, "Tutorials")
|
||||
for (tut in tutorials)
|
||||
GameBasics.Tutorials.put(tut.key,tut.value.map{it.joinToString("\r\n")})
|
||||
GameBasics.Tutorials[tut.key] = tut.value.map{it.joinToString("\r\n")}
|
||||
|
||||
val techColumns = getFromJson(Array<TechColumn>::class.java, "Techs")
|
||||
for (techColumn in techColumns) {
|
||||
|
@ -15,7 +15,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
protected var terrainFeatureImage:Image?=null
|
||||
|
||||
protected var resourceImage: Image? = null
|
||||
protected var unitImage: Image? = null
|
||||
protected var unitImage: Group? = null
|
||||
protected var improvementImage: Image? =null
|
||||
private var improvementType: String? = null
|
||||
var populationImage: Image? = null
|
||||
@ -74,15 +74,6 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
terrainFeatureImage=null
|
||||
}
|
||||
|
||||
if(cityImage==null && tileInfo.isCityCenter){
|
||||
terrainFeatureImage = ImageGetter.getImage("TerrainIcons/City.png")
|
||||
addActor(terrainFeatureImage)
|
||||
setSize(30f,30f)
|
||||
setColor(1f,1f,1f,0.5f)
|
||||
setPosition(this@TileGroup.width /2-width/2,
|
||||
this@TileGroup.height/2-height/2)
|
||||
}
|
||||
}
|
||||
|
||||
val RGB= tileInfo.getBaseTerrain().RGB!!
|
||||
hexagon.color = Color(RGB[0]/255f,RGB[1]/255f,RGB[2]/255f,1f)
|
||||
@ -97,7 +88,8 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
}
|
||||
|
||||
if (tileInfo.unit != null && unitImage == null) {
|
||||
unitImage = ImageGetter.getImage("UnitIcons/" + tileInfo.unit!!.name!!.replace(" ", "_") + "_(Civ5).png")
|
||||
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,
|
||||
@ -183,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.color = Color.RED
|
||||
image.color = tileInfo.getOwner()!!.getCivilization().getColor()
|
||||
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)
|
||||
@ -193,5 +185,22 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
|