Tech manager now shows eras of technologies!

This commit is contained in:
Yair Morgenstern 2018-06-25 19:27:27 +03:00
parent c5f127e555
commit 1388aec34a
3 changed files with 25 additions and 2 deletions

View File

@ -1601,4 +1601,9 @@
"Can speed up construction of a wonder, or construct a Manufactory (+4 production)":{
German:"Kann die Bauzeit eines Wunders verkürzen oder eine Fabrik (+4 Produktion) bauen"
}
// Policy picker screen
"You have entered the [newEra] era!":{}
"[policyBranch] policy branch unlocked!":{} // EG Rationalism policy branch unlocked!
}

View File

@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Color
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.Technology
import com.unciv.models.gamebasics.unit.Unit
import com.unciv.ui.utils.tr
import java.util.*
class TechManager {
@ -52,12 +53,21 @@ class TechManager {
if (techsInProgress[currentTechnology]!! < getCurrentTechnology().cost)
return
val previousEra = civInfo.getEra()
// We finished it!
techsInProgress.remove(currentTechnology)
techsToResearch.remove(currentTechnology)
techsResearched.add(currentTechnology)
civInfo.addNotification("Research of [$currentTechnology] 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)}
}
val revealedResource = GameBasics.TileResources.values.firstOrNull { currentTechnology == it.revealedBy }
if (revealedResource != null) {

View File

@ -1,6 +1,7 @@
package com.unciv.ui.pickerscreens
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.TechManager
@ -33,12 +34,17 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
init {
techsToResearch = ArrayList(civTech.techsToResearch)
val techMatrix = Array<Array<Technology?>>(18) { arrayOfNulls(10) } // Divided into columns, then rows
val columns = 17
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(10) } // Divided into columns, then rows
for (technology in GameBasics.Technologies.values) {
techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
}
val eras = ArrayList<Label>()
for(i in techMatrix.indices) eras.add(Label("",CameraStageBaseScreen.skin))
eras.forEach { topTable.add(it) }
for (i in 0..9) {
topTable.row().pad(5f)
@ -46,13 +52,15 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
val tech = techMatrix[j][i]
if (tech == null)
topTable.add() // empty cell
else {
val TB = TextButton("", CameraStageBaseScreen.skin)
techNameToButton[tech.name] = TB
TB.addClickListener {
selectTechnology(tech)
}
topTable.add<TextButton>(TB)
topTable.add(TB)
if(eras[j].text.toString()=="") eras[j].setText(tech.era().toString())
}
}
}