def teleport(self, source, obj, target, destination):
     self._go()
     
     if self._playerInDistance(source.getPlayer().position, obj.rect):
         # Play the sound of this TeleportClickable object
         # (if there is one; could be a door squeaking etc)
         if hasattr(obj, 'sound'):
             GlobalServices.getAudioDevice().play(SOUND, obj.sound, 0.8)
         
         self.teleport_in_progress = True
         set_property(PLAYER_MOVEMENT_ENABLED, False)
         
         # Save the state of the current map's properties to the persistent shelf
         # before teleporting to the new map
         update_persistent_map_properties(source, get_savegame())
         
         dur = 1000
         fadeout = OverlayFactory.create_animated_color((0,0,0), dur, 0, True, 0, 255)
         source.addOverlay(fadeout)
         self._wait(dur)
         source.rendering_enabled = False
         GlobalServices.getEventManager().post(MapChangeRequestEvent((target, destination)))
         
         source.removeOverlay(fadeout)
         source.flushOverlayQueue()
         set_property(PLAYER_MOVEMENT_ENABLED, True)
         self.teleport_in_progress = False
         
     self._halt()
def note(storage, obj, m):
    storage._go()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        _lastitem[0] = "note"
        _lastitem[1] += 1
        storage._toggleCutscene(True)
        ad = GlobalServices.getAudioDevice()
        # Overlays
        note = OverlayFactory.create("note_big.png")
        text = OverlayFactory.create("lastnote.png")
        m.addOverlay(note)
        m.addOverlay(text)
        
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)
        
        # Wait for user input
        storage._pauseUntilClick()
        
        # Delete note overlay
        m.removeOverlay(note)
        m.removeOverlay(text)
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND) 
        storage._toggleCutscene(False)
        set_property(SAVE_ENABLED, False)
        storage._setData('attic_noteseen', True)
    storage._halt()
    checkEnding(storage, m)
def init(storage, m):
    storage._go()
    storage._toggleCutscene(True)
    ad = GlobalServices.getAudioDevice()
    tr = GlobalServices.getTextRenderer()
    ad.stop(MUSIC, 5000)
    ad.stop(SOUND, 5000, 'amb_guardian')
    # Make the overlay
    darktrans = OverlayFactory.create_animated_color((20,0,0),\
                5000, 0, True, 0, 220)
    dark = OverlayFactory.create_by_color((20,0,0), 0, 220)
    fog = OverlayFactory.create("fog.png", pygame.BLEND_MULT)
    white = OverlayFactory.create("noise.png", pygame.BLEND_MULT)
    m.clearOverlays()
    m.addOverlay(darktrans)
    m.addOverlay(fog)
    
    player = m.getPlayer()
    shadow = m.getShadow()
    shadow.setPosition(conv_tile_pixel((8,10),m))
    
    player.setDirection([0,-1])
    player.halfSpeed()
    
    
    # Here be dragons
    storage._wait(5000)
    m.rendering_enabled = True
    m.addOverlay(dark)
    m.removeOverlay(darktrans)
    ad.play(MUSIC, 'bgm_4', VOLUME_MUSIC, -1)
    ad.play(SOUND, 'flashlight_toggle', VOLUME_SOUND)
    
    storage._wait(2000)
    tr.write("What is this place?", 3)
    storage._wait(3000)
    tr.write("It feels... strangely familiar.", 3)
    storage._wait(2000)
    ad.play(SOUND, 'noise', VOLUME_SOUND_AMBIENT + 0.3, -1)
    m.addOverlay(white)
    shadow.setVisible(True)
    storage._wait(300)
    m.removeOverlay(white)
    ad.stop(SOUND, 0, 'noise')
    shadow.setVisible(False)
    shadow.setPosition(conv_tile_pixel((8,12),m))
    storage._wait(1500)
    m.addOverlay(white)
    ad.play(SOUND, 'noise', VOLUME_SOUND_AMBIENT + 0.3, -1)
    shadow.setVisible(True)
    shadow.moveBy((0, 15), 500)
    storage._wait(450)
    m.removeOverlay(white)
    ad.stop(SOUND, 0, 'noise')
    shadow.setVisible(False)
    
    storage._toggleCutscene(False)
    set_property(SAVE_ENABLED, False)
    storage._halt()
 def _pauseUntilClick(self):
     # Set global property that enables the extra behaviour of InputController
     set_property(CURRENTLY_PAUSING_FOR_CLICK, True)
     self.waiting = True
     clicked = False
     while not clicked:
         if self.interrupted:
             raise Storage.Break()
         pygame.time.wait(self.timestep)
         # InputController re-sets this flag, so
         # this loop will notice when it changed
         if not get_property(CURRENTLY_PAUSING_FOR_CLICK):
             clicked = True
     self.waiting = False
