mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 09:18:43 +07:00
Fix Paradrop crossing World-wrap seam (#10936)
* Fix Paradrop crossing World-wrap seam problem * Change MoveHereButton for Paradrop
This commit is contained in:
@ -4,13 +4,13 @@ import com.badlogic.gdx.math.Vector2
|
||||
import com.badlogic.gdx.math.Vector3
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.round
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.sign
|
||||
import kotlin.math.sin
|
||||
import kotlin.math.sqrt
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate", "unused") // this is a library offering optional services
|
||||
object HexMath {
|
||||
@ -227,6 +227,7 @@ object HexMath {
|
||||
return hexesToReturn
|
||||
}
|
||||
|
||||
/** Get number of hexes from [origin] to [destination] _without respecting world-wrap_ */
|
||||
fun getDistance(origin: Vector2, destination: Vector2): Int {
|
||||
val relativeX = origin.x - destination.x
|
||||
val relativeY = origin.y - destination.y
|
||||
|
@ -5,7 +5,6 @@ package com.unciv.logic.map.mapunit.movement
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.map.BFS
|
||||
import com.unciv.logic.map.HexMath.getDistance
|
||||
import com.unciv.logic.map.mapunit.MapUnit
|
||||
import com.unciv.logic.map.tile.Tile
|
||||
import com.unciv.models.UnitActionType
|
||||
@ -258,7 +257,7 @@ class UnitMovement(val unit: MapUnit) {
|
||||
if (unit.baseUnit.movesLikeAirUnits())
|
||||
return unit.currentTile.aerialDistanceTo(destination) <= unit.getMaxMovementForAirUnits()
|
||||
if (unit.isPreparingParadrop())
|
||||
return getDistance(unit.currentTile.position, destination.position) <= unit.cache.paradropRange && canParadropOn(destination)
|
||||
return unit.currentTile.aerialDistanceTo(destination) <= unit.cache.paradropRange && canParadropOn(destination)
|
||||
return getDistanceToTiles().containsKey(destination)
|
||||
}
|
||||
|
||||
|
@ -501,18 +501,22 @@ class WorldMapHolder(
|
||||
val smallerCircleSizes = 25f
|
||||
|
||||
private fun getMoveHereButton(dto: MoveHereButtonDto): Group {
|
||||
val moveHereButton = ImageGetter.getStatIcon("Movement")
|
||||
.apply { color = Color.BLACK; width = buttonSize / 2; height = buttonSize / 2 }
|
||||
.surroundWithCircle(buttonSize-2, false)
|
||||
val isParadrop = dto.unitToTurnsToDestination.keys.all { it.isPreparingParadrop() }
|
||||
val image = if (isParadrop)
|
||||
ImageGetter.getUnitActionPortrait("Paradrop", buttonSize / 2)
|
||||
else ImageGetter.getStatIcon("Movement")
|
||||
.apply { color = Color.BLACK; width = buttonSize / 2; height = buttonSize / 2 }
|
||||
val moveHereButton = image
|
||||
.surroundWithCircle(buttonSize - 2, false)
|
||||
.surroundWithCircle(buttonSize, false, Color.BLACK)
|
||||
|
||||
|
||||
val numberCircle = dto.unitToTurnsToDestination.values.maxOrNull()!!.toString().toLabel(fontSize = 14)
|
||||
.apply { setAlignment(Align.center) }
|
||||
.surroundWithCircle(smallerCircleSizes-2, color = BaseScreen.skinStrings.skinConfig.baseColor.darken(0.3f))
|
||||
.surroundWithCircle(smallerCircleSizes,false)
|
||||
|
||||
moveHereButton.addActor(numberCircle)
|
||||
if (!isParadrop) {
|
||||
val numberCircle = dto.unitToTurnsToDestination.values.maxOrNull()!!.toString().toLabel(fontSize = 14)
|
||||
.apply { setAlignment(Align.center) }
|
||||
.surroundWithCircle(smallerCircleSizes - 2, color = BaseScreen.skinStrings.skinConfig.baseColor.darken(0.3f))
|
||||
.surroundWithCircle(smallerCircleSizes, false)
|
||||
moveHereButton.addActor(numberCircle)
|
||||
}
|
||||
|
||||
val firstUnit = dto.unitToTurnsToDestination.keys.first()
|
||||
val unitIcon = if (dto.unitToTurnsToDestination.size == 1) UnitGroup(firstUnit, smallerCircleSizes)
|
||||
@ -536,7 +540,7 @@ class WorldMapHolder(
|
||||
}
|
||||
|
||||
private fun getSwapWithButton(dto: SwapWithButtonDto): Group {
|
||||
val swapWithButton = Group().apply { width = buttonSize;height = buttonSize; }
|
||||
val swapWithButton = Group().apply { width = buttonSize; height = buttonSize }
|
||||
swapWithButton.addActor(ImageGetter.getCircle().apply { width = buttonSize; height = buttonSize })
|
||||
swapWithButton.addActor(
|
||||
ImageGetter.getImage("OtherIcons/Swap")
|
||||
|
Reference in New Issue
Block a user