// Update is called once per frame
    void Update()
    {
        if (!move_done)
        {
            if (selected && !Input.GetMouseButton(0))
            {
                released_after_selected = true;
            }

            if (selected && released_after_selected)
            {
                movementScript.selectMove(this);
            }
            if (Input.GetMouseButton(0) && gridManager.tilemapGridToMatrixPos(gridManager.mousePositionToTileMapPosition(Input.mousePosition)) == posOnMatrix)
            {
                if (movementScript.last_object != null && movementScript.last_object != this)
                {
                    movementScript.last_object.selected = false;
                    movementScript.last_object.released_after_selected = false;
                    gridManager.clearPaths();
                }
                selected = true;
            }
        }
    }
    void selectMove()
    {
        if (Input.GetMouseButton(0) && !select_started && gridManager.matrixPosToWorld(playerPos) == gridManager.mousePositionToTileMapPosition(Input.mousePosition))
        {
            mousePressed = true;
            Vector3Int next = gridManager.mousePositionToTileMapPosition(Input.mousePosition);
            last_position = gridManager.tilemapGridToMatrixPos(next);
            gridManager.board_tilemap.SetTile(next, gridManager.red_tile);
            select_started = true;
        }

        if (Input.GetMouseButton(0) && select_started && spaces_selected < player_moves)
        {
            Vector3Int next      = gridManager.mousePositionToTileMapPosition(Input.mousePosition);
            Vector3Int nextCoord = gridManager.tilemapGridToMatrixPos(next);
            if (gridManager.are_adjacent(last_position, nextCoord))
            {
                gridManager.board_tilemap.SetTile(next, gridManager.red_tile);
                move_queue.Enqueue(nextCoord);
                last_position = nextCoord;
                spaces_selected++;
            }
            else if (last_position != nextCoord)
            {
                select_started  = false;
                mousePressed    = false;
                spaces_selected = 0;
                gridManager.clearPaths();
                move_queue.Clear();
            }
        }

        if (mousePressed && !Input.GetMouseButton(0))
        {
            turnDone        = true;
            mousePressed    = false;
            select_started  = false;
            spaces_selected = 0;
            turnManager.nextTurn();
        }
    }
    void makeMove()
    {
        if (move_queue.Count > 0 && !moving)
        {
            Vector3Int next_move = move_queue.Dequeue();
            StartCoroutine(smoothMovement(last_object.posOnMatrix, next_move));
            last_object.posOnMatrix = next_move;
        }
        else if (move_queue.Count == 0 && turnDone)
        {
            gridManager.clearPaths();
            last_object.selected = false;
            turnDone             = false;

            //turnManager.nextTurn();
        }
    }