Added "No barbarians" starting option - part of #559

This commit is contained in:
Yair Morgenstern 2019-04-13 22:49:17 +03:00
parent ccb9950187
commit 0539890a4d
3 changed files with 13 additions and 5 deletions

View File

@ -20,6 +20,7 @@ class GameParameters{
var humanNations=ArrayList<String>().apply { add("Babylon") }
var numberOfEnemies=3
var mapType= MapType.Perlin
var noBarbarians=false
var mapFileName :String?=null
}

View File

@ -47,7 +47,7 @@ class GameInfo {
currentPlayerIndex = (currentPlayerIndex+1) % civilizations.size
if(currentPlayerIndex==0){
turns++
if (turns % 10 == 0) { // every 10 turns add a barbarian in a random place
if (turns % 10 == 0 && !gameParameters.noBarbarians) { // every 10 turns add a barbarian in a random place
placeBarbarianUnit(null)
}
}

View File

@ -2,10 +2,7 @@ package com.unciv.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
import com.badlogic.gdx.scenes.scene2d.ui.Skin
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.*
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
import com.badlogic.gdx.utils.Array
import com.unciv.GameStarter
@ -80,6 +77,16 @@ class NewGameScreen: PickerScreen(){
addDifficultySelectBox(newGameOptionsTable)
val noBarbariansCheckbox = CheckBox("No barbarians",skin)
noBarbariansCheckbox.isChecked=newGameParameters.noBarbarians
noBarbariansCheckbox.addListener(object : ChangeListener() {
override fun changed(event: ChangeEvent?, actor: Actor?) {
newGameParameters.noBarbarians = noBarbariansCheckbox.isChecked
}
})
newGameOptionsTable.add(noBarbariansCheckbox).colspan(2).row()
rightSideButton.enable()
rightSideButton.setText("Start game!".tr())
rightSideButton.onClick {