예제 #1
0
    public void DropPiece()
    {
        if (selectedPiece == null)
        {
            //StateManager.Instance.state = StateManager.State.matching;
            return;
        }

        selectedPiece = null;
        selectBox.anchoredPosition = new Vector2(-432, 0);
        verticalSelectLine.gameObject.SetActive(false);
        horizontalSelectLine.gameObject.SetActive(false);
        cDir = 0;

        if (moving == null || moveAmount == 0)
        {
            //StateManager.Instance.state = StateManager.State.matching;
            return;
        }


        if (moveAmount > 0)
        {
            int j = 8 - moveAmount;
            for (int i = 8; i > 3; i--)
            {
                moving[i].value = moving[j].value;
                moving[i].RestSprite(game.pieces[moving[i].value - 1]);
                j--;
            }
        }
        else if (moveAmount < 0)
        {
            int j = 4 - moveAmount;
            for (int i = 4; i < 9; i++)
            {
                moving[i].value = moving[j].value;
                moving[i].RestSprite(game.pieces[moving[i].value - 1]);
                j++;
            }
        }


        foreach (NodePiece piece in moving)
        {
            piece.MovePositionBack();
        }
        cDir = 0;
        game.UpdateNodeData();
        game.CopyBoard();
        moving = null;
    }