def pencil(storage, obj, m):
    storage._go()
    tr = GlobalServices.getTextRenderer()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        _lastitem[0] = "pencil"
        _lastitem[1] += 1
        storage._toggleCutscene(True)
        if not storage._getData('attic_pencilseen'):
            tr.write("What appears to be a red marker lies on the table.", 3)
            storage._wait(3000)
        tr.write("The messages surely have been written using this marker.", 3)
        storage._toggleCutscene(False)
        set_property(SAVE_ENABLED, False)
        storage._setData('attic_pencilseen', True)
    storage._halt()
    checkEnding(storage, m)
def gun(storage, obj, m):
    storage._go()
    tr = GlobalServices.getTextRenderer()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        _lastitem[0] = "gun"
        _lastitem[1] += 1
        storage._toggleCutscene(True)
        if not storage._getData('attic_handseen'):
            tr.write("In the center of the table's surface, there is a handgun.", 3)
            storage._wait(3000)
            tr.write("It looks like it has been used several times.", 3)
        else:
            tr.write("The handgun looks like it has been used several times.", 3)
        storage._toggleCutscene(False)
        set_property(SAVE_ENABLED, False)
        storage._setData('attic_gunseen', True)
    storage._halt()
    checkEnding(storage, m)
def hand(storage, obj, m):
    storage._go()
    tr = GlobalServices.getTextRenderer()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        _lastitem[0] = "hand"
        _lastitem[1] += 1
        storage._toggleCutscene(True)
        if not storage._getData('attic_handseen'):
            tr.write("There is an imprint of a hand on the wall, drained in paint.", 3)
            storage._wait(3000)
            tr.deleteAll()
            storage._wait(1500)
        tr.write("...My right hand is a perfect match to the imprint.", 3)
        storage._toggleCutscene(False)
        set_property(SAVE_ENABLED, False)
        storage._setData('attic_handseen', True)
    storage._halt()
    checkEnding(storage, m)
 def teleport(self, source, target, destination):
     self._go()
     self.teleport_in_progress = True
     set_property(PLAYER_MOVEMENT_ENABLED, False)
     
     # Save the state of the current map's properties to the persistent shelf
     # before teleporting to the new map
     update_persistent_map_properties(source, get_savegame())
     
     dur = 1000
     fadeout = OverlayFactory.create_animated_color((0,0,0), dur, 0, True, 0, 255)
     source.addOverlay(fadeout)
     self._wait(dur)
     source.rendering_enabled = False
     GlobalServices.getEventManager().post(MapChangeRequestEvent((target, destination)))
     
     set_property(PLAYER_MOVEMENT_ENABLED, True)
     source.removeOverlay(fadeout)
     
     self.teleport_in_progress = False
     self._halt()
def photo(storage, obj, m):
    storage._go()
    tr = GlobalServices.getTextRenderer()
    if storage._playerInDistance(m.getPlayer().position, obj.rect, 100):
        _lastitem[0] = "photo"
        _lastitem[1] += 1
        storage._toggleCutscene(True)
        if not storage._getData('attic_photoseen'):
            tr.write("I know this photo. It was taken two years ago.", 3)
            storage._wait(3000)
            
        photo = OverlayFactory.create("photo.png", 0)
        m.addOverlay(photo, 0)
        
        tr.write("My family... everyone has been crossed out with the same red paint I've seen everywhere.", 4)
        
        storage._pauseUntilClick()
        
        m.removeOverlay(photo)
        storage._toggleCutscene(False)
        set_property(SAVE_ENABLED, False)
        storage._setData('attic_photoseen', True)
    storage._halt()
    checkEnding(storage, m)
 def _toggleCutscene(self, enabled):
     
     # Set the "CUTSCENE RUNNING" property to the given value.
     # Afterwards, invert the given value and therefore disable some things.
     set_property(CUTSCENE_RUNNING, enabled)
     
     # If this parameter is True, there is a cutscene
     # which DISABLES these properties. That's why
     # this next line makes sense
     enabled = not enabled
     
     set_property(PLAYER_MOVEMENT_ENABLED, enabled)
     set_property(MOUSE_HIGHLIGHT_ENABLED, enabled)
     set_property(INVENTORY_OPEN_ENABLED, enabled)
     set_property(GAME_MENU_OPEN_ENABLED, enabled)
     set_property(SAVE_ENABLED, enabled)
     set_property(FLASHLIGHT_MOVEMENT_ENABLED, enabled)
# CS 386