コード例 #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]);
    }
コード例 #2
0
    public GridCoordinates GetFront(BlockGrid grid)
    {
        GridCoordinates coords = new GridCoordinates(x, y + 1);

        return(coords.OutOfBounds(grid) ? null : coords);
    }
コード例 #3
0
    public GridCoordinates GetRearRight(BlockGrid grid)
    {
        GridCoordinates coords = new GridCoordinates(x + 1, y - 1);

        return(coords.OutOfBounds(grid) ? null : coords);
    }
コード例 #4
0
    public GridCoordinates GetLeft(BlockGrid grid)
    {
        GridCoordinates coords = new GridCoordinates(x - 1, y);

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