mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Solved #670 - civ starting locations are given as much space as possible
This commit is contained in:
parent
024bad9b5a
commit
cf2580b8ed
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 967 KiB After Width: | Height: | Size: 990 KiB |
@ -2,6 +2,7 @@ package com.unciv
|
|||||||
|
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.unciv.logic.GameInfo
|
import com.unciv.logic.GameInfo
|
||||||
|
import com.unciv.logic.HexMath
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.civilization.PlayerType
|
import com.unciv.logic.civilization.PlayerType
|
||||||
import com.unciv.logic.map.BFS
|
import com.unciv.logic.map.BFS
|
||||||
@ -31,6 +32,7 @@ class GameStarter{
|
|||||||
gameInfo.gameParameters = newGameParameters
|
gameInfo.gameParameters = newGameParameters
|
||||||
gameInfo.tileMap = TileMap(newGameParameters)
|
gameInfo.tileMap = TileMap(newGameParameters)
|
||||||
gameInfo.tileMap.gameInfo = gameInfo // need to set this transient before placing units in the map
|
gameInfo.tileMap.gameInfo = gameInfo // need to set this transient before placing units in the map
|
||||||
|
|
||||||
val startingLocations = getStartingLocations(
|
val startingLocations = getStartingLocations(
|
||||||
newGameParameters.numberOfEnemies+newGameParameters.numberOfHumanPlayers+newGameParameters.numberOfCityStates,
|
newGameParameters.numberOfEnemies+newGameParameters.numberOfHumanPlayers+newGameParameters.numberOfCityStates,
|
||||||
gameInfo.tileMap)
|
gameInfo.tileMap)
|
||||||
@ -96,7 +98,7 @@ class GameStarter{
|
|||||||
landTilesInBigEnoughGroup.addAll(tilesInGroup)
|
landTilesInBigEnoughGroup.addAll(tilesInGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
for(minimumDistanceBetweenStartingLocations in tileMap.tileMatrix.size/2 downTo 0){
|
for(minimumDistanceBetweenStartingLocations in tileMap.tileMatrix.size/3 downTo 0){
|
||||||
val freeTiles = landTilesInBigEnoughGroup
|
val freeTiles = landTilesInBigEnoughGroup
|
||||||
.filter { vectorIsAtLeastNTilesAwayFromEdge(it.position,minimumDistanceBetweenStartingLocations,tileMap)}
|
.filter { vectorIsAtLeastNTilesAwayFromEdge(it.position,minimumDistanceBetweenStartingLocations,tileMap)}
|
||||||
.toMutableList()
|
.toMutableList()
|
||||||
@ -117,13 +119,12 @@ class GameStarter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun vectorIsAtLeastNTilesAwayFromEdge(vector: Vector2, n:Int, tileMap: TileMap): Boolean {
|
fun vectorIsAtLeastNTilesAwayFromEdge(vector: Vector2, n:Int, tileMap: TileMap): Boolean {
|
||||||
val arrayXIndex = vector.x.toInt()-tileMap.leftX
|
// Since all maps are HEXAGONAL, the easiest way of checking if a tile is n steps away from the
|
||||||
val arrayYIndex = vector.y.toInt()-tileMap.bottomY
|
// edge is checking the distance to the CENTER POINT
|
||||||
|
// Can't believe we used a dumb way of calculating this before!
|
||||||
return arrayXIndex < tileMap.tileMatrix.size-n
|
val hexagonalRadius = -tileMap.leftX
|
||||||
&& arrayXIndex > n
|
val distanceFromCenter = HexMath().getDistance(vector, Vector2.Zero)
|
||||||
&& arrayYIndex < tileMap.tileMatrix[arrayXIndex].size-n
|
return hexagonalRadius-distanceFromCenter >= n
|
||||||
&& arrayYIndex > n
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user