mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 21:30:20 +07:00
Added option to choose map generation type
This commit is contained in:
@ -13,7 +13,7 @@ class GameStarter(){
|
||||
fun startNewGame(newGameParameters: NewGameScreen.NewGameParameters): GameInfo {
|
||||
val gameInfo = GameInfo()
|
||||
|
||||
gameInfo.tileMap = TileMap(newGameParameters.mapRadius)
|
||||
gameInfo.tileMap = TileMap(newGameParameters.mapRadius, newGameParameters.mapType)
|
||||
gameInfo.tileMap.gameInfo = gameInfo // need to set this transient before placing units in the map
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ class UnCivGame : Game() {
|
||||
* This exists so that when debugging we can see the entire map.
|
||||
* Remember to turn this to false before commit and upload!
|
||||
*/
|
||||
val viewEntireMapForDebug = true
|
||||
val viewEntireMapForDebug = false
|
||||
|
||||
lateinit var worldScreen: WorldScreen
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.HexMath
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.ui.NewGameScreen
|
||||
|
||||
class TileMap {
|
||||
|
||||
@ -30,12 +31,21 @@ class TileMap {
|
||||
get() = tileList
|
||||
|
||||
|
||||
constructor(distance: Int) {
|
||||
// tileList.addAll(AlexanderRandomMapGenerator().generateMap(distance,0.75f).values)
|
||||
tileList.addAll(PerlinNoiseRandomMapGenerator().generateMap(distance).values)
|
||||
constructor(distance: Int, mapType: NewGameScreen.NewGameParameters.MapType) {
|
||||
val map:HashMap<String,TileInfo>
|
||||
|
||||
if(mapType==NewGameScreen.NewGameParameters.MapType.WithWater)
|
||||
map = PerlinNoiseRandomMapGenerator().generateMap(distance)
|
||||
|
||||
else map = SeedRandomMapGenerator().generateMap(distance,0f)
|
||||
|
||||
tileList.addAll(map.values)
|
||||
// tileList.addAll(AlexanderRandomMapGenerator().generateMap(distance,0.8f).values)
|
||||
|
||||
setTransients()
|
||||
}
|
||||
|
||||
|
||||
operator fun contains(vector: Vector2): Boolean {
|
||||
val arrayXIndex = vector.x.toInt()-leftX
|
||||
if(arrayXIndex<0 || arrayXIndex>=tileMatrix.size) return false
|
||||
|
@ -18,10 +18,15 @@ import kotlin.concurrent.thread
|
||||
class NewGameScreen: PickerScreen(){
|
||||
|
||||
class NewGameParameters{
|
||||
enum class MapType{
|
||||
LandOnly,
|
||||
WithWater
|
||||
}
|
||||
var difficulty="Prince"
|
||||
var nation="Babylon"
|
||||
var mapRadius=20
|
||||
var numberOfEnemies=3
|
||||
var mapType=MapType.LandOnly
|
||||
}
|
||||
|
||||
val newGameParameters=NewGameParameters()
|
||||
@ -102,10 +107,10 @@ class NewGameScreen: PickerScreen(){
|
||||
}
|
||||
|
||||
private fun getOptionsTable(): Table {
|
||||
val table = Table()
|
||||
table.skin = skin
|
||||
val newGameOptionsTable = Table()
|
||||
newGameOptionsTable.skin = skin
|
||||
|
||||
table.add("{World size}:".tr())
|
||||
newGameOptionsTable.add("{World size}:".tr())
|
||||
val worldSizeToRadius = LinkedHashMap<String, Int>()
|
||||
worldSizeToRadius["Small"] = 10
|
||||
worldSizeToRadius["Medium"] = 20
|
||||
@ -117,10 +122,10 @@ class NewGameScreen: PickerScreen(){
|
||||
newGameParameters.mapRadius = worldSizeToRadius[worldSizeSelectBox.selected.value]!!
|
||||
}
|
||||
})
|
||||
table.add(worldSizeSelectBox).pad(10f).row()
|
||||
newGameOptionsTable.add(worldSizeSelectBox).pad(10f).row()
|
||||
|
||||
|
||||
table.add("{Number of enemies}:".tr())
|
||||
newGameOptionsTable.add("{Number of enemies}:".tr())
|
||||
val enemiesSelectBox = SelectBox<Int>(skin)
|
||||
val enemiesArray = Array<Int>()
|
||||
(1..5).forEach { enemiesArray.add(it) }
|
||||
@ -132,14 +137,21 @@ class NewGameScreen: PickerScreen(){
|
||||
newGameParameters.numberOfEnemies = enemiesSelectBox.selected
|
||||
}
|
||||
})
|
||||
table.add(enemiesSelectBox).pad(10f).row()
|
||||
newGameOptionsTable.add(enemiesSelectBox).pad(10f).row()
|
||||
|
||||
|
||||
table.add("{Difficulty}:".tr())
|
||||
newGameOptionsTable.add("{Difficulty}:".tr())
|
||||
val difficultySelectBox = TranslatedSelectBox(GameBasics.Difficulties.keys, newGameParameters.difficulty, skin)
|
||||
table.add(difficultySelectBox).pad(10f).row()
|
||||
newGameOptionsTable.add(difficultySelectBox).pad(10f).row()
|
||||
|
||||
|
||||
val checkBox = CheckBox("Add water tiles \n(EXPERIMENTAL/WIP)",skin)
|
||||
checkBox.onClick {
|
||||
if(checkBox.isChecked) newGameParameters.mapType = NewGameParameters.MapType.WithWater
|
||||
else newGameParameters.mapType = NewGameParameters.MapType.LandOnly
|
||||
}
|
||||
newGameOptionsTable.add(checkBox).row()
|
||||
|
||||
rightSideButton.enable()
|
||||
rightSideButton.setText("Start game!".tr())
|
||||
rightSideButton.onClick {
|
||||
@ -152,8 +164,9 @@ class NewGameScreen: PickerScreen(){
|
||||
newGame = GameStarter().startNewGame(newGameParameters)
|
||||
}
|
||||
}
|
||||
table.pack()
|
||||
return table
|
||||
|
||||
newGameOptionsTable.pack()
|
||||
return newGameOptionsTable
|
||||
}
|
||||
|
||||
var newGame:GameInfo?=null
|
||||
|
Reference in New Issue
Block a user