mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-06 08:21:36 +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
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TechIcons/Mass Media
|
||||
TechIcons/Mass Media (retired)
|
||||
rotate: false
|
||||
xy: 1354, 1435
|
||||
size: 100, 100
|
||||
|
@ -543,7 +543,7 @@
|
||||
happiness:4,
|
||||
requiredBuilding:"Theatre",
|
||||
maintenance:2,
|
||||
requiredTech:"Mass Media"
|
||||
requiredTech:"Refrigeration"
|
||||
},
|
||||
{
|
||||
name:"Cristo Redentor",
|
||||
|
@ -296,7 +296,7 @@
|
||||
{
|
||||
name:"Scientific Theory",
|
||||
row:4,
|
||||
prerequisites:["Archaeology","Architecture","Economics"]
|
||||
prerequisites:["Architecture","Economics"]
|
||||
},
|
||||
{
|
||||
name:"Industrialization",
|
||||
@ -329,17 +329,17 @@
|
||||
techs:[
|
||||
{
|
||||
name:"Biology",
|
||||
row:3,
|
||||
prerequisites:["Archaeology","Scientific Theory","Fertilizer"]
|
||||
row:2,
|
||||
prerequisites:["Archaeology","Scientific Theory"]
|
||||
},
|
||||
{
|
||||
name:"Electricity",
|
||||
row:5,
|
||||
row:3,
|
||||
prerequisites:["Scientific Theory"]
|
||||
},
|
||||
{
|
||||
name:"Steam Power",
|
||||
row:7,
|
||||
row:6,
|
||||
uniques:["Increases embarked movement +1"],
|
||||
prerequisites:["Industrialization","Scientific Theory","Rifling"]
|
||||
},
|
||||
@ -359,23 +359,23 @@
|
||||
techs:[
|
||||
{
|
||||
name:"Refrigeration",
|
||||
row:3,
|
||||
row:2,
|
||||
prerequisites:["Biology", "Electricity"], //to do: offshore platform should need this
|
||||
},
|
||||
{
|
||||
name:"Radio",
|
||||
row:3,
|
||||
prerequisites:["Electricity"]
|
||||
},
|
||||
{
|
||||
name:"Replacable Parts",
|
||||
row:4,
|
||||
prerequisites:["Electricity","Steam Power"]
|
||||
},
|
||||
{
|
||||
name:"Radio",
|
||||
row:5,
|
||||
prerequisites:["Electricity"]
|
||||
},
|
||||
{
|
||||
name:"Combustion",
|
||||
row:8,
|
||||
prerequisites:["Steam Power","Dynamite"]
|
||||
name:"Flight",
|
||||
row:6,
|
||||
prerequisites:["Steam Power"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -389,7 +389,7 @@
|
||||
{
|
||||
name:"Plastics",
|
||||
row:3,
|
||||
prerequisites:["Biology","Replacable Parts"]
|
||||
prerequisites:["Radio","Replacable Parts"]
|
||||
},
|
||||
{
|
||||
name:"Electronics",
|
||||
@ -397,15 +397,10 @@
|
||||
prerequisites:["Replacable Parts", "Flight"],
|
||||
},
|
||||
{
|
||||
name:"Mass Media",
|
||||
row:6,
|
||||
prerequisites:["Radio"]
|
||||
},
|
||||
{
|
||||
name:"Flight",
|
||||
row:7,
|
||||
prerequisites:["Combustion"]
|
||||
},
|
||||
name:"Combustion",
|
||||
row:8,
|
||||
prerequisites:["Steam Power","Dynamite"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -416,13 +411,13 @@
|
||||
techs:[
|
||||
{
|
||||
name:"Pharmaceuticals",
|
||||
row:3,
|
||||
prerequisites:["Plastics"]
|
||||
row:2,
|
||||
prerequisites:["Plastics","Refrigeration"]
|
||||
},
|
||||
{
|
||||
name:"Computers",
|
||||
row:5,
|
||||
prerequisites:["Mass Media"],
|
||||
prerequisites:["Electronics"],
|
||||
uniques:["+10% science and production in all cities"]
|
||||
},
|
||||
{
|
||||
@ -440,7 +435,7 @@
|
||||
techs:[
|
||||
{
|
||||
name:"Ecology",
|
||||
row:3,
|
||||
row:2,
|
||||
prerequisites:["Pharmaceuticals"]
|
||||
},
|
||||
{
|
||||
|
@ -60,6 +60,24 @@ class TechManager {
|
||||
|
||||
//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) {
|
||||
val currentTechnology = currentTechnology()
|
||||
if (currentTechnology == null) return
|
||||
@ -67,27 +85,36 @@ class TechManager {
|
||||
if (techsInProgress[currentTechnology]!! < costOfTech(currentTechnology))
|
||||
return
|
||||
|
||||
val previousEra = civInfo.getEra()
|
||||
|
||||
// We finished it!
|
||||
techsInProgress.remove(currentTechnology)
|
||||
if(currentTechnology!="Future Tech")
|
||||
techsToResearch.remove(currentTechnology)
|
||||
techsResearched.add(currentTechnology)
|
||||
addTechnology(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
|
||||
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()
|
||||
if(previousEra < currentEra){
|
||||
civInfo.addNotification("You have entered the [$currentEra] era!".tr(),null,Color.GOLD)
|
||||
GameBasics.PolicyBranches.values.filter { it.era==currentEra }
|
||||
.forEach{civInfo.addNotification("["+it.name+"] policy branch unlocked!".tr(),null,Color.PURPLE)}
|
||||
if (previousEra < currentEra) {
|
||||
civInfo.addNotification("You have entered the [$currentEra] era!".tr(), null, Color.GOLD)
|
||||
GameBasics.PolicyBranches.values.filter { it.era == currentEra }
|
||||
.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) {
|
||||
for (tileInfo in civInfo.gameInfo.tileMap.values
|
||||
@ -96,22 +123,26 @@ class TechManager {
|
||||
val closestCityTile = tileInfo.getTilesInDistance(4)
|
||||
.firstOrNull { it.isCityCenter() }
|
||||
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
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val obsoleteUnits = GameBasics.Units.values.filter { it.obsoleteTech==currentTechnology }
|
||||
for(city in civInfo.cities)
|
||||
if(city.cityConstructions.getCurrentConstruction() in obsoleteUnits){
|
||||
val obsoleteUnits = GameBasics.Units.values.filter { it.obsoleteTech == techName }
|
||||
for (city in civInfo.cities)
|
||||
if (city.cityConstructions.getCurrentConstruction() in obsoleteUnits) {
|
||||
val currentConstructionUnit = city.cityConstructions.getCurrentConstruction() as BaseUnit
|
||||
city.cityConstructions.currentConstruction = currentConstructionUnit.upgradesTo!!
|
||||
}
|
||||
}
|
||||
|
||||
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]!! })
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
||||
private var isFreeTechPick: Boolean = false
|
||||
private var selectedTech: Technology? = null
|
||||
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.
|
||||
private var researchableTechs = GameBasics.Technologies.keys
|
||||
@ -39,7 +39,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
||||
init {
|
||||
onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }
|
||||
|
||||
techsToResearch = ArrayList(civTech.techsToResearch)
|
||||
tempTechsToResearch = ArrayList(civTech.techsToResearch)
|
||||
|
||||
val columns = 17
|
||||
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)
|
||||
}
|
||||
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.onClick {
|
||||
if (isFreeTechPick) {
|
||||
civTech.techsResearched.add(selectedTech!!.name)
|
||||
if (civTech.techsToResearch.contains(selectedTech!!.name)) {
|
||||
civTech.techsToResearch.remove(selectedTech!!.name)
|
||||
}
|
||||
civTech.freeTechs -= 1
|
||||
civTech.getFreeTechnology(selectedTech!!.name)
|
||||
} else
|
||||
civTech.techsToResearch = techsToResearch
|
||||
civTech.techsToResearch = tempTechsToResearch
|
||||
game.setWorldScreen()
|
||||
game.worldScreen.shouldUpdate=true
|
||||
dispose()
|
||||
@ -98,8 +95,8 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
||||
val techButton = techNameToButton[techName]!!
|
||||
when {
|
||||
civTech.isResearched(techName) && techName!="Future Tech" -> techButton.color = researchedTechColor
|
||||
techsToResearch.isNotEmpty() && techsToResearch.first() == techName -> techButton.color = currentTechColor
|
||||
techsToResearch.contains(techName) -> techButton.color = queuedTechColor
|
||||
tempTechsToResearch.isNotEmpty() && tempTechsToResearch.first() == techName -> techButton.color = currentTechColor
|
||||
tempTechsToResearch.contains(techName) -> techButton.color = queuedTechColor
|
||||
researchableTechs.contains(techName) -> techButton.color = researchableTechColor
|
||||
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)
|
||||
}
|
||||
|
||||
if (techsToResearch.contains(techName) && techsToResearch.size > 1) {
|
||||
text += " (" + techsToResearch.indexOf(techName) + ")"
|
||||
if (tempTechsToResearch.contains(techName) && tempTechsToResearch.size > 1) {
|
||||
text += " (" + tempTechsToResearch.indexOf(techName) + ")"
|
||||
}
|
||||
|
||||
if (!civTech.isResearched(techName) || techName=="Future Tech")
|
||||
@ -129,37 +126,22 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
|
||||
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.disable()
|
||||
setButtonsInfo()
|
||||
return
|
||||
}
|
||||
|
||||
if (researchableTechs.contains(tech.name)) {
|
||||
techsToResearch.clear()
|
||||
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())
|
||||
}
|
||||
tempTechsToResearch.clear()
|
||||
tempTechsToResearch.addAll(civTech.getRequiredTechsToDestination(tech))
|
||||
|
||||
pick("Research [${techsToResearch[0]}]".tr())
|
||||
pick("Research [${tempTechsToResearch[0]}]".tr())
|
||||
setButtonsInfo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun selectTechnologyForFreeTech(tech: Technology) {
|
||||
if (researchableTechs.contains(tech.name)) {
|
||||
pick("Pick [${selectedTech!!.name}] as free tech".tr())
|
||||
|
Reference in New Issue
Block a user