Пример #1
0
    // Called when drop operation is done on the grid
    public Vector2Int PutPlaceableToTheGrid(Placeable placeable)
    {
        Vector2Int correspondingGridIndex = GetCorrespondingRoundedGridIndex(placeable.transform.position);

        placeable.transform.position = GetGridPosition(correspondingGridIndex);

        Vector2Int placeableSize = placeable.GetSize();

        int endXIndex = correspondingGridIndex.x + placeableSize.x;
        int endYIndex = correspondingGridIndex.y + placeableSize.y;

        for (int y = correspondingGridIndex.y; y < endYIndex; y++)
        {
            for (int x = correspondingGridIndex.x; x < endXIndex; x++)
            {
                grid[x, y].isObstructed = true;
            }
        }
        return(correspondingGridIndex);
    }