mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-06 00:09:23 +07:00
Merge branch 'master' of https://github.com/yairm210/Unciv
This commit is contained in:
@ -462,6 +462,11 @@ class MapUnit {
|
|||||||
removeFromTile()
|
removeFromTile()
|
||||||
civInfo.removeUnit(this)
|
civInfo.removeUnit(this)
|
||||||
civInfo.updateViewableTiles()
|
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(){
|
fun removeFromTile(){
|
||||||
@ -516,18 +521,29 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun disband(){
|
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()
|
destroy()
|
||||||
if(currentTile.getOwner()==civInfo)
|
if(currentTile.getOwner()==civInfo)
|
||||||
civInfo.gold += baseUnit.getDisbandGold()
|
civInfo.gold += baseUnit.getDisbandGold()
|
||||||
if (civInfo.isDefeated()) civInfo.destroy()
|
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) {
|
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.Button
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
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.RoadStatus
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.ruleset.tile.TileImprovement
|
import com.unciv.models.ruleset.tile.TileImprovement
|
||||||
@ -35,8 +36,8 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
|||||||
accept(selectedImprovement)
|
accept(selectedImprovement)
|
||||||
}
|
}
|
||||||
|
|
||||||
val regularImprovements = VerticalGroup()
|
val regularImprovements = Table()
|
||||||
regularImprovements.space(10f)
|
regularImprovements.defaults().pad(5f)
|
||||||
|
|
||||||
for (improvement in tileInfo.tileMap.gameInfo.ruleSet.tileImprovements.values) {
|
for (improvement in tileInfo.tileMap.gameInfo.ruleSet.tileImprovements.values) {
|
||||||
if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue
|
if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue
|
||||||
@ -71,7 +72,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
|||||||
accept(improvement)
|
accept(improvement)
|
||||||
}
|
}
|
||||||
|
|
||||||
val improvementRow = Table()
|
val statIcons = Table()
|
||||||
|
|
||||||
// get benefits of the new improvement
|
// get benefits of the new improvement
|
||||||
val stats = tileInfo.getImprovementStats(improvement, currentPlayerCiv, tileInfo.getCity())
|
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
|
// icon for adding the resource by improvement
|
||||||
if (provideResource)
|
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
|
// icon for removing the resource by replacing improvement
|
||||||
if (removeImprovement && tileInfo.hasViewableResource(currentPlayerCiv) && tileInfo.getTileResource().improvement == tileInfo.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)
|
val resourceIcon = ImageGetter.getResourceImage(tileInfo.resource.toString(), 30f)
|
||||||
crossedResource.addActor(resourceIcon)
|
crossedResource.addActor(resourceIcon)
|
||||||
crossedResource.addActor(cross)
|
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)
|
val improvementButton = Button(skin)
|
||||||
improvementButton.add(group).padRight(10f).fillY()
|
improvementButton.add(group).pad(5f).fillY()
|
||||||
improvementButton.addSeparatorVertical()
|
regularImprovements.add(improvementButton)
|
||||||
improvementButton.add(pickNow).padLeft(10f).fill()
|
regularImprovements.add(pickNow).padLeft(10f)
|
||||||
improvementRow.add(improvementButton)
|
regularImprovements.row()
|
||||||
|
|
||||||
regularImprovements.addActor(improvementRow)
|
|
||||||
}
|
}
|
||||||
topTable.add(regularImprovements)
|
topTable.add(regularImprovements)
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
if(!canBePromoted)
|
if(!canBePromoted)
|
||||||
rightSideButton.disable()
|
rightSideButton.disable()
|
||||||
|
|
||||||
val availablePromotionsGroup = VerticalGroup()
|
val availablePromotionsGroup = Table()
|
||||||
availablePromotionsGroup.space(10f)
|
availablePromotionsGroup.defaults().pad(5f)
|
||||||
|
|
||||||
val unitType = unit.type
|
val unitType = unit.type
|
||||||
val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter {
|
val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter {
|
||||||
@ -67,9 +67,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
descriptionLabel.setText(promotion.getDescription(promotionsForUnitType))
|
descriptionLabel.setText(promotion.getDescription(promotionsForUnitType))
|
||||||
}
|
}
|
||||||
|
|
||||||
val promotionTable = Table()
|
availablePromotionsGroup.add(selectPromotionButton)
|
||||||
promotionTable.add(selectPromotionButton)
|
|
||||||
|
|
||||||
|
|
||||||
if(canBePromoted && isPromotionAvailable) {
|
if(canBePromoted && isPromotionAvailable) {
|
||||||
val pickNow = "Pick now!".toLabel()
|
val pickNow = "Pick now!".toLabel()
|
||||||
@ -77,12 +75,13 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
pickNow.onClick {
|
pickNow.onClick {
|
||||||
acceptPromotion(promotion)
|
acceptPromotion(promotion)
|
||||||
}
|
}
|
||||||
promotionTable.add(pickNow).padLeft(10f).fillY()
|
availablePromotionsGroup.add(pickNow).padLeft(10f).fillY()
|
||||||
}
|
}
|
||||||
else if(unitHasPromotion) selectPromotionButton.color= Color.GREEN
|
else if(unitHasPromotion) selectPromotionButton.color= Color.GREEN
|
||||||
else selectPromotionButton.color= Color.GRAY
|
else selectPromotionButton.color= Color.GRAY
|
||||||
|
|
||||||
availablePromotionsGroup.addActor(promotionTable)
|
availablePromotionsGroup.row()
|
||||||
|
|
||||||
}
|
}
|
||||||
topTable.add(availablePromotionsGroup)
|
topTable.add(availablePromotionsGroup)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user