Beispiel #1
0
    private void HandleMove(Tile currentTile, Tile targetTile)
    {
        if (currentTile == targetTile)
        {
            DeselectTile();
        }

        if (noMovingAfterTheFirstOne && currentTile.unit.hasMoved)
        {
            return;
        }

        Vector2Int mapPosition = targetTile.GetMapPosition();

        Tile reachableTile = pathfinding.GetMaxReachableTile(mapPosition.x, mapPosition.y, currentTile.unit.remainingMovementPoints);

        if (reachableTile == currentTile)
        {
            return;
        }

        Vector2Int reachablePosition = reachableTile.GetMapPosition();
        int        reachableDistance = pathfinding.GetDistanceToNode(reachablePosition.x, reachablePosition.y);

        StartCoroutine(ExecuteMoveAction(reachableTile, currentTile, reachableDistance));

        targetTile.SetIsSelected(false);
        DeselectTile();

        if (oneActionOnly)
        {
            SwitchPlayer();
        }
    }