Beispiel #1
0
def doDrops(drops):
    if len(drops) == 0:
        return (None, None)
    
    suitDropsDict = { }
    for drop in drops:
        suitId = drop['target']['suit'].doId
        if suitDropsDict.has_key(suitId):
            suitDropsDict[suitId].append(drop)
        else:
            suitDropsDict[suitId] = [
                drop]
    
    suitDrops = suitDropsDict.values()
    
    def compFunc(a, b):
        if len(a) > len(b):
            return 1
        elif len(a) < len(b):
            return -1
        
        return 0

    suitDrops.sort(compFunc)
    delay = 0.0
    tracks = []
    for st in suitDrops:
        if len(st) > 0:
            ival = __doSuitDrops(st)
            if ival:
                tracks.append(Track([
                    (delay, ival)]))
            
            delay = delay + TOON_DROP_SUIT_DELAY
        
    
    mtrack = MultiTrack(tracks, name = 'toplevel-drop')
    camDuration = mtrack.getDuration()
    camTrack = MovieCamera.chooseDropShot(drops, suitDropsDict, camDuration)
    return (mtrack, camTrack)
Beispiel #2
0
def doDrops(drops):
    if len(drops) == 0:
        return (None, None)
    suitDropsDict = {}
    for drop in drops:
        suitId = drop['target']['suit'].doId
        if suitDropsDict.has_key(suitId):
            suitDropsDict[suitId].append(drop)
        else:
            suitDropsDict[suitId] = [
             drop]

    suitDrops = suitDropsDict.values()

    def compFunc(a, b):
        if len(a) > len(b):
            return 1
        else:
            if len(a) < len(b):
                return -1
        return 0

    suitDrops.sort(compFunc)
    delay = 0.0
    tracks = []
    for st in suitDrops:
        if len(st) > 0:
            ival = __doSuitDrops(st)
            if ival:
                tracks.append(Track([(delay, ival)]))
            delay = delay + TOON_DROP_SUIT_DELAY

    mtrack = MultiTrack(tracks, name='toplevel-drop')
    camDuration = mtrack.getDuration()
    camTrack = MovieCamera.chooseDropShot(drops, suitDropsDict, camDuration)
    return (
     mtrack, camTrack)
    return
Beispiel #3
0
def doDrops(drops):
    """ Drops occur in the following order:
        a) by suit, in order of increasing number of drops per suit
          1) level 1 drops, right to left, (TOON_DROP_DELAY later)
          2) level 2 drops, right to left, (TOON_DROP_DELAY later)
          3) level 3 drops, right to left, (TOON_DROP_DELAY later)
          etc.
        b) next suit, (TOON_DROP_SUIT_DELAY later)
    """
    if (len(drops) == 0):
        return (None, None)

    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(drops)

    # Group the drops by targeted suit
    suitDropsDict = {}
    groupDrops = []
    for drop in drops:
        track = drop['track']
        level = drop['level']
        targets = drop['target']
        if (len(targets) == 1):
            suitId = targets[0]['suit'].doId
            if (suitDropsDict.has_key(suitId)):
                suitDropsDict[suitId].append((drop, targets[0]))
            else:
                suitDropsDict[suitId] = [(drop, targets[0])]
        elif level <= MAX_LEVEL_INDEX and attackAffectsGroup(track, level):
            groupDrops.append(drop)
        else:
            # We're dealing with an NPC drop, which can have multiple
            # targets
            for target in targets:
                suitId = target['suit'].doId
                if (suitDropsDict.has_key(suitId)):
                    otherDrops = suitDropsDict[suitId]
                    alreadyInList = 0
                    for oDrop in otherDrops:
                        if (oDrop[0]['toon'] == drop['toon']):
                            alreadyInList = 1
                    if (alreadyInList == 0):
                        suitDropsDict[suitId].append((drop, target))
                else:
                    suitDropsDict[suitId] = [(drop, target)]
    suitDrops = suitDropsDict.values()

    # Sort the suits based on the number of drops per suit
    def compFunc(a, b):
        if (len(a) > len(b)):
            return 1
        elif (len(a) < len(b)):
            return -1
        return 0

    suitDrops.sort(compFunc)
    delay = 0.0
    mtrack = Parallel(name='toplevel-drop')
    npcDrops = {}
    for st in suitDrops:
        if (len(st) > 0):
            ival = __doSuitDrops(st, npcs, npcDrops)
            if (ival):
                mtrack.append(Sequence(Wait(delay), ival))
            delay = delay + TOON_DROP_SUIT_DELAY

    dropTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()

    #we do the group drops after all the single drops have gone
    if groupDrops:
        ival = __doGroupDrops(groupDrops)
        dropTrack.append(ival)
        camDuration += ival.getDuration()

    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseDropShot(drops, suitDropsDict, camDuration,
                                          enterDuration, exitDuration)

    return (dropTrack, camTrack)
