Unit table now displays range for ranged units

Air units are ranged units
Moving air units around now works completely!
This commit is contained in:
Yair Morgenstern 2019-07-05 14:27:39 +03:00
parent 8d79cca70d
commit 070d780e18
10 changed files with 111 additions and 77 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -1294,77 +1294,77 @@ PolicyIcons/Protectionism
index: -1
PolicyIcons/Reformation
rotate: false
xy: 1714, 3
xy: 1766, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Representation
rotate: false
xy: 1766, 3
xy: 1818, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Republic
rotate: false
xy: 1818, 3
xy: 1870, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Scientific Revolution
rotate: false
xy: 1870, 3
xy: 1922, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Secularism
rotate: false
xy: 1922, 3
xy: 1974, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Sovereignty
rotate: false
xy: 1974, 3
xy: 2026, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Theocracy
rotate: false
xy: 2026, 3
xy: 2078, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Total War
rotate: false
xy: 2078, 3
xy: 2130, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Trade Unions
rotate: false
xy: 2130, 3
xy: 2182, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Universal Suffrage
rotate: false
xy: 2182, 3
xy: 2234, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
PolicyIcons/Warrior Code
rotate: false
xy: 2234, 3
xy: 2286, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
@ -1642,13 +1642,20 @@ StatIcons/Production
orig: 200, 200
offset: 0, 0
index: -1
StatIcons/RangedStrength
StatIcons/Range
rotate: false
xy: 1662, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
StatIcons/RangedStrength
rotate: false
xy: 1714, 3
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
StatIcons/Resistance
rotate: false
xy: 1304, 413
@ -2337,21 +2344,21 @@ TileSets/FantasyHex/Desert+Oasis
index: -1
TileSets/FantasyHex/Grassland
rotate: false
xy: 2286, 25
xy: 2338, 25
size: 32, 28
orig: 32, 28
offset: 0, 0
index: -1
TileSets/FantasyHex/TopRightBorder
rotate: false
xy: 2286, 25
xy: 2338, 25
size: 32, 28
orig: 32, 28
offset: 0, 0
index: -1
TileSets/FantasyHex/Grassland+Forest
rotate: false
xy: 2426, 414
xy: 2426, 413
size: 31, 29
orig: 31, 29
offset: 0, 0
@ -2386,7 +2393,7 @@ TileSets/FantasyHex/Hill+Forest
index: -1
TileSets/FantasyHex/Lakes
rotate: false
xy: 2320, 25
xy: 2372, 25
size: 32, 28
orig: 32, 28
offset: 0, 0
@ -2407,56 +2414,56 @@ TileSets/FantasyHex/Ocean
index: -1
TileSets/FantasyHex/Plains
rotate: false
xy: 2354, 25
xy: 2406, 25
size: 32, 28
orig: 32, 28
offset: 0, 0
index: -1
TileSets/FantasyHex/Plains+City
rotate: false
xy: 2388, 18
xy: 2426, 580
size: 32, 35
orig: 32, 35
offset: 0, 0
index: -1
TileSets/FantasyHex/Plains+Forest
rotate: false
xy: 2438, 1523
xy: 2426, 545
size: 32, 33
orig: 32, 33
offset: 0, 0
index: -1
TileSets/FantasyHex/Plains+Jungle
rotate: false
xy: 2426, 580
xy: 2426, 508
size: 32, 35
orig: 32, 35
offset: 0, 0
index: -1
TileSets/FantasyHex/TopBorder
rotate: false
xy: 2426, 550
xy: 2426, 478
size: 32, 28
orig: 32, 28
offset: 0, 0
index: -1
TileSets/FantasyHex/Tundra
rotate: false
xy: 2426, 516
xy: 2426, 444
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1
TileSets/FantasyHex/Tundra+City
rotate: false
xy: 2426, 479
xy: 2438, 1521
size: 32, 35
orig: 32, 35
offset: 0, 0
index: -1
TileSets/FantasyHex/Tundra+Forest
rotate: false
xy: 2426, 445
xy: 1006, 15
size: 32, 32
orig: 32, 32
offset: 0, 0
@ -3051,7 +3058,7 @@ UnitPromotionIcons/Boarding_Party_II_(Civ5)
index: -1
UnitPromotionIcons/Boarding_Party_I_(Civ5)
rotate: false
xy: 2459, 423
xy: 2459, 422
size: 20, 20
orig: 20, 20
offset: 0, 0
@ -3072,147 +3079,147 @@ UnitPromotionIcons/Bombardment_II_(Civ5)
index: -1
UnitPromotionIcons/Bombardment_I_(Civ5)
rotate: false
xy: 538, 5
xy: 2442, 55
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Charge_(Civ5)
rotate: false
xy: 1006, 27
xy: 2338, 3
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Coastal_Raider_III_(Civ5)
rotate: false
xy: 2442, 55
xy: 458, 669
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Coastal_Raider_II_(Civ5)
rotate: false
xy: 458, 669
xy: 2440, 33
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Coastal_Raider_I_(Civ5)
rotate: false
xy: 2286, 3
xy: 538, 5
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Cover_II_(Civ5)
rotate: false
xy: 2422, 33
xy: 1172, 1281
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Cover_I_(Civ5)
rotate: false
xy: 1172, 1281
xy: 312, 51
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Drill_III_(Civ5)
rotate: false
xy: 312, 51
xy: 334, 71
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Drill_II_(Civ5)
rotate: false
xy: 334, 71
xy: 281, 1643
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Drill_I_(Civ5)
rotate: false
xy: 281, 1643
xy: 379, 1259
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Formation_II_(Civ5)
rotate: false
xy: 379, 1259
xy: 2360, 3
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Formation_I_(Civ5)
rotate: false
xy: 560, 5
xy: 458, 647
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Heal_Instantly_(Civ5)
rotate: false
xy: 458, 647
xy: 560, 5
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Indirect_Fire_(Civ5)
rotate: false
xy: 2308, 3
xy: 1172, 1259
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Logistics_(Civ5)
rotate: false
xy: 1172, 1259
xy: 312, 29
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/March_(Civ5)
rotate: false
xy: 312, 29
xy: 334, 49
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Medic_(Civ5)
rotate: false
xy: 334, 49
xy: 356, 71
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Medic_II_(Civ5)
rotate: false
xy: 334, 49
xy: 356, 71
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Mobility_(Civ5)
rotate: false
xy: 356, 71
xy: 281, 1621
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Range_(Civ5)
rotate: false
xy: 281, 1621
xy: 379, 1237
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Scouting_III_(Civ5)
rotate: false
xy: 379, 1237
xy: 2382, 3
size: 20, 20
orig: 20, 20
offset: 0, 0
@ -3226,28 +3233,28 @@ UnitPromotionIcons/Scouting_II_(Civ5)
index: -1
UnitPromotionIcons/Scouting_I_(Civ5)
rotate: false
xy: 2330, 3
xy: 356, 49
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Sentry_(Civ5)
rotate: false
xy: 356, 49
xy: 378, 71
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Shock_III_(Civ5)
rotate: false
xy: 378, 71
xy: 379, 1215
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Shock_II_(Civ5)
rotate: false
xy: 379, 1215
xy: 2404, 3
size: 20, 20
orig: 20, 20
offset: 0, 0
@ -3261,63 +3268,63 @@ UnitPromotionIcons/Shock_I_(Civ5)
index: -1
UnitPromotionIcons/Siege_(Civ5)
rotate: false
xy: 2352, 3
xy: 378, 49
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Targeting_III_(Civ5)
rotate: false
xy: 378, 49
xy: 400, 71
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Targeting_II_(Civ5)
rotate: false
xy: 400, 71
xy: 626, 5
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Targeting_I_(Civ5)
rotate: false
xy: 626, 5
xy: 400, 49
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Volley_(Civ5)
rotate: false
xy: 400, 49
xy: 648, 5
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Wolfpack_III_(Civ5)
rotate: false
xy: 648, 5
xy: 670, 5
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Wolfpack_II_(Civ5)
rotate: false
xy: 670, 5
xy: 692, 5
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Wolfpack_I_(Civ5)
rotate: false
xy: 692, 5
xy: 714, 5
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
UnitPromotionIcons/Woodsman_(Civ5)
rotate: false
xy: 714, 5
xy: 736, 5
size: 20, 20
orig: 20, 20
offset: 0, 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 997 KiB

