예제 #1
0
    private void updatePosition(DirectionType direction)
    {
        Vector2 curPos;

        // Get block's current position
        curPos = transform.position;

        //Clear the current position on the grid
        gridBehavior.CellClear((int)curPos.x, (int)curPos.y);

        //Increment position based on the DirectionType
        if (direction == DirectionType.RIGHT)
        {
            curPos.x += 1;
        }
        else if (direction == DirectionType.LEFT)
        {
            curPos.x -= 1;
        }
        else
        {
            curPos.y -= 1;
        }

        //Update the position of the block by moving it the size of the block
        transform.position = curPos;

        //Let the grid know of the new position
        gridBehavior.CellSet((int)curPos.x, (int)curPos.y);
    }