mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-09 23:07:35 +07:00
a7afc0718c
* Added an icon for unit swapping * Implemented unit swapping In the original Civ V, unit swapping is a supported mechanic. If you try to move a unit to a tile with another of your units, and both units have enough movement points left to reach the other's tile, they will swap places. They will consume only the movement points needed to reach the other's tile in this way. This change implements unit swapping for Unciv. To prevent all kinds of problems from arising with automatic unit movement, unit swapping can only be done explicitly. This also means that it can only be done if the unit-swap movement is possible in a single turn. It is however not limited to adjacent units. Because Unciv supports mobile devices, there is in general no separation between a unit-selection click and a movement click. Clicking on another unit while a unit is selected simply selects that other unit. Because we do not want to make it more difficult to select other units in this way, unit swapping is implemented as a separate "movement mode": to toggle this mode on or off, the new unit action "Swap units" must be used. Newly selected units still always start in the normal movement mode. In the unit-swap movement mode, the possible swap tiles are highlighted instead of the possible movement and attack tiles. Clicking on a highlighted tile will display a swap button, similar to the movement button, or instantly perform the swap if single-click-movement is enabled. This new behavior overrides the selection of the unit on the target tile: if the user wants to select the unit instead, they have to exit the unit-swapping mode first. The swapping code is robust, it can even handle swaps that involve a paradrop! An option to always swap-move when an eligible tile is clicked instead of requiring the unit-swapping mode, similar to the existing single-click-movement option, could perhaps be added in later. * Added some comments to existing movement functions * Fixed a silly mistake Fixed a silly mistake which caused the unit-swapping eligibility detection to sometimes remove units from the world. * Removed some unneeded code * Fixed movement buttons not showing with world wrap Fixed a bug where the "move here" and "swap with" buttons would only show on the leftmost copy of the world when world wrap was enabled. * Made the swap action only display if usable Made the unit swapping button only display if there is at least one possible swap movement.
1.9 KiB
100x100px
1.9 KiB
100x100px