mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 15:27:50 +07:00
No longer displays red circle in attackable tiles (from range) but not viewed - gave away enemy positions!
This commit is contained in:
@ -50,13 +50,14 @@ class UnCivGame : Game() {
|
||||
else gameInfo = GameInfo()
|
||||
|
||||
gameInfo.tileMap = TileMap(20)
|
||||
gameInfo.civilizations.add(CivilizationInfo("Babylon", Vector2.Zero, gameInfo))
|
||||
|
||||
gameInfo.civilizations.add(CivilizationInfo("Greece", Vector2(3f,5f), gameInfo))
|
||||
gameInfo.civilizations.add(CivilizationInfo("Babylon", Vector2.Zero, gameInfo)) // first one is player civ
|
||||
|
||||
val barbarianCivilization = CivilizationInfo()
|
||||
gameInfo.civilizations.add(barbarianCivilization)// second is barbarian civ
|
||||
|
||||
gameInfo.civilizations.add(CivilizationInfo("Greece", Vector2(3f,5f), gameInfo)) // all the rest whatever
|
||||
|
||||
barbarianCivilization.civName = "Barbarians"
|
||||
gameInfo.civilizations.add(barbarianCivilization)
|
||||
(1..5).forEach { gameInfo.placeBarbarianUnit() }
|
||||
|
||||
gameInfo.setTransients()
|
||||
|
@ -7,6 +7,7 @@ import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.Notification
|
||||
import com.unciv.logic.map.TileMap
|
||||
import com.unciv.logic.map.UnitType
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.ui.utils.getRandom
|
||||
import com.unciv.ui.worldscreen.unit.UnitActions
|
||||
|
||||
@ -34,11 +35,11 @@ class GameInfo {
|
||||
// maybe one of them has a wonder that affects the stats of all the rest of the cities
|
||||
|
||||
for (civInfo in civilizations){
|
||||
if(!civInfo.isPlayerCivilization())
|
||||
automateMoves(civInfo)
|
||||
for (city in civInfo.cities)
|
||||
city.cityStats.update()
|
||||
civInfo.happiness = civInfo.getHappinessForNextTurn()
|
||||
if(!civInfo.isPlayerCivilization())
|
||||
automateMoves(civInfo)
|
||||
}
|
||||
|
||||
if(turns%10 == 0){ // every 10 turns add a barbarian in a random place
|
||||
@ -74,6 +75,12 @@ class GameInfo {
|
||||
|
||||
|
||||
private fun automateMoves(civInfo: CivilizationInfo) {
|
||||
if(civInfo.tech.techsToResearch.isEmpty()) {
|
||||
val researchableTechs = GameBasics.Technologies.values.filter { civInfo.tech.canBeResearched(it.name) }
|
||||
val techToResearch = researchableTechs.minBy { it.cost }
|
||||
civInfo.tech.techsResearched.add(techToResearch!!.name)
|
||||
}
|
||||
|
||||
for(unit in civInfo.getCivUnits()){
|
||||
|
||||
if(unit.name=="Settler") {
|
||||
|
@ -149,9 +149,9 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
|
||||
// This is some crazy voodoo magic so I'll explain.
|
||||
|
||||
image.setSize(40f, 2f)
|
||||
image.moveBy(this.width/2-image.width/2,
|
||||
this.height/2-image.height/2)
|
||||
image.setSize(35f, 2f)
|
||||
image.moveBy(width/2-image.width/2, // center
|
||||
height/2-image.height/2)
|
||||
// in addTiles, we set the position of groups by relative world position *0.8*groupSize, filter groupSize = 50
|
||||
// Here, we want to have the borders start HALFWAY THERE and extend towards the tiles, so we give them a position of 0.8*25.
|
||||
// BUT, we don't actually want it all the way out there, because we want to display the borders of 2 different civs!
|
||||
|
@ -89,7 +89,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
WG.update(false)
|
||||
}
|
||||
|
||||
for (string in civInfo.getViewableTiles()
|
||||
val civViewableTiles = civInfo.getViewableTiles()
|
||||
for (string in civViewableTiles
|
||||
.filter { tileGroups.containsKey(it) }) {
|
||||
|
||||
tileGroups[string]!!.run {
|
||||
@ -112,7 +113,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
UnitType.Ranged -> attackableTiles = unit.getTile().getTilesInDistance(2)
|
||||
}
|
||||
|
||||
for (tile in attackableTiles.filter { it.unit!=null && it.unit!!.owner != unit.owner })
|
||||
for (tile in attackableTiles.filter { it.unit!=null && it.unit!!.owner != unit.owner && civViewableTiles.contains(it)})
|
||||
tileGroups[tile]!!.showCircle(Color(237/255f,41/255f,57/255f,1f))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user