Beispiel #4
0
def doDrops(drops):
    if len(drops) == 0:
        return (None, None)
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(drops)
    suitDropsDict = {}
    groupDrops = []
    for drop in drops:
        track = drop['track']
        level = drop['level']
        targets = drop['target']
        if len(targets) == 1:
            suitId = targets[0]['suit'].doId
            if suitDropsDict.has_key(suitId):
                suitDropsDict[suitId].append((drop, targets[0]))
            else:
                suitDropsDict[suitId] = [(drop, targets[0])]
        elif level <= MAX_LEVEL_INDEX and attackAffectsGroup(track, level):
            groupDrops.append(drop)
        else:
            for target in targets:
                suitId = target['suit'].doId
                if suitDropsDict.has_key(suitId):
                    otherDrops = suitDropsDict[suitId]
                    alreadyInList = 0
                    for oDrop in otherDrops:
                        if oDrop[0]['toon'] == drop['toon']:
                            alreadyInList = 1

                    if alreadyInList == 0:
                        suitDropsDict[suitId].append((drop, target))
                else:
                    suitDropsDict[suitId] = [(drop, target)]

    suitDrops = suitDropsDict.values()

    def compFunc(a, b):
        if len(a) > len(b):
            return 1
        elif len(a) < len(b):
            return -1
        return 0

    suitDrops.sort(compFunc)
    delay = 0.0
    mtrack = Parallel(name='toplevel-drop')
    npcDrops = {}
    for st in suitDrops:
        if len(st) > 0:
            ival = __doSuitDrops(st, npcs, npcDrops)
            if ival:
                mtrack.append(Sequence(Wait(delay), ival))
            delay = delay + TOON_DROP_SUIT_DELAY

    dropTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()
    if groupDrops:
        ival = __doGroupDrops(groupDrops)
        dropTrack.append(ival)
        camDuration += ival.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseDropShot(drops, suitDropsDict, camDuration,
                                          enterDuration, exitDuration)
    return (dropTrack, camTrack)
def doDrops(drops):
    if len(drops) == 0:
        return (None, None)
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(drops)
    suitDropsDict = {}
    groupDrops = []
    for drop in drops:
        track = drop['track']
        level = drop['level']
        targets = drop['target']
        if len(targets) == 1:
            suitId = targets[0]['suit'].doId
            if suitId in suitDropsDict:
                suitDropsDict[suitId].append((drop, targets[0]))
            else:
                suitDropsDict[suitId] = [(drop, targets[0])]
        elif level <= MAX_LEVEL_INDEX and attackAffectsGroup(track, level):
            groupDrops.append(drop)
        else:
            for target in targets:
                suitId = target['suit'].doId
                if suitId in suitDropsDict:
                    otherDrops = suitDropsDict[suitId]
                    alreadyInList = 0
                    for oDrop in otherDrops:
                        if oDrop[0]['toon'] == drop['toon']:
                            alreadyInList = 1

                    if alreadyInList == 0:
                        suitDropsDict[suitId].append((drop, target))
                else:
                    suitDropsDict[suitId] = [(drop, target)]

    suitDrops = suitDropsDict.values()

    def compFunc(a, b):
        if len(a) > len(b):
            return 1
        elif len(a) < len(b):
            return -1
        return 0

    suitDrops.sort(compFunc)
    delay = 0.0
    mtrack = Parallel(name='toplevel-drop')
    npcDrops = {}
    for st in suitDrops:
        if len(st) > 0:
            ival = __doSuitDrops(st, npcs, npcDrops)
            if ival:
                mtrack.append(Sequence(Wait(delay), ival))
            delay = delay + TOON_DROP_SUIT_DELAY

    dropTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()
    if groupDrops:
        ival = __doGroupDrops(groupDrops)
        dropTrack.append(ival)
        camDuration += ival.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseDropShot(drops, suitDropsDict, camDuration, enterDuration, exitDuration)
    return (dropTrack, camTrack)