Take map relief into account (#2389)

This commit is contained in:
Jack Rainy 2020-04-12 16:39:53 +03:00 committed by GitHub
parent 65b7927df6
commit 23c6fad5db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,7 @@ import com.unciv.logic.automation.UnitAutomation
import com.unciv.logic.city.CityInfo import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.map.* import com.unciv.logic.map.*
import com.unciv.models.AttackableTile
import com.unciv.models.UncivSound import com.unciv.models.UncivSound
import com.unciv.models.ruleset.unit.UnitType import com.unciv.models.ruleset.unit.UnitType
import com.unciv.ui.map.TileGroupMap import com.unciv.ui.map.TileGroupMap
@ -261,23 +262,24 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
if (UncivGame.Current.settings.singleTapMove || isAirUnit) 0.7f else 0.3f) if (UncivGame.Current.settings.singleTapMove || isAirUnit) 0.7f else 0.3f)
} }
val unitType = unit.type val attackableTiles: List<AttackableTile> = if (unit.type.isCivilian()) listOf()
val attackableTiles: List<TileInfo> = if (unitType.isCivilian()) listOf()
else { else {
val tiles = BattleHelper.getAttackableEnemies(unit, unit.movement.getDistanceToTiles()).map { it.tileToAttack } BattleHelper.getAttackableEnemies(unit, unit.movement.getDistanceToTiles())
tiles.filter { (UncivGame.Current.viewEntireMapForDebug || playerViewableTilePositions.contains(it.position)) } .filter { (UncivGame.Current.viewEntireMapForDebug ||
playerViewableTilePositions.contains(it.tileToAttack.position)) }
.distinctBy { it.tileToAttack }
} }
for (attackableTile in attackableTiles) { for (attackableTile in attackableTiles) {
tileGroups[attackableTile]!!.showCircle(colorFromRGB(237, 41, 57)) tileGroups[attackableTile.tileToAttack]!!.showCircle(colorFromRGB(237, 41, 57))
val distance = unit.currentTile.aerialDistanceTo(attackableTile)
if (distance > unit.getRange())
tileGroups[attackableTile]!!.showCrosshair(colorFromRGB(255, 75, 0))
else
tileGroups[attackableTile]!!.showCrosshair(Color.RED)
tileGroups[attackableTile.tileToAttack]!!.showCrosshair (
// the targets which cannot be attacked without movements shown as orange-ish
if (attackableTile.tileToAttackFrom != unit.currentTile)
colorFromRGB(255, 75, 0)
else Color.RED
)
} }
// Fade out less relevant images if a military unit is selected // Fade out less relevant images if a military unit is selected