mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 23:44:24 +07:00
Civ 5: unit selection and cycling behaviour, "Wait" action (#8202)
Co-authored-by: tunerzinc@gmail.com <vfylfhby>
This commit is contained in:
parent
9dce968ce0
commit
f4c91126bc
@ -383,10 +383,12 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
||||
val groupHeight = 25f
|
||||
val groupWidth = if (cityCurrentConstruction is PerpetualConstruction) 15f else 40f
|
||||
group.setSize(groupWidth, groupHeight)
|
||||
val constructionImage = ImageGetter.getPortraitImage(cityConstructions.currentConstructionFromQueue, 25f)
|
||||
constructionImage.centerY(group)
|
||||
constructionImage.x = group.width - constructionImage.width
|
||||
group.addActor(constructionImage)
|
||||
if (cityConstructions.currentConstructionFromQueue.isNotEmpty()) {
|
||||
val constructionImage = ImageGetter.getPortraitImage(cityCurrentConstruction.name, 25f)
|
||||
constructionImage.centerY(group)
|
||||
constructionImage.x = group.width - constructionImage.width
|
||||
group.addActor(constructionImage)
|
||||
}
|
||||
|
||||
val secondaryColor = cityConstructions.cityInfo.civInfo.nation.getInnerColor()
|
||||
if (cityCurrentConstruction !is PerpetualConstruction) {
|
||||
|
@ -649,10 +649,12 @@ class WorldScreen(
|
||||
selectUnit = false
|
||||
)
|
||||
bottomUnitTable.selectUnit(nextDueUnit)
|
||||
shouldUpdate = true
|
||||
// Unless 'wait' action is chosen, the unit will not be considered due anymore.
|
||||
nextDueUnit.due = false
|
||||
} else {
|
||||
mapHolder.removeAction(mapHolder.blinkAction)
|
||||
mapHolder.selectedTile = null
|
||||
bottomUnitTable.selectUnit()
|
||||
}
|
||||
shouldUpdate = true
|
||||
}
|
||||
|
||||
private fun isNextTurnUpdateRunning(): Boolean {
|
||||
|
@ -945,12 +945,10 @@ object UnitActions {
|
||||
}
|
||||
|
||||
private fun addWaitAction(unit: MapUnit, actionList: ArrayList<UnitAction>, worldScreen: WorldScreen) {
|
||||
if (!unit.isIdle()) return
|
||||
if (worldScreen.viewingCiv.getDueUnits().filter { it != unit }.none()) return
|
||||
actionList += UnitAction(
|
||||
type = UnitActionType.Wait,
|
||||
action = {
|
||||
unit.due = true
|
||||
unit.due = false
|
||||
worldScreen.switchToNextUnit()
|
||||
}
|
||||
)
|
||||
|
@ -11,6 +11,7 @@ import com.unciv.logic.battle.CityCombatant
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.civilopedia.CivilopediaCategories
|
||||
import com.unciv.ui.civilopedia.CivilopediaScreen
|
||||
@ -285,20 +286,42 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
|
||||
// Do no select a different unit while in Air Sweep mode
|
||||
if (selectedUnit != null && selectedUnit!!.isPreparingAirSweep()) return
|
||||
|
||||
fun isViewingCiv(unit:MapUnit): Boolean = unit.civInfo == worldScreen.viewingCiv || worldScreen.viewingCiv.isSpectator()
|
||||
|
||||
// Civ 5 Order of selection:
|
||||
// 1. City
|
||||
// 2. GP + Settlers
|
||||
// 3. Military
|
||||
// 4. Other civilian (Workers)
|
||||
// 5. None (Deselect)
|
||||
|
||||
when {
|
||||
forceSelectUnit != null ->
|
||||
selectUnit(forceSelectUnit)
|
||||
selectedTile.isCityCenter() &&
|
||||
(selectedTile.getOwner() == worldScreen.viewingCiv || worldScreen.viewingCiv.isSpectator()) ->
|
||||
citySelected(selectedTile.getCity()!!)
|
||||
selectedTile.militaryUnit != null &&
|
||||
(selectedTile.militaryUnit!!.civInfo == worldScreen.viewingCiv || worldScreen.viewingCiv.isSpectator()) &&
|
||||
selectedTile.militaryUnit!! !in selectedUnits &&
|
||||
(selectedTile.civilianUnit == null || selectedUnit != selectedTile.civilianUnit) -> // Only select the military unit there if we do not currently have the civilian unit selected
|
||||
selectUnit(selectedTile.militaryUnit!!, Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT))
|
||||
|
||||
// Settlers and GP come first
|
||||
|
||||
selectedTile.civilianUnit != null
|
||||
&& (selectedTile.civilianUnit!!.civInfo == worldScreen.viewingCiv || worldScreen.viewingCiv.isSpectator())
|
||||
&& selectedUnit != selectedTile.civilianUnit ->
|
||||
&& isViewingCiv(selectedTile.civilianUnit!!)
|
||||
&& (selectedTile.civilianUnit!!.isGreatPerson() || selectedTile.civilianUnit!!.hasUnique(UniqueType.FoundCity))
|
||||
&& selectedTile.civilianUnit!! !in selectedUnits
|
||||
&& (selectedTile.militaryUnit == null || selectedUnit != selectedTile.militaryUnit) ->
|
||||
selectUnit(selectedTile.civilianUnit!!, Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT))
|
||||
|
||||
// Then military
|
||||
selectedTile.militaryUnit != null
|
||||
&& isViewingCiv(selectedTile.militaryUnit!!)
|
||||
&& selectedTile.militaryUnit!! !in selectedUnits
|
||||
&& (selectedTile.civilianUnit == null || selectedUnit != selectedTile.civilianUnit) -> // Only select the military unit there if we do not currently have the civilian unit selected
|
||||
selectUnit(selectedTile.militaryUnit!!, Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT))
|
||||
|
||||
// Then the rest
|
||||
selectedTile.civilianUnit != null
|
||||
&& isViewingCiv(selectedTile.civilianUnit!!)
|
||||
&& selectedTile.civilianUnit!! !in selectedUnits ->
|
||||
selectUnit(selectedTile.civilianUnit!!, Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT))
|
||||
selectedTile == previouslySelectedUnit?.currentTile -> {
|
||||
// tapping the same tile again will deselect a unit.
|
||||
@ -313,4 +336,3 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user