After

Width:  |  Height:  |  Size: 999 KiB

View file

@ -838,18 +838,20 @@
hurryCostModifier:20,
attackSound:"shot"
},
/*
{
name:"Triplane",
unitType:"AirFighter",
movement:1,
strength:34,
cost: 225,
strength:35,
rangedStrength:35,
range:5,
cost: 325,
requiredTech:"Flight",
hurryCostModifier:20,
attackSound:"shot"
},
*/
/*
{
name:"Norvegian Ski Infantry",

View file

@ -129,18 +129,23 @@ class MapUnit {
// we need to map all the places that this could change: Unit changes locations, owners, gets promotion?
fun updateViewableTiles() {
var visibilityRange = 2
visibilityRange += getUniques().count{it=="+1 Visibility Range"}
if(hasUnique("Limited Visibility")) visibilityRange-=1
if(civInfo.getNation().unique=="All land military units have +1 sight, 50% discount when purchasing tiles")
visibilityRange += 1
if(type.isWaterUnit() && !type.isCivilian()
&& civInfo.getBuildingUniques().contains("All military naval units receive +1 movement and +1 sight"))
visibilityRange += 1
val tile = getTile()
if (tile.baseTerrain == Constants.hill && type.isLandUnit()) visibilityRange += 1
viewableTiles = tile.getViewableTiles(visibilityRange, type.isWaterUnit())
if(type.isAirUnit()){
viewableTiles = getTile().getTilesInDistance(6) // it's that simple
}
else {
var visibilityRange = 2
visibilityRange += getUniques().count { it == "+1 Visibility Range" }
if (hasUnique("Limited Visibility")) visibilityRange -= 1
if (civInfo.getNation().unique == "All land military units have +1 sight, 50% discount when purchasing tiles")
visibilityRange += 1
if (type.isWaterUnit() && !type.isCivilian()
&& civInfo.getBuildingUniques().contains("All military naval units receive +1 movement and +1 sight"))
visibilityRange += 1
val tile = getTile()
if (tile.baseTerrain == Constants.hill && type.isLandUnit()) visibilityRange += 1
viewableTiles = tile.getViewableTiles(visibilityRange, type.isWaterUnit())
}
civInfo.updateViewableTiles() // for the civ
}

View file

@ -143,6 +143,11 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
val currentTile = unit.getTile()
if (currentTile == destination) return currentTile
if(unit.type.isAirUnit()){
unit.moveToTile(destination)
return destination
}
val distanceToTiles = unit.getDistanceToTiles()
val destinationTileThisTurn: TileInfo
@ -174,6 +179,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
}
fun canReach(destination: TileInfo): Boolean {
if(unit.type.isAirUnit())
return unit.currentTile.arialDistanceTo(destination) <= unit.getRange()
return getShortestPath(destination).isNotEmpty()
}

View file

@ -31,6 +31,7 @@ enum class UnitType{
|| this == WaterRanged
|| this == WaterSubmarine
|| this == City
|| this.isAirUnit()
}
fun isLandUnit(): Boolean {

View file

@ -14,6 +14,7 @@ class WorldTileGroup(internal val worldScreen: WorldScreen, tileInfo: TileInfo)
var cityButton: CityButton? = null
fun selectUnit(unit: MapUnit) {
if(unit.type.isAirUnit()) return // doesn't appear on map so nothing to select
val unitImage = if (unit.type.isCivilian()) civilianUnitImage
else militaryUnitImage
unitImage?.selectUnit()

View file

@ -131,7 +131,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
* The only "heavy lifting" that needs to be done is getting the turns to get there,
* so that and that alone will be relegated to the concurrent thread.
*/
val turnsToGetThere = selectedUnit.movementAlgs().getShortestPath(tileInfo).size // this is what takes the most time, tbh
val turnsToGetThere = if(selectedUnit.type.isAirUnit()) 1
else selectedUnit.movementAlgs().getShortestPath(tileInfo).size // this is what takes the most time, tbh
Gdx.app.postRunnable {
if(UnCivGame.Current.settings.singleTapMove && turnsToGetThere==1) {
@ -284,9 +285,14 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
tileGroups[unit.getTile()]!!.selectUnit(unit)
for (tile: TileInfo in unit.getDistanceToTiles().keys)
val isAirUnit = unit.type.isAirUnit()
val tilesInMoveRange = if(isAirUnit) unit.getTile().getTilesInDistance(unit.getRange())
else unit.getDistanceToTiles().keys
for (tile: TileInfo in tilesInMoveRange)
if (unit.canMoveTo(tile))
tileGroups[tile]!!.showCircle(Color.WHITE, if (UnCivGame.Current.settings.singleTapMove) 0.7f else 0.3f)
tileGroups[tile]!!.showCircle(Color.WHITE,
if (UnCivGame.Current.settings.singleTapMove || isAirUnit) 0.7f else 0.3f)
val unitType = unit.type
val attackableTiles: List<TileInfo> = when {

View file

@ -132,6 +132,11 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
unitDescriptionTable.add(unit.baseUnit().rangedStrength.toString()).padRight(10f)
}
if(unit.type.isRanged()){
unitDescriptionTable.add(ImageGetter.getStatIcon("Range")).size(20f)
unitDescriptionTable.add(unit.getRange().toString()).padRight(10f)
}
if (!unit.type.isCivilian()) {
unitDescriptionTable.add("XP")
unitDescriptionTable.add(unit.promotions.XP.toString()+"/"+unit.promotions.xpForNextPromotion())