mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-07 00:41:39 +07:00
Organized Modern Era techs
Free techs are added like regular techs - with all the abilities and notifications thereof
This commit is contained in:
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@ -1684,7 +1684,7 @@ TechIcons/Masonry
|
|||||||
orig: 100, 100
|
orig: 100, 100
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
TechIcons/Mass Media
|
TechIcons/Mass Media (retired)
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 1354, 1435
|
xy: 1354, 1435
|
||||||
size: 100, 100
|
size: 100, 100
|
||||||
|
@ -543,7 +543,7 @@
|
|||||||
happiness:4,
|
happiness:4,
|
||||||
requiredBuilding:"Theatre",
|
requiredBuilding:"Theatre",
|
||||||
maintenance:2,
|
maintenance:2,
|
||||||
requiredTech:"Mass Media"
|
requiredTech:"Refrigeration"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Cristo Redentor",
|
name:"Cristo Redentor",
|
||||||
|
@ -296,7 +296,7 @@
|
|||||||
{
|
{
|
||||||
name:"Scientific Theory",
|
name:"Scientific Theory",
|
||||||
row:4,
|
row:4,
|
||||||
prerequisites:["Archaeology","Architecture","Economics"]
|
prerequisites:["Architecture","Economics"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Industrialization",
|
name:"Industrialization",
|
||||||
@ -329,17 +329,17 @@
|
|||||||
techs:[
|
techs:[
|
||||||
{
|
{
|
||||||
name:"Biology",
|
name:"Biology",
|
||||||
row:3,
|
row:2,
|
||||||
prerequisites:["Archaeology","Scientific Theory","Fertilizer"]
|
prerequisites:["Archaeology","Scientific Theory"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Electricity",
|
name:"Electricity",
|
||||||
row:5,
|
row:3,
|
||||||
prerequisites:["Scientific Theory"]
|
prerequisites:["Scientific Theory"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Steam Power",
|
name:"Steam Power",
|
||||||
row:7,
|
row:6,
|
||||||
uniques:["Increases embarked movement +1"],
|
uniques:["Increases embarked movement +1"],
|
||||||
prerequisites:["Industrialization","Scientific Theory","Rifling"]
|
prerequisites:["Industrialization","Scientific Theory","Rifling"]
|
||||||
},
|
},
|
||||||
@ -359,23 +359,23 @@
|
|||||||
techs:[
|
techs:[
|
||||||
{
|
{
|
||||||
name:"Refrigeration",
|
name:"Refrigeration",
|
||||||
row:3,
|
row:2,
|
||||||
prerequisites:["Biology", "Electricity"], //to do: offshore platform should need this
|
prerequisites:["Biology", "Electricity"], //to do: offshore platform should need this
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name:"Radio",
|
||||||
|
row:3,
|
||||||
|
prerequisites:["Electricity"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name:"Replacable Parts",
|
name:"Replacable Parts",
|
||||||
row:4,
|
row:4,
|
||||||
prerequisites:["Electricity","Steam Power"]
|
prerequisites:["Electricity","Steam Power"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Radio",
|
name:"Flight",
|
||||||
row:5,
|
row:6,
|
||||||
prerequisites:["Electricity"]
|
prerequisites:["Steam Power"]
|
||||||
},
|
|
||||||
{
|
|
||||||
name:"Combustion",
|
|
||||||
row:8,
|
|
||||||
prerequisites:["Steam Power","Dynamite"]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -389,7 +389,7 @@
|
|||||||
{
|
{
|
||||||
name:"Plastics",
|
name:"Plastics",
|
||||||
row:3,
|
row:3,
|
||||||
prerequisites:["Biology","Replacable Parts"]
|
prerequisites:["Radio","Replacable Parts"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Electronics",
|
name:"Electronics",
|
||||||
@ -397,15 +397,10 @@
|
|||||||
prerequisites:["Replacable Parts", "Flight"],
|
prerequisites:["Replacable Parts", "Flight"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Mass Media",
|
name:"Combustion",
|
||||||
row:6,
|
row:8,
|
||||||
prerequisites:["Radio"]
|
prerequisites:["Steam Power","Dynamite"]
|
||||||
},
|
}
|
||||||
{
|
|
||||||
name:"Flight",
|
|
||||||
row:7,
|
|
||||||
prerequisites:["Combustion"]
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -416,13 +411,13 @@
|
|||||||
techs:[
|
techs:[
|
||||||
{
|
{
|
||||||
name:"Pharmaceuticals",
|
name:"Pharmaceuticals",
|
||||||
row:3,
|
row:2,
|
||||||
prerequisites:["Plastics"]
|
prerequisites:["Plastics","Refrigeration"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Computers",
|
name:"Computers",
|
||||||
row:5,
|
row:5,
|
||||||
prerequisites:["Mass Media"],
|
prerequisites:["Electronics"],
|
||||||
uniques:["+10% science and production in all cities"]
|
uniques:["+10% science and production in all cities"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -440,7 +435,7 @@
|
|||||||
techs:[
|
techs:[
|
||||||
{
|
{
|
||||||
name:"Ecology",
|
name:"Ecology",
|
||||||
row:3,
|
row:2,
|
||||||
prerequisites:["Pharmaceuticals"]
|
prerequisites:["Pharmaceuticals"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -60,6 +60,24 @@ class TechManager {
|
|||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
fun getRequiredTechsToDestination(destinationTech: Technology): List<String> {
|
||||||
|
val prerequisites = Stack<String>()
|
||||||
|
val checkPrerequisites = ArrayDeque<String>()
|
||||||
|
checkPrerequisites.add(destinationTech.name)
|
||||||
|
|
||||||
|
while (!checkPrerequisites.isEmpty()) {
|
||||||
|
val techNameToCheck = checkPrerequisites.pop()
|
||||||
|
if (isResearched(techNameToCheck) || prerequisites.contains(techNameToCheck))
|
||||||
|
continue //no need to add or check prerequisites
|
||||||
|
val techToCheck = GameBasics.Technologies[techNameToCheck]
|
||||||
|
for (str in techToCheck!!.prerequisites)
|
||||||
|
if (!checkPrerequisites.contains(str)) checkPrerequisites.add(str)
|
||||||
|
prerequisites.add(techNameToCheck)
|
||||||
|
}
|
||||||
|
|
||||||
|
return prerequisites.reversed()
|
||||||
|
}
|
||||||
|
|
||||||
fun nextTurn(scienceForNewTurn: Int) {
|
fun nextTurn(scienceForNewTurn: Int) {
|
||||||
val currentTechnology = currentTechnology()
|
val currentTechnology = currentTechnology()
|
||||||
if (currentTechnology == null) return
|
if (currentTechnology == null) return
|
||||||
@ -67,27 +85,36 @@ class TechManager {
|
|||||||
if (techsInProgress[currentTechnology]!! < costOfTech(currentTechnology))
|
if (techsInProgress[currentTechnology]!! < costOfTech(currentTechnology))
|
||||||
return
|
return
|
||||||
|
|
||||||
val previousEra = civInfo.getEra()
|
|
||||||
|
|
||||||
// We finished it!
|
// We finished it!
|
||||||
techsInProgress.remove(currentTechnology)
|
techsInProgress.remove(currentTechnology)
|
||||||
if(currentTechnology!="Future Tech")
|
addTechnology(currentTechnology)
|
||||||
techsToResearch.remove(currentTechnology)
|
}
|
||||||
techsResearched.add(currentTechnology)
|
|
||||||
|
fun getFreeTechnology(techName:String){
|
||||||
|
freeTechs--
|
||||||
|
addTechnology(techName)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addTechnology(techName:String) {
|
||||||
|
if(techName!="Future Tech")
|
||||||
|
techsToResearch.remove(techName)
|
||||||
|
|
||||||
|
val previousEra = civInfo.getEra()
|
||||||
|
techsResearched.add(techName)
|
||||||
|
|
||||||
// this is to avoid concurrent modification problems
|
// this is to avoid concurrent modification problems
|
||||||
researchedTechnologies = researchedTechnologies.withItem(GameBasics.Technologies[currentTechnology]!!)
|
researchedTechnologies = researchedTechnologies.withItem(GameBasics.Technologies[techName]!!)
|
||||||
|
|
||||||
civInfo.addNotification("Research of [$currentTechnology] has completed!", null, Color.BLUE)
|
civInfo.addNotification("Research of [$techName] has completed!", null, Color.BLUE)
|
||||||
|
|
||||||
val currentEra = civInfo.getEra()
|
val currentEra = civInfo.getEra()
|
||||||
if(previousEra < currentEra){
|
if (previousEra < currentEra) {
|
||||||
civInfo.addNotification("You have entered the [$currentEra] era!".tr(),null,Color.GOLD)
|
civInfo.addNotification("You have entered the [$currentEra] era!".tr(), null, Color.GOLD)
|
||||||
GameBasics.PolicyBranches.values.filter { it.era==currentEra }
|
GameBasics.PolicyBranches.values.filter { it.era == currentEra }
|
||||||
.forEach{civInfo.addNotification("["+it.name+"] policy branch unlocked!".tr(),null,Color.PURPLE)}
|
.forEach { civInfo.addNotification("[" + it.name + "] policy branch unlocked!".tr(), null, Color.PURPLE) }
|
||||||
}
|
}
|
||||||
|
|
||||||
val revealedResource = GameBasics.TileResources.values.firstOrNull { currentTechnology == it.revealedBy }
|
val revealedResource = GameBasics.TileResources.values.firstOrNull { techName == it.revealedBy }
|
||||||
|
|
||||||
if (revealedResource != null) {
|
if (revealedResource != null) {
|
||||||
for (tileInfo in civInfo.gameInfo.tileMap.values
|
for (tileInfo in civInfo.gameInfo.tileMap.values
|
||||||
@ -96,22 +123,26 @@ class TechManager {
|
|||||||
val closestCityTile = tileInfo.getTilesInDistance(4)
|
val closestCityTile = tileInfo.getTilesInDistance(4)
|
||||||
.firstOrNull { it.isCityCenter() }
|
.firstOrNull { it.isCityCenter() }
|
||||||
if (closestCityTile != null) {
|
if (closestCityTile != null) {
|
||||||
civInfo.addNotification("{"+revealedResource.name + "} {revealed near} "
|
civInfo.addNotification("{" + revealedResource.name + "} {revealed near} "
|
||||||
+ closestCityTile.getCity()!!.name, tileInfo.position, Color.BLUE) // todo change to [] notation
|
+ closestCityTile.getCity()!!.name, tileInfo.position, Color.BLUE) // todo change to [] notation
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val obsoleteUnits = GameBasics.Units.values.filter { it.obsoleteTech==currentTechnology }
|
val obsoleteUnits = GameBasics.Units.values.filter { it.obsoleteTech == techName }
|
||||||
for(city in civInfo.cities)
|
for (city in civInfo.cities)
|
||||||
if(city.cityConstructions.getCurrentConstruction() in obsoleteUnits){
|
if (city.cityConstructions.getCurrentConstruction() in obsoleteUnits) {
|
||||||
val currentConstructionUnit = city.cityConstructions.getCurrentConstruction() as BaseUnit
|
val currentConstructionUnit = city.cityConstructions.getCurrentConstruction() as BaseUnit
|
||||||
city.cityConstructions.currentConstruction = currentConstructionUnit.upgradesTo!!
|
city.cityConstructions.currentConstruction = currentConstructionUnit.upgradesTo!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTransients(){
|
fun setTransients(){
|
||||||
|
// As of 2.10.16, removed mass media, since our tech tree is like G&K
|
||||||
|
techsResearched.remove("Mass Media")
|
||||||
|
techsToResearch.remove("Mass Media")
|
||||||
|
|
||||||
researchedTechnologies.addAll(techsResearched.map { GameBasics.Technologies[it]!! })
|
researchedTechnologies.addAll(techsResearched.map { GameBasics.Technologies[it]!! })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
private var isFreeTechPick: Boolean = false
|
private var isFreeTechPick: Boolean = false
|
||||||
private var selectedTech: Technology? = null
|
private var selectedTech: Technology? = null
|
||||||
private var civTech: TechManager = civInfo.tech
|
private var civTech: TechManager = civInfo.tech
|
||||||
private var techsToResearch: ArrayList<String>
|
private var tempTechsToResearch: ArrayList<String>
|
||||||
|
|
||||||
// All these are to counter performance problems when updating buttons for all techs.
|
// All these are to counter performance problems when updating buttons for all techs.
|
||||||
private var researchableTechs = GameBasics.Technologies.keys
|
private var researchableTechs = GameBasics.Technologies.keys
|
||||||
@ -39,7 +39,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
init {
|
init {
|
||||||
onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }
|
onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }
|
||||||
|
|
||||||
techsToResearch = ArrayList(civTech.techsToResearch)
|
tempTechsToResearch = ArrayList(civTech.techsToResearch)
|
||||||
|
|
||||||
val columns = 17
|
val columns = 17
|
||||||
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(10) } // Divided into columns, then rows
|
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(10) } // Divided into columns, then rows
|
||||||
@ -68,7 +68,8 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
selectTechnology(tech)
|
selectTechnology(tech)
|
||||||
}
|
}
|
||||||
topTable.add(techButton)
|
topTable.add(techButton)
|
||||||
if(eras[j].text.toString()=="") eras[j].setText((tech.era().toString()+" era").tr())
|
if(eras[j].text.toString()=="") // name of era was not yet set
|
||||||
|
eras[j].setText((tech.era().toString()+" era").tr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,13 +79,9 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
rightSideButton.setText("Pick a tech".tr())
|
rightSideButton.setText("Pick a tech".tr())
|
||||||
rightSideButton.onClick {
|
rightSideButton.onClick {
|
||||||
if (isFreeTechPick) {
|
if (isFreeTechPick) {
|
||||||
civTech.techsResearched.add(selectedTech!!.name)
|
civTech.getFreeTechnology(selectedTech!!.name)
|
||||||
if (civTech.techsToResearch.contains(selectedTech!!.name)) {
|
|
||||||
civTech.techsToResearch.remove(selectedTech!!.name)
|
|
||||||
}
|
|
||||||
civTech.freeTechs -= 1
|
|
||||||
} else
|
} else
|
||||||
civTech.techsToResearch = techsToResearch
|
civTech.techsToResearch = tempTechsToResearch
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
game.worldScreen.shouldUpdate=true
|
game.worldScreen.shouldUpdate=true
|
||||||
dispose()
|
dispose()
|
||||||
@ -98,8 +95,8 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
val techButton = techNameToButton[techName]!!
|
val techButton = techNameToButton[techName]!!
|
||||||
when {
|
when {
|
||||||
civTech.isResearched(techName) && techName!="Future Tech" -> techButton.color = researchedTechColor
|
civTech.isResearched(techName) && techName!="Future Tech" -> techButton.color = researchedTechColor
|
||||||
techsToResearch.isNotEmpty() && techsToResearch.first() == techName -> techButton.color = currentTechColor
|
tempTechsToResearch.isNotEmpty() && tempTechsToResearch.first() == techName -> techButton.color = currentTechColor
|
||||||
techsToResearch.contains(techName) -> techButton.color = queuedTechColor
|
tempTechsToResearch.contains(techName) -> techButton.color = queuedTechColor
|
||||||
researchableTechs.contains(techName) -> techButton.color = researchableTechColor
|
researchableTechs.contains(techName) -> techButton.color = researchableTechColor
|
||||||
else -> techButton.color = Color.BLACK
|
else -> techButton.color = Color.BLACK
|
||||||
}
|
}
|
||||||
@ -110,8 +107,8 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
techButton.color = techButton.color.cpy().lerp(Color.LIGHT_GRAY, 0.5f)
|
techButton.color = techButton.color.cpy().lerp(Color.LIGHT_GRAY, 0.5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (techsToResearch.contains(techName) && techsToResearch.size > 1) {
|
if (tempTechsToResearch.contains(techName) && tempTechsToResearch.size > 1) {
|
||||||
text += " (" + techsToResearch.indexOf(techName) + ")"
|
text += " (" + tempTechsToResearch.indexOf(techName) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!civTech.isResearched(techName) || techName=="Future Tech")
|
if (!civTech.isResearched(techName) || techName=="Future Tech")
|
||||||
@ -129,37 +126,22 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (civTech.isResearched(tech.name) && tech.name!="Future Tech") {
|
if (civTech.isResearched(tech.name) && tech.name != "Future Tech") {
|
||||||
rightSideButton.setText("Pick a tech".tr())
|
rightSideButton.setText("Pick a tech".tr())
|
||||||
rightSideButton.disable()
|
rightSideButton.disable()
|
||||||
setButtonsInfo()
|
setButtonsInfo()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (researchableTechs.contains(tech.name)) {
|
tempTechsToResearch.clear()
|
||||||
techsToResearch.clear()
|
tempTechsToResearch.addAll(civTech.getRequiredTechsToDestination(tech))
|
||||||
techsToResearch.add(tech.name)
|
|
||||||
} else {
|
|
||||||
val prerequisites = Stack<String>()
|
|
||||||
val checkPrerequisites = ArrayDeque<String>()
|
|
||||||
checkPrerequisites.add(tech.name)
|
|
||||||
while (!checkPrerequisites.isEmpty()) {
|
|
||||||
val techNameToCheck = checkPrerequisites.pop()
|
|
||||||
if (civTech.isResearched(techNameToCheck) || prerequisites.contains(techNameToCheck))
|
|
||||||
continue //no need to add or check prerequisites
|
|
||||||
val techToCheck = GameBasics.Technologies[techNameToCheck]
|
|
||||||
for (str in techToCheck!!.prerequisites)
|
|
||||||
if (!checkPrerequisites.contains(str)) checkPrerequisites.add(str)
|
|
||||||
prerequisites.add(techNameToCheck)
|
|
||||||
}
|
|
||||||
techsToResearch.clear()
|
|
||||||
while (!prerequisites.isEmpty()) techsToResearch.add(prerequisites.pop())
|
|
||||||
}
|
|
||||||
|
|
||||||
pick("Research [${techsToResearch[0]}]".tr())
|
pick("Research [${tempTechsToResearch[0]}]".tr())
|
||||||
setButtonsInfo()
|
setButtonsInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun selectTechnologyForFreeTech(tech: Technology) {
|
private fun selectTechnologyForFreeTech(tech: Technology) {
|
||||||
if (researchableTechs.contains(tech.name)) {
|
if (researchableTechs.contains(tech.name)) {
|
||||||
pick("Pick [${selectedTech!!.name}] as free tech".tr())
|
pick("Pick [${selectedTech!!.name}] as free tech".tr())
|
||||||
|
Reference in New Issue
Block a user