mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-05 07:49:17 +07:00
Merge branch 'master' of https://github.com/yairm210/Unciv
This commit is contained in:
@ -462,6 +462,11 @@ class MapUnit {
|
||||
removeFromTile()
|
||||
civInfo.removeUnit(this)
|
||||
civInfo.updateViewableTiles()
|
||||
// all transported units should be destroyed as well
|
||||
if (type.isAircraftCarrierUnit() || type.isMissileCarrierUnit()) {
|
||||
currentTile.getUnits().filter { it.type.isAirUnit() && it.isTransported }
|
||||
.forEach { unit -> unit.destroy() }
|
||||
}
|
||||
}
|
||||
|
||||
fun removeFromTile(){
|
||||
@ -516,18 +521,29 @@ class MapUnit {
|
||||
}
|
||||
|
||||
fun disband(){
|
||||
// evacuation of transported units before disbanding, if possible
|
||||
if (type.isAircraftCarrierUnit() || type.isMissileCarrierUnit()) {
|
||||
for(unit in currentTile.getUnits().filter { it.type.isAirUnit() && it.isTransported }) {
|
||||
// we disbanded a carrier in a city, it can still stay in the city
|
||||
if (currentTile.isCityCenter() && unit.movement.canMoveTo(currentTile)) continue
|
||||
// if no "fuel" to escape, should be disbanded as well
|
||||
if (unit.currentMovement < 0.1)
|
||||
unit.disband()
|
||||
// let's find closest city or another carrier where it can be evacuated
|
||||
val tileCanMoveTo = unit.currentTile.getTilesInDistance(unit.getRange()).
|
||||
filterNot { it == currentTile }.firstOrNull{unit.movement.canMoveTo(it)}
|
||||
|
||||
if (tileCanMoveTo!=null)
|
||||
unit.movement.moveToTile(tileCanMoveTo)
|
||||
else
|
||||
unit.disband()
|
||||
}
|
||||
}
|
||||
|
||||
destroy()
|
||||
if(currentTile.getOwner()==civInfo)
|
||||
civInfo.gold += baseUnit.getDisbandGold()
|
||||
if (civInfo.isDefeated()) civInfo.destroy()
|
||||
|
||||
for(unit in currentTile.getUnits().filter { it.type.isAirUnit() && it.isTransported }) {
|
||||
if (unit.movement.canMoveTo(currentTile)) continue // we disbanded a carrier in a city, it can still stay in the city
|
||||
val tileCanMoveTo = unit.currentTile.getTilesInDistance(unit.getRange())
|
||||
.firstOrNull{unit.movement.canMoveTo(it)}
|
||||
if(tileCanMoveTo!=null) unit.movement.moveToTile(tileCanMoveTo)
|
||||
else unit.disband()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAncientRuinBonus(tile: TileInfo) {
|
||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.ruleset.tile.TileImprovement
|
||||
@ -35,8 +36,8 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||
accept(selectedImprovement)
|
||||
}
|
||||
|
||||
val regularImprovements = VerticalGroup()
|
||||
regularImprovements.space(10f)
|
||||
val regularImprovements = Table()
|
||||
regularImprovements.defaults().pad(5f)
|
||||
|
||||
for (improvement in tileInfo.tileMap.gameInfo.ruleSet.tileImprovements.values) {
|
||||
if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue
|
||||
@ -71,7 +72,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||
accept(improvement)
|
||||
}
|
||||
|
||||
val improvementRow = Table()
|
||||
val statIcons = Table()
|
||||
|
||||
// get benefits of the new improvement
|
||||
val stats = tileInfo.getImprovementStats(improvement, currentPlayerCiv, tileInfo.getCity())
|
||||
@ -100,7 +101,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||
|
||||
// icon for adding the resource by improvement
|
||||
if (provideResource)
|
||||
improvementRow.add(ImageGetter.getResourceImage(tileInfo.resource.toString(), 30f)).pad(3f)
|
||||
statIcons.add(ImageGetter.getResourceImage(tileInfo.resource.toString(), 30f)).pad(3f)
|
||||
|
||||
// icon for removing the resource by replacing improvement
|
||||
if (removeImprovement && tileInfo.hasViewableResource(currentPlayerCiv) && tileInfo.getTileResource().improvement == tileInfo.improvement) {
|
||||
@ -111,18 +112,17 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||
val resourceIcon = ImageGetter.getResourceImage(tileInfo.resource.toString(), 30f)
|
||||
crossedResource.addActor(resourceIcon)
|
||||
crossedResource.addActor(cross)
|
||||
improvementRow.add(crossedResource).padTop(30f).padRight(33f)
|
||||
statIcons.add(crossedResource).padTop(30f).padRight(33f)
|
||||
}
|
||||
|
||||
improvementRow.add(statsTable).padLeft(13f)
|
||||
statIcons.add(statsTable).padLeft(13f)
|
||||
regularImprovements.add(statIcons).align(Align.right)
|
||||
|
||||
val improvementButton = Button(skin)
|
||||
improvementButton.add(group).padRight(10f).fillY()
|
||||
improvementButton.addSeparatorVertical()
|
||||
improvementButton.add(pickNow).padLeft(10f).fill()
|
||||
improvementRow.add(improvementButton)
|
||||
|
||||
regularImprovements.addActor(improvementRow)
|
||||
improvementButton.add(group).pad(5f).fillY()
|
||||
regularImprovements.add(improvementButton)
|
||||
regularImprovements.add(pickNow).padLeft(10f)
|
||||
regularImprovements.row()
|
||||
}
|
||||
topTable.add(regularImprovements)
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
if(!canBePromoted)
|
||||
rightSideButton.disable()
|
||||
|
||||
val availablePromotionsGroup = VerticalGroup()
|
||||
availablePromotionsGroup.space(10f)
|
||||
val availablePromotionsGroup = Table()
|
||||
availablePromotionsGroup.defaults().pad(5f)
|
||||
|
||||
val unitType = unit.type
|
||||
val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter {
|
||||
@ -67,9 +67,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
descriptionLabel.setText(promotion.getDescription(promotionsForUnitType))
|
||||
}
|
||||
|
||||
val promotionTable = Table()
|
||||
promotionTable.add(selectPromotionButton)
|
||||
|
||||
availablePromotionsGroup.add(selectPromotionButton)
|
||||
|
||||
if(canBePromoted && isPromotionAvailable) {
|
||||
val pickNow = "Pick now!".toLabel()
|
||||
@ -77,12 +75,13 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
pickNow.onClick {
|
||||
acceptPromotion(promotion)
|
||||
}
|
||||
promotionTable.add(pickNow).padLeft(10f).fillY()
|
||||
availablePromotionsGroup.add(pickNow).padLeft(10f).fillY()
|
||||
}
|
||||
else if(unitHasPromotion) selectPromotionButton.color= Color.GREEN
|
||||
else selectPromotionButton.color= Color.GRAY
|
||||
|
||||
availablePromotionsGroup.addActor(promotionTable)
|
||||
availablePromotionsGroup.row()
|
||||
|
||||
}
|
||||
topTable.add(availablePromotionsGroup)
|
||||
}
|
||||
|
Reference in New Issue
Block a user