Esempio n. 1
0
def canPlaceCouch(span, warnAreas):
    # Check the coordinates
    if span[0].x == span[1].x:
        if span[0].x == 500:
            span[0].x = span[1].x = 0
        else:
            span[0].x = span[1].x = 500

        for i in range(span[0].y, span[1].y + 1):
            if warnArea.getWarnLevel(Vector2(span[0].x, i), warnAreas):
                return False
    else:
        if span[0].y == 500:
            span[0].y = span[1].y = 0
        else:
            span[0].y = span[1].y = 500

        for i in range(span[0].x, span[1].x + 1):
            if warnArea.getWarnLevel(Vector2(i, span[0].y), warnAreas):
                return False

    return True
Esempio n. 2
0
def getFreeSpaceInPosArray(array, maxLevel, warnAreas):
    freeSpaces = []

    areaStart = None
    lastPos = None
    for pos in array:
        if warnArea.getWarnLevel(pos, warnAreas) < maxLevel:
            if areaStart == None:
                areaStart = pos
        else:
            if areaStart != None:
                freeSpaces.append([areaStart, lastPos])
                areaStart = None


        lastPos = pos

    #Add last segment
    if areaStart != None:
        freeSpaces.append([areaStart, array[-1]])

    return freeSpaces