예제 #1
0
    public Block GetBlock(GridCoordinates coordinates)
    {
        if (coordinates == null)
        {
            return(null);
        }

        if (coordinates.OutOfBounds(this))
        {
            Debug.LogError("Tried to get block that is out of grid bounds:\n Width: " + Width + "\t Length: " + Length + "\n\t coords: " + coordinates.ToString());
            return(null);
        }

        return(array[coordinates.x, coordinates.y]);
    }
    public GridCoordinates GetFront(BlockGrid grid)
    {
        GridCoordinates coords = new GridCoordinates(x, y + 1);

        return(coords.OutOfBounds(grid) ? null : coords);
    }
    public GridCoordinates GetRearRight(BlockGrid grid)
    {
        GridCoordinates coords = new GridCoordinates(x + 1, y - 1);

        return(coords.OutOfBounds(grid) ? null : coords);
    }
    public GridCoordinates GetLeft(BlockGrid grid)
    {
        GridCoordinates coords = new GridCoordinates(x - 1, y);

        return(coords.OutOfBounds(grid) ? null : coords);
    }