mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
Submarine is invisible now, except to submarines and destroyers. But it still can be aimed by everybody.
This commit is contained in:
parent
209eb4c73b
commit
36d7b30279
@ -467,7 +467,7 @@
|
|||||||
strength:55,
|
strength:55,
|
||||||
cost: 375,
|
cost: 375,
|
||||||
requiredTech:"Combustion",
|
requiredTech:"Combustion",
|
||||||
uniques:[], // todo: add interception and bonus vs submarines once we have air and submarine units
|
uniques:["Can attack submarines"], // todo: add interception and bonus vs submarines once we have air and submarine units
|
||||||
hurryCostModifier:20
|
hurryCostModifier:20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -491,7 +491,7 @@
|
|||||||
rangedStrength: 60,
|
rangedStrength: 60,
|
||||||
cost: 325,
|
cost: 325,
|
||||||
requiredTech:"Refrigeration",
|
requiredTech:"Refrigeration",
|
||||||
uniques:["Bonus as Attacker 75%", "Invisible to others", "Can Only Attack Water"], //to do: 3 uniques
|
uniques:["Bonus as Attacker 75%", "Invisible to others", "Can Only Attack Water", "Can attack submarines"], //to do: 3 uniques
|
||||||
hurryCostModifier:20
|
hurryCostModifier:20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@ class CivilizationInfo {
|
|||||||
*/
|
*/
|
||||||
@Transient private var units=ArrayList<MapUnit>()
|
@Transient private var units=ArrayList<MapUnit>()
|
||||||
@Transient var viewableTiles = HashSet<TileInfo>()
|
@Transient var viewableTiles = HashSet<TileInfo>()
|
||||||
|
@Transient var viewableInvisibleUnitsTiles = HashSet<TileInfo>()
|
||||||
|
|
||||||
var gold = 0
|
var gold = 0
|
||||||
var happiness = 15
|
var happiness = 15
|
||||||
@ -228,6 +229,9 @@ class CivilizationInfo {
|
|||||||
newViewableTiles.addAll(getCivUnits().flatMap { it.getViewableTiles()})
|
newViewableTiles.addAll(getCivUnits().flatMap { it.getViewableTiles()})
|
||||||
viewableTiles = newViewableTiles // to avoid concurrent modification problems
|
viewableTiles = newViewableTiles // to avoid concurrent modification problems
|
||||||
|
|
||||||
|
val newViewableInvisibleTiles = HashSet<TileInfo>()
|
||||||
|
newViewableInvisibleTiles.addAll(getCivUnits().filter {it.hasUnique("Can attack submarines")}.flatMap {it.getViewableTiles()})
|
||||||
|
viewableInvisibleUnitsTiles = newViewableInvisibleTiles
|
||||||
// updating the viewable tiles also affects the explored tiles, obvs
|
// updating the viewable tiles also affects the explored tiles, obvs
|
||||||
|
|
||||||
val newExploredTiles = HashSet<Vector2>(exploredTiles)
|
val newExploredTiles = HashSet<Vector2>(exploredTiles)
|
||||||
|
@ -177,6 +177,12 @@ class MapUnit {
|
|||||||
return currentTile.baseTerrain=="Ocean"||currentTile.baseTerrain=="Coast"
|
return currentTile.baseTerrain=="Ocean"||currentTile.baseTerrain=="Coast"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isInvisible(): Boolean {
|
||||||
|
if(hasUnique("Invisible to others"))
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
fun getEmbarkedMovement(): Int {
|
fun getEmbarkedMovement(): Int {
|
||||||
var movement=2
|
var movement=2
|
||||||
movement += civInfo.tech.getUniques().count { it == "Increases embarked movement +1" }
|
movement += civInfo.tech.getUniques().count { it == "Increases embarked movement +1" }
|
||||||
|
@ -281,5 +281,14 @@ open class TileInfo {
|
|||||||
turnsToImprovement = improvement.getTurnsToBuild(civInfo)
|
turnsToImprovement = improvement.getTurnsToBuild(civInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasEnemySubmarine(): Boolean {
|
||||||
|
val unitsInTile = getUnits()
|
||||||
|
if (unitsInTile.isEmpty()) return false
|
||||||
|
if (!unitsInTile.first().civInfo.isPlayerCivilization() &&
|
||||||
|
unitsInTile.firstOrNull {it.isInvisible() == true} != null) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
@ -23,8 +23,10 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(
|
|||||||
fun update() {
|
fun update() {
|
||||||
val canSeeTile = UnCivGame.Current.viewEntireMapForDebug
|
val canSeeTile = UnCivGame.Current.viewEntireMapForDebug
|
||||||
|| city.civInfo.viewableTiles.contains(tileInfo)
|
|| city.civInfo.viewableTiles.contains(tileInfo)
|
||||||
|
val showSubmarine = UnCivGame.Current.viewEntireMapForDebug
|
||||||
super.update(canSeeTile,true)
|
|| city.civInfo.viewableInvisibleUnitsTiles.contains(tileInfo)
|
||||||
|
|| (!tileInfo.hasEnemySubmarine())
|
||||||
|
super.update(canSeeTile,true, showSubmarine)
|
||||||
|
|
||||||
updatePopulationImage()
|
updatePopulationImage()
|
||||||
if (improvementImage != null) improvementImage!!.setColor(1f, 1f, 1f, 0.5f)
|
if (improvementImage != null) improvementImage!!.setColor(1f, 1f, 1f, 0.5f)
|
||||||
|
@ -133,7 +133,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
open fun update(isViewable: Boolean, showResourcesAndImprovements:Boolean) {
|
open fun update(isViewable: Boolean, showResourcesAndImprovements:Boolean, showSubmarine: Boolean) {
|
||||||
hideCircle()
|
hideCircle()
|
||||||
if (!UnCivGame.Current.viewEntireMapForDebug
|
if (!UnCivGame.Current.viewEntireMapForDebug
|
||||||
&& !tileInfo.tileMap.gameInfo.getPlayerCivilization().exploredTiles.contains(tileInfo.position)) {
|
&& !tileInfo.tileMap.gameInfo.getPlayerCivilization().exploredTiles.contains(tileInfo.position)) {
|
||||||
@ -150,7 +150,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
|
|
||||||
|
|
||||||
civilianUnitImage = newUnitImage(tileInfo.civilianUnit, civilianUnitImage, isViewable, -20f)
|
civilianUnitImage = newUnitImage(tileInfo.civilianUnit, civilianUnitImage, isViewable, -20f)
|
||||||
militaryUnitImage = newUnitImage(tileInfo.militaryUnit, militaryUnitImage, isViewable, 20f)
|
militaryUnitImage = newUnitImage(tileInfo.militaryUnit, militaryUnitImage, isViewable && showSubmarine, 20f)
|
||||||
|
|
||||||
updateRoadImages()
|
updateRoadImages()
|
||||||
updateBorderImages()
|
updateBorderImages()
|
||||||
|
@ -23,7 +23,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun update(isViewable: Boolean) {
|
fun update(isViewable: Boolean, showSubmarine: Boolean) {
|
||||||
val city = tileInfo.getCity()
|
val city = tileInfo.getCity()
|
||||||
|
|
||||||
removePopulationIcon()
|
removePopulationIcon()
|
||||||
@ -36,7 +36,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
updateCityButton(city, isViewable || UnCivGame.Current.viewEntireMapForDebug) // needs to be before the update so the units will be above the city button
|
updateCityButton(city, isViewable || UnCivGame.Current.viewEntireMapForDebug) // needs to be before the update so the units will be above the city button
|
||||||
|
|
||||||
super.update(isViewable || UnCivGame.Current.viewEntireMapForDebug,
|
super.update(isViewable || UnCivGame.Current.viewEntireMapForDebug,
|
||||||
UnCivGame.Current.settings.showResourcesAndImprovements)
|
UnCivGame.Current.settings.showResourcesAndImprovements, showSubmarine)
|
||||||
|
|
||||||
yieldGroup.isVisible = !UnCivGame.Current.settings.showResourcesAndImprovements
|
yieldGroup.isVisible = !UnCivGame.Current.settings.showResourcesAndImprovements
|
||||||
if (yieldGroup.isVisible)
|
if (yieldGroup.isVisible)
|
||||||
|
@ -180,6 +180,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
|
|
||||||
internal fun updateTiles(civInfo: CivilizationInfo) {
|
internal fun updateTiles(civInfo: CivilizationInfo) {
|
||||||
val playerViewableTilePositions = civInfo.viewableTiles.map { it.position }.toHashSet()
|
val playerViewableTilePositions = civInfo.viewableTiles.map { it.position }.toHashSet()
|
||||||
|
val playerViewableInvisibleUnitsTilePositions = civInfo.viewableInvisibleUnitsTiles.map { it.position }.toHashSet()
|
||||||
|
|
||||||
cityButtonOverlays.forEach{it.remove()}
|
cityButtonOverlays.forEach{it.remove()}
|
||||||
cityButtonOverlays.clear()
|
cityButtonOverlays.clear()
|
||||||
@ -187,9 +188,16 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
for (tileGroup in tileGroups.values){
|
for (tileGroup in tileGroups.values){
|
||||||
val canSeeTile = UnCivGame.Current.viewEntireMapForDebug
|
val canSeeTile = UnCivGame.Current.viewEntireMapForDebug
|
||||||
|| playerViewableTilePositions.contains(tileGroup.tileInfo.position)
|
|| playerViewableTilePositions.contains(tileGroup.tileInfo.position)
|
||||||
tileGroup.update(canSeeTile)
|
|
||||||
|
val showSubmarine = UnCivGame.Current.viewEntireMapForDebug
|
||||||
|
|| playerViewableInvisibleUnitsTilePositions.contains(tileGroup.tileInfo.position)
|
||||||
|
|| (!tileGroup.tileInfo.hasEnemySubmarine())
|
||||||
|
tileGroup.update(canSeeTile, showSubmarine)
|
||||||
|
|
||||||
val unitsInTile = tileGroup.tileInfo.getUnits()
|
val unitsInTile = tileGroup.tileInfo.getUnits()
|
||||||
if(canSeeTile && unitsInTile.isNotEmpty() && !unitsInTile.first().civInfo.isPlayerCivilization())
|
val canSeeEnemy = unitsInTile.isNotEmpty() && !unitsInTile.first().civInfo.isPlayerCivilization()
|
||||||
|
&& (showSubmarine || unitsInTile.firstOrNull {!it.isInvisible()}!=null)
|
||||||
|
if(canSeeTile && canSeeEnemy)
|
||||||
tileGroup.showCircle(Color.RED) // Display ALL viewable enemies with a red circle so that users don't need to go "hunting" for enemy units
|
tileGroup.showCircle(Color.RED) // Display ALL viewable enemies with a red circle so that users don't need to go "hunting" for enemy units
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user