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()
Exemplo n.º 2
0
 def startAmbientSounds(self):
     for s in self.ambient_sounds:
         kind = s[0]
         key = s[1][0]
         vol = s[1][1]
         loop = s[1][2]
         fadein = s[1][3]
         GlobalServices.getAudioDevice().play(kind, key, vol, loop, fadein)
Exemplo n.º 3
0
 def switchToMainMenu(self):
     # Pause all things
     GlobalServices.getAudioDevice().stopAll()
     # Close and delete the temporary shelf
     reset_savegame()
     # Delete the Map cache as well
     MapFactory.clearMaps()
     # Change state
     self.state = STATE_MAIN_MENU
     self.evManager.post(GameStateChangedEvent(self.state))
 def newgame(self, name):
     # Delete the current shelf (if any)
     self.gh.deleteSavegame(name)
     # Create a shelf file handle using the given name
     set_shelf(name)
     # Initialize an empty dictionary for the saved map properties
     shelf = get_savegame()
     shelf['saved_maps'] = {}
     # Fadeout music
     GlobalServices.getAudioDevice().stop(AudioDevice.MUSIC, FADEOUT_TIME)
     # Set the player's start position
     self.gh.player.setPosition((240, 208))
     # Initialize the map loading of the first map
     self.gh.initMapLoading("bedroom")
 def handle(self, event):
     # FullscreenToggleRequestEvent
     if isinstance(event, FullscreenToggleRequestEvent):
         # Order the Game menu to check if that's possible
         self.gh.fullscreenToggleRequest()
     # InventoryToggleEvent: Order the closing of the inventory dialog
     elif isinstance(event, InventoryToggleEvent):
         GlobalServices.getAudioDevice().play(SOUND, "journal_close", VOLUME_SOUND)
         # Change game state
         self.gh.state = STATE_GAME_RUNNING
         self.gh.evManager.post(GameStateChangedEvent(self.gh.state))
     # MouseMotionEvent: Check with the inventory if the mouse has highlighted an item
     elif isinstance(event, MouseMotionEvent):
         item = self.gh.player.inventory.checkForItemHighlight(event.object)
         self.gh.evManager.post(InventoryItemHighlightedEvent(item))
def tpatrium(storage, m, obj):
    storage._go()
    ad = GlobalServices.getAudioDevice()
    
    tr = GlobalServices.getTextRenderer()
    retval = False
    
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        # Key
        if storage._getData('atrium_open'):
            retval = True
        else:
            inventory = m.getPlayer().inventory
            if inventory.containsName(INVENTORY_ITEM_ATRIUM_KEY):
                storage._toggleCutscene(True)
                
                ad.play(SOUND, "pick_key", VOLUME_SOUND)
                tr.write("I can use the atrium key here.", 3)
                storage._wait(3000)
                
                key = inventory.get(INVENTORY_ITEM_ATRIUM_KEY)
                key.subQty(1)
                storage._setData('atrium_open', True)
                
                storage._toggleCutscene(False)
                retval = True
                
            else:
                ad.play(SOUND, "lockeddoor", VOLUME_SOUND)
                tr.write("The door to the atrium... it's locked? That's weird, it shouldn't be.", 3)
            
    storage._halt()
    return retval
def checkEnding(storage, m):
    storage._go()
    ad = GlobalServices.getAudioDevice()
    ad.stop(SOUND, 0, 'insanity_ear_ring')
    ad.play(SOUND, 'insanity_ear_ring', (0.02*_lastitem[1]), -1, 0)
    # Check if the ending has been reached
    if  storage._getData('attic_photoseen')\
    and storage._getData('attic_handseen')\
    and storage._getData('attic_noteseen')\
    and storage._getData('attic_gunseen')\
    and storage._getData('attic_pencilseen'):
        storage._halt()
        ending(storage, m)
    else:
        # Add a random scare if necessary
        if _lastitem[1] % 2 == 0:
            white = OverlayFactory.create("noise.png", pygame.BLEND_MULT)
            storage._wait(1000)
            shadow = m.getShadow()
            shadow.setPosition(conv_tile_pixel((random.randrange(3,12),\
                                                random.randrange(7,11)),m))
            m.addOverlay(white)
            shadow.setVisible(True)
            ad.play(SOUND, 'noise', VOLUME_SOUND + 0.1, -1)
            storage._wait(300)
            m.removeOverlay(white)
            ad.stop(SOUND, 0, 'noise')
            shadow.setVisible(False)
        storage._halt()
def switch(storage, obj, m):
    storage._go()
    
    tr = GlobalServices.getTextRenderer()
    ad = GlobalServices.getAudioDevice()
    
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        if storage._getData('guestroom_switch_pressed'):
            tr.write("I pulled the lever. It won't budge now.", 3)
        else:
            storage._toggleCutscene(True)
            tr.write("It's... a lever?", 3)
            storage._wait(3000)
            if storage._getData('guestroom_foundshelf'):
                tr.write("Does this do something with the hinges on that bookshelf?", 3)
                storage._wait(3000)
            ad.play(SOUND, 'pull_switch', VOLUME_SOUND)
            # Change graphics
            downswitch = os.path.join(PATH_GRAPHICS_TILES,'switch_down.png')
            obj.changeImage(downswitch)
            shelfchange = os.path.join(PATH_GRAPHICS_TILES,'shelf_atriumkey_inside.png')
            shelf_object = m.getObjectByName('keyshelf')
            shelf_object.changeImage(shelfchange, True)
            ad.play(SOUND, 'shelf', VOLUME_SOUND)
            
            storage._setData('guestroom_switch_pressed', True)
            storage._toggleCutscene(False)
    else:
        tr.write("I can't reach that from here.", 3) 
    storage._halt()
Exemplo n.º 9
0
 def save(self, disp=False):                
     # Get the savegame data
     temp = get_savegame()
     # Open the "real" shelf (the one the player can load up again)!
     save = shelve.open(CURRENT_SHELF_FILENAME[0])
     
     # Save persistent data that needs to be stored in order to retrieve the game state.
     # All data that is used to do that is actually the player's current position,
     # the current map where this position applies, and the currently playing background
     # music.
     # Pre-defined keys for the dict
     save['player_position'] = self.player.position
     save['current_map'] = self.currentmap.properties['key_name']
     save['player_inventory'] = self.player.inventory
     save['current_sounds'] = GlobalServices.getAudioDevice().getPlayingSounds()
     
     temp['global_overlays'] = get_global_overlays()
     
     # Update the persistent map properties for the current map
     update_persistent_map_properties(self.currentmap, temp)
     # Copy the rest of the shelf data to the "correct" save file
     copy_to_shelve(temp, save)
     
     # Close the shelves again; that's it!
     save.close()
     
     if disp:
         # Display the optional success message using the TextRenderer module
         tr = GlobalServices.getTextRenderer()
         tr.write("Game saved.", 3)
 def __init__(self):
     # Initialize via superclass constructor
     ViewInterface.__init__(self)
     # Write out the logo and menu items using the TextRenderer module
     self.writeTexts()
     # Menu item highlighted by the user, or "None"
     self.mouseover = None
     # BG image
     self.bg = pygame.transform.smoothscale(
         pygame.image.load(os.path.join(PATH_GRAPHICS_SPRITES, "main_menu_bg.png")), (SCREEN_WIDTH, SCREEN_HEIGHT)
     ).convert()
     # Title image
     self.title = pygame.image.load(os.path.join(PATH_GRAPHICS_SPRITES, "title.png"))
     # Load menu stuff. First, Boolean if it is open
     self.loadmenu_open = False
     tr = GlobalServices.getTextRenderer()
     self.loadmenu_caption = tr.writeAsSurface("Where do you want to pick up?", COLOR_TEXT, FONTSTYLE_CAPTION)
     back = tr.writeAsSurface("Back", COLOR_TEXT, FONTSTYLE_CAPTION)
     self.menu_backbutton = (back, pygame.Rect((500, 20), back.get_rect().size))
     # The list of save game folders to choose from
     self.loadmenu_saves = []
     # New game menu stuff. Boolean if it is open
     self.newgame_open = False
     self.newgame_caption = tr.writeAsSurface(
         "Enter a save game name. Proceed with Enter...", COLOR_TEXT, FONTSTYLE_CAPTION
     )
     # List of characters that make up the save game name
     self.newgame_name = []
     self.newgame_surf = tr.writeAsSurface("_")
     # Play BGM
     self.ad = GlobalServices.getAudioDevice()
     self.ad.play(MUSIC, "maincredit", VOLUME_MUSIC + 0.2, -1)
def note(storage, obj, m):
    storage._go()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        # Cutscene toggle: Disable user input
        storage._toggleCutscene(True)
        tr = GlobalServices.getTextRenderer()
        ad = GlobalServices.getAudioDevice()
        
        tr.deleteAll()
        
        # Overlays
        note = OverlayFactory.create("note_big.png")
        togray = OverlayFactory.create_animated_color((0,0,0), 1000, 0, True, 0, 200)
        m.addOverlay(note)
        m.addOverlay(togray)
        
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)
        
        # Text of the note
        y = 140
        ofs = 18
        tr.write("Who would have done something like this?!",\
                 0, COLOR_TEXT, (100, y + (ofs*0)))
        tr.write("My little girl... you shouldn't have had to suffer through this.",\
                 0, COLOR_TEXT, (100, y + (ofs*1)))
        tr.write("After I found your lifeless body, I took it to your most favourite place.",\
                 0, COLOR_TEXT, (100, y + (ofs*2)))
        tr.write("Surely you will find peace among there.",\
                 0, COLOR_TEXT, (100, y + (ofs*3)))
        tr.write("I looked at your picture today.",\
                 0, COLOR_TEXT, (100, y + (ofs*5)))
        tr.write("I do not know if it is just me, but your mother's expression changed.",\
                 0, COLOR_TEXT, (100, y + (ofs*6)))
        tr.write("There she sits, to your right, and what appears to be a sole tear runs down her cheek.",\
                 0, COLOR_TEXT, (100, y + (ofs*7)))
        tr.write("Can a painting feel emotions?",\
                 0, COLOR_TEXT, (100, y + (ofs*9)))
        tr.write("Now I am surely being silly.",\
                 0, COLOR_TEXT, (100, y + (ofs*10)))
        tr.write("I will miss you, big sister.",\
                 0, COLOR_TEXT, (100, y + (ofs*11)))
        tr.write("- J",\
                 0, COLOR_TEXT, (100, y + (ofs*13)))
        
        # Wait for user input
        storage._pauseUntilClick()
        
        GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
        
        # Delete note overlay
        m.removeOverlay(note)
        m.removeOverlay(togray)
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)        
        # Delete texts
        tr.deleteAll()
        
        storage._toggleCutscene(False)
    storage._halt()
Exemplo n.º 12
0
def tpmasterroom(storage, m, obj):
    storage._go()
    retval = True
    
    if not storage._getData('atrium_masterroom_firstentered'):
        storage._toggleCutscene(True)
        tr = GlobalServices.getTextRenderer()
        tr.write("The lever in the library has moved the shelf out of the way.", 3)
        storage._wait(3000)
        tr.write("This means that I can enter the master office.", 3)
        storage._wait(3000)
        tr.write("I'm barely awake right now. What does all of this mean?", 3)
        storage._wait(3000)
        m.getPlayer().setDirection([0,1])
        m.getOverlay("_flashlight").point("down")
        tr.deleteAll()
        storage._wait(2000)
        m.getPlayer().setDirection([0,-1])
        m.getOverlay("_flashlight").point("up")
        tr.write("...", 3)
        storage._wait(3000)
        storage._toggleCutscene(False)
        ad = GlobalServices.getAudioDevice()
        ad.stop(MUSIC, 5000)
        storage._setData('atrium_masterroom_firstentered', True)
    storage._halt()
    return retval
Exemplo n.º 13
0
def tplibrary(storage, m, obj):
    storage._go()
    
    retval = False
    tr = GlobalServices.getTextRenderer()
    ad = GlobalServices.getAudioDevice()
    
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        if storage._getData('library_open'):
            retval = True
        else:
            inventory = m.getPlayer().inventory
            if inventory.containsName(INVENTORY_ITEM_LIBRARY_KEY):
                storage._toggleCutscene(True)
                ad.play(SOUND, "pick_key", VOLUME_SOUND)
                tr.write("The library key fits into the lock.", 3)
                storage._wait(3000)
                
                key = inventory.get(INVENTORY_ITEM_LIBRARY_KEY)
                key.subQty(1)
                storage._setData('library_open', True)
                
                storage._toggleCutscene(False)
                retval = True
            else:
                ad.play(SOUND, "lockeddoor", VOLUME_SOUND)
                tr.write("The door is locked. 'Library' is spelt on the door frame.", 3)
    
    storage._halt()
    return retval
def tpstorage(storage, m, obj):
    storage._go()
    
    tr = GlobalServices.getTextRenderer()
    ad = GlobalServices.getAudioDevice()
    inv = m.getPlayer().inventory
    
    retval = False
    
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        if storage._getData('storage_open'):
            retval = True
        elif inv.containsName(INVENTORY_ITEM_STORAGE_KEY):
            storage._toggleCutscene(True)
            
            ad.play(SOUND, "keypickup", VOLUME_SOUND)
            tr.write("I can use the storage key here.", 3)
            storage._wait(3000)
            
            key = inv.get(INVENTORY_ITEM_STORAGE_KEY)
            key.subQty(1)
            storage._setData('storage_open', True)
            
            storage._toggleCutscene(False)
            retval = True
        else:
            ad.play(SOUND, "lockeddoor", VOLUME_SOUND)
            tr.write("The storage has been locked for as long as I can remember. I have never been in there.", 4)
            retval = False
    
    storage._halt()
    return retval
def dronesound(storage, obj, m):
    storage._go()
    if storage._getData('rightwing_powershortage'):
        remove_from_map(storage.s, SCRIPT, m.properties['key_name'], 'dronesound')
        ad = GlobalServices.getAudioDevice()
        
        ad.play(SOUND, 'drone', VOLUME_SOUND_AMBIENT, 0, 1500)
        black = OverlayFactory.create_by_color((0,0,0), 0, 255)
        
        storage._wait(3000)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark3', VOLUME_SOUND)
        storage._wait(50)
        m.removeOverlay(black)
        ad.play(SOUND, '27_spark1', VOLUME_SOUND)
        storage._wait(100)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark4', VOLUME_SOUND)
        storage._wait(50)
        m.removeOverlay(black)
        ad.play(SOUND, '27_spark2', VOLUME_SOUND)
        storage._wait(1750)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark1', VOLUME_SOUND)
        storage._wait(100)
        m.removeOverlay(black)
        ad.play(SOUND, '27_spark3', VOLUME_SOUND)
    storage._halt()
Exemplo n.º 16
0
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 relaxlever(storage, obj, m):
    storage._go()
    if not storage._getData('library_relaxlever_pressed')\
    and storage._playerInDistance(m.getPlayer().position, obj.rect):
        ad = GlobalServices.getAudioDevice()
        ad.play(SOUND, 'pull_switch', VOLUME_SOUND)
        # Change graphics
        downswitch = os.path.join(PATH_GRAPHICS_TILES,'switch_down.png')
        obj.changeImage(downswitch)
        shelf = m.getObjectByName('shelf')
        ad.play(SOUND, 'shelf', VOLUME_SOUND)
        # Re-position the shelf
        m.removeObject(shelf, True)
        
        add_to_map(get_savegame(), OBJECT, 'libraryupstairs', 'shelf',\
                   pygame.Rect(conv_tile_pixel((47,10), m), conv_tile_pixel((4,6), m)),\
                   'libraryupstairs_shelf', 'bigshelf_four.png', True)
        
        # Add the next lever (that was behind the moved shelf)
        add_to_map(get_savegame(), OBJECT, 'libraryupstairs', 'officelever',\
                   pygame.Rect(conv_tile_pixel((45,11), m), conv_tile_pixel((1,2), m)),\
                   'libraryupstairs_officelever', 'switch_up.png', True)
        
        storage._accessData()
        storage._setData('library_relaxlever_pressed', True)
    storage._halt()
Exemplo n.º 18
0
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()
Exemplo n.º 19
0
 def checkForObjectHighlight(self, mouseevent):
     if self.renderer is not None:
         # Translate into world coordinates
         mpos = mouseevent.pos
         wcoords = self.renderer.get_world_pos(self._cLayer, mpos[0], mpos[1])
         # Check for collision with Clickable objects
         for obj in self.objects:
             if obj.rect.collidepoint(wcoords):
                 # If the found object is not already the highlighted one,
                 # play a "hover" sound effect and return the object.
                 # (This way, the sound only plays once instead of infinitely)
                 if obj is not self.highlighted_object:
                     GlobalServices.getAudioDevice().play(SOUND, "object_hover", VOLUME_SOUND)
                     self.highlighted_object = obj
                 return obj
     self.highlighted_object = None
     return None
Exemplo n.º 20
0
def sfx(storage, obj, m):
    storage._go()
    ad = GlobalServices.getAudioDevice()
    ad.play(SOUND, 'general_thunder2', VOLUME_SOUND)
    storage._wait(2400)
    ad.play(SOUND, 'general_thunder7', VOLUME_SOUND)
    m.removeObject(obj)
    storage._halt()
def officelever(storage, obj, m):
    storage._go()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        if not storage._getData('library_officelever_pressed'):
            storage._toggleCutscene(True)
            ad = GlobalServices.getAudioDevice()
            ad.play(SOUND, 'pull_switch', VOLUME_SOUND)
            
            # Change graphics for this lever
            downswitch = os.path.join(PATH_GRAPHICS_TILES,'switch_down.png')
            obj.changeImage(downswitch)
            
            # Grab the shelf in atrium.tmx and delete it
            remove_object_from_map_properties(get_savegame(), 'atrium',\
                                              OBJECT, 'mastershelf', True)
            
            # Add the TeleportClickable to that map
            from src.model.Clickable import TeleportClickable, Clickable
            tele = TeleportClickable('tpmasterroom',\
                                     pygame.Rect(conv_tile_pixel((24, 4), m),\
                                            conv_tile_pixel( (2, 3), m)),\
                                     None, 'atrium_tpmasterroom', 'doormove6',\
                                     'masterroom', 32*16, 35*16)
            add_object_to_map_properties(get_savegame(), 'atrium',\
                                         TELEPORTOBJECT, tele)
            
            # Add vandalized painting image
            painting = get_object_from_map_properties(get_savegame(), 'librarydownstairs','painting')
            vandalized = os.path.join(PATH_GRAPHICS_TILES, 'vandalizedpainting.png')
            painting.changeImage(vandalized)
            update_object_in_map_properties(get_savegame(), 'librarydownstairs', painting)
            
            # Add new wall texts on this map and librarydownstairs.tmx
            add_to_map(get_savegame(), OBJECT, 'libraryupstairs', 'message',\
               pygame.Rect(conv_tile_pixel((43,36), m), conv_tile_pixel((14,5), m)),\
               'libraryupstairs_message', 'message_3.png', True)
            
            # Add the scare script
            add_to_map(get_savegame(), SCRIPT, 'libraryupstairs', 'scare',\
                   pygame.Rect(conv_tile_pixel((38,14), m), conv_tile_pixel((1,6), m)),\
                   'libraryupstairs_scare')
            
            message4path = os.path.join(PATH_GRAPHICS_TILES, 'message_4.png')
            message4 = pygame.image.load(message4path).convert_alpha()
            othermsg = Clickable('message', pygame.Rect(conv_tile_pixel((22,18), m),\
                                 conv_tile_pixel((6,6), m)),\
                                 'librarydownstairs_message', None,
                                 message4, message4path)
            add_object_to_map_properties(get_savegame(), 'librarydownstairs',\
                                         OBJECT, othermsg)                                 
            
            # Toggle this event as "happened"
            storage._setData('library_officelever_pressed', True)
            
            storage._toggleCutscene(False)
        
    storage._halt()
def switch(storage, obj, m, index):
    # (Extra "index" parameter depicts the # of the switch that was triggered
    # from 1 (far left) to 5 (far right))
    storage._go()
    if not storage._getData('lefthallway_puzzle_solved'):
        if storage._playerInDistance(m.getPlayer().position, obj.rect):
            ad = GlobalServices.getAudioDevice()
            # Initialize the persistent representation of this puzzle if it doesn't exist yet
            states = storage._getData('lefthallway_switches')
            if states is None:
                # -1: down, 0: middle, 1: up
                states = [0, 0, 0, 0, 0]
                
            # Change the state of the switch that was passed in
            # (subtract 1 from the index b/c computer scientists love to start at 0!)
            state = states[index-1]
            state += 1
            if state > 1:
                state = -1
            states[index-1] = state
            
            storage._setData('lefthallway_switches', states)
            
            # Change graphic for that switch
            if state == -1:
                image = 'switch_down.png'
            elif state == 0:
                image = 'switch_mid.png'
            else:
                image = 'switch_up.png'
            gfx = os.path.join(PATH_GRAPHICS_TILES, image)
            ad.play(SOUND, 'pull_switch', VOLUME_SOUND)
            obj.changeImage(gfx)
                
            # Solution to the switch puzzle (from left to right):
            # up down down up up
            # (The gender of the five people on the portrait
            # are mapped to the positioning of the switches.
            # The encoding of gender is hinted at in the abandoned chamber.)
            solution = [1, -1, -1, 1, 1]
            if states == solution:
                # Puzzle solved
                storage._toggleCutscene(True)
                ad.play(SOUND, 'doorstop3', VOLUME_SOUND)
                lastdir = m.getPlayer().getDirection()
                m.getPlayer().setDirection(string_to_direction("up-right"))
                storage._wait(250)
                ad.play(SOUND, '07_pick_lock', VOLUME_SOUND)
                storage._wait(500)
                tr = GlobalServices.getTextRenderer()
                tr.write("Something has happened. I think this is the correct combination.", 3)
                m.getPlayer().setDirection(string_to_direction(lastdir))
                storage._setData('lefthallway_puzzle_solved', True)
                storage._toggleCutscene(False)
    
    storage._halt()
def tpupperbalcony(storage, source, obj):
    storage._go()
    retval = False
    tr = GlobalServices.getTextRenderer()
    ad = GlobalServices.getAudioDevice()
    if storage._playerInDistance(source.getPlayer().position, obj.rect):
        ad.play(SOUND, "lockeddoor", VOLUME_SOUND)
        tr.write("The door won't budge.", 3)
    storage._halt()
    return retval
def officenote(storage, obj, m):
    storage._go()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        # Cutscene toggle: Disable user input
        storage._toggleCutscene(True)
        tr = GlobalServices.getTextRenderer()
        ad = GlobalServices.getAudioDevice()
        
        tr.deleteAll()
        
        # Overlays
        note = OverlayFactory.create("note_big.png")
        togray = OverlayFactory.create_animated_color((0,0,0), 1000, 0, True, 0, 200)
        m.addOverlay(note)
        m.addOverlay(togray)
        
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)
        
        # Text of the note
        y = 150
        ofs = 18
        tr.write("The doctor's said that everything is going to be fine.",\
                 0, COLOR_TEXT, (100, y + (ofs*0)))
        tr.write("I won't give my offspring away only because your senile self",\
                 0, COLOR_TEXT, (100, y + (ofs*1)))
        tr.write("blames everything on him! How dare you speak those insults!",\
                 0, COLOR_TEXT, (100, y + (ofs*2)))
        tr.write("Cly has NOTHING to do with any of the disappearances of our family.",\
                 0, COLOR_TEXT, (100, y + (ofs*3)))
        tr.write("I mean, God, why do you keep saying that?! Haven't you heard",\
                 0, COLOR_TEXT, (100, y + (ofs*4)))
        tr.write("the inspector's words? He's innocent!",\
                 0, COLOR_TEXT, (100, y + (ofs*5)))
        tr.write("I took your key to where you wrongfully locked my son, you monster.",\
                 0, COLOR_TEXT, (100, y + (ofs*7)))
        tr.write("This will be hard to forgive, father.",\
                 0, COLOR_TEXT, (100, y + (ofs*8)))
        tr.write("- M",\
                 0, COLOR_TEXT, (100, y + (ofs*10)))
        
        # Wait for user input
        storage._pauseUntilClick()
        
        GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
        
        # Delete note overlay
        m.removeOverlay(note)
        m.removeOverlay(togray)
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)        
        # Delete texts
        tr.deleteAll()
        storage._toggleCutscene(False)
    storage._halt()
def librarykey(storage, obj, m):
    storage._go()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        tr = GlobalServices.getTextRenderer()
        ad = GlobalServices.getAudioDevice()
        ad.play(SOUND, 'pick_key', VOLUME_SOUND)
        tr.write("Got 'Library Key'", 3, COLOR_GOT_ITEM)
        m.getPlayer().inventory.add(ItemFactory.create(INVENTORY_ITEM_LIBRARY_KEY, 1))
        remove_from_map(get_savegame(), OBJECT, 'mirrorhall', 'librarykey')
        storage._setData('librarykey_obtained', True)
    storage._halt()
def noise(storage, obj, m):
    storage._go()
    m.removeObject(obj)
    ad = GlobalServices.getAudioDevice()
    ad.play(SOUND, 'scare_whine_loop1', VOLUME_SOUND)
    storage._wait(1000)
    ad.play(SOUND, 'amb_guardian', VOLUME_SOUND_AMBIENT, -1, 3000)
    storage._wait(3000)
    ad.play(SOUND, 'scare_animal_squeal1', VOLUME_SOUND)
    storage._wait(4500)
    ad.play(SOUND, 'scare_tingeling_rev2', VOLUME_SOUND)
    storage._halt()
Exemplo n.º 27
0
def rollCredits(storage, m):
    storage._go()
    m.rendering_enabled = False
    m.clearOverlays()
    ad = GlobalServices.getAudioDevice()
    tr = GlobalServices.getTextRenderer()
    x = 125
    pos = SCREEN_HEIGHT/2
    ofs = 28
    ad.play(MUSIC, 'credits', VOLUME_MUSIC + 0.1)
    tl = OverlayFactory.create("title.png", 0)
    m.addOverlay(tl)
    storage._wait(5000)
    m.removeOverlay(tl)
    storage._wait(1000)
    tr.write("Created by Marcel Schnelle", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False)
    tr.write("at California State University, Fullerton", 0, COLOR_TEXT, (x, pos + ofs*1), FONTSTYLE_CAPTION, False)
    tr.write("for 'Introduction to Game Design & Production'", 0, COLOR_TEXT, (x, pos + ofs*2), FONTSTYLE_CAPTION, False)
    tr.write("(Fall 2012)", 0, COLOR_TEXT, (x, pos + ofs*3), FONTSTYLE_CAPTION, False)
    storage._wait(10000)
    tr.deleteAll()
    storage._wait(1000)
    tr.write("Story by Anna Martje Geudert", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False)
    storage._wait(5000)
    tr.deleteAll()
    storage._wait(1000)
    tr.write("Resources gathered from", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False)
    tr.write("Celianna", 0, COLOR_TEXT, (x, pos + ofs*1), FONTSTYLE_CAPTION, False)
    tr.write("Enterbrain", 0, COLOR_TEXT, (x, pos + ofs*2), FONTSTYLE_CAPTION, False)
    tr.write("Kaz", 0, COLOR_TEXT, (x, pos + ofs*3), FONTSTYLE_CAPTION, False)
    tr.write("Lunarea", 0, COLOR_TEXT, (x, pos + ofs*4), FONTSTYLE_CAPTION, False)
    tr.write("Mack", 0, COLOR_TEXT, (x, pos + ofs*5), FONTSTYLE_CAPTION, False)
    storage._wait(10000)
    tr.deleteAll()
    storage._wait(1000)
    tr.write("And the games", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False)
    tr.write("'Cry of Fear'", 0, COLOR_TEXT, (x, pos + ofs*1), FONTSTYLE_CAPTION, False)
    tr.write("'Amnesia: The Dark Descent'", 0, COLOR_TEXT, (x, pos + ofs*2), FONTSTYLE_CAPTION, False)
    storage._wait(7500)
    tr.deleteAll()
    storage._wait(1000)
    tr.write("Inspired by", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False)
    tr.write("Mark Fischbach", 0, COLOR_TEXT, (x, pos + ofs*1), FONTSTYLE_CAPTION, False)
    storage._wait(7500)
    tr.deleteAll()
    storage._wait(1000)
    tr.write("Thanks for playing!", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False)
    ad.stop(MUSIC, 7500)
    storage._wait(7500)
    tr.deleteAll()
    storage._wait(2000)
    storage._halt()
    GlobalServices.getEventManager().post(MainMenuSwitchRequestEvent())
Exemplo n.º 28
0
def hintnote(storage, obj, m):
    storage._go()
    
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        # Cutscene toggle: Disable user input
        storage._toggleCutscene(True)
        tr = GlobalServices.getTextRenderer()
        ad = GlobalServices.getAudioDevice()
        
        tr.deleteAll()
        
        # Overlays
        note = OverlayFactory.create("note_big.png")
        togray = OverlayFactory.create_animated_color((0,0,0), 1000, 0, True, 0, 200)
        m.addOverlay(note)
        m.addOverlay(togray)
        
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)
        
        # Text of the note
        y = 200
        ofs = 18
        tr.write("Claire:",\
                 0, COLOR_TEXT, (100, y + (ofs*0)))
        tr.write("You know that I had to seal the master's bedroom for a reason, right?",\
                 0, COLOR_TEXT, (100, y + (ofs*2)))
        tr.write("It is not at all because of personal disapproval or anything like that.",\
                 0, COLOR_TEXT, (100, y + (ofs*3)))
        tr.write("Please understand that it is for our own good, and safety.",\
                 0, COLOR_TEXT, (100, y + (ofs*4)))
        tr.write("Please do not try to unlock it. Trust me on this one.",\
                 0, COLOR_TEXT, (100, y + (ofs*5)))
        tr.write("- J",\
                 0, COLOR_TEXT, (100, y + (ofs*7)))
        
        # Wait for user input
        storage._pauseUntilClick()
        
        GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
        
        # Delete note overlay
        m.removeOverlay(note)
        m.removeOverlay(togray)
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)        
        # Delete texts
        tr.deleteAll()
        
        storage._toggleCutscene(False)
        
    storage._halt()
Exemplo n.º 29
0
 def handle(self, event):
     # Handle tick and quit events first
     super(GameViewHandler, self).handle(event)
     # Map changed event: Order the current view to change the rendered map
     if isinstance(event, MapChangedEvent):
         self.v.currentView.setCurrentMap(event.object)
     # Object highlighted event: Notify the view to render the appropriate rectangle for the highlighted object
     elif isinstance(event, ObjectHighlightedEvent):
         self.v.currentView.setHighlightedObject(event.object)
     # Mouse click event. Check if the user has clicked on a region of interest
     elif isinstance(event, MouseClickEvent):
         # Get the clicked-on object
         clickedobj = self.v.currentView.getHighlightedObject()
         # If it is not none, post an object interaction event, so that the
         # ObjectEngine may execute the object's behaviour
         if clickedobj is not None:
             GlobalServices.getAudioDevice().play(SOUND, "object_click", VOLUME_SOUND)
             self.v.evManager.post(ObjectInteractionEvent(clickedobj))
     # Save event. Order the current view (GameView) to capture a screenshot and save
     # it in the current save game's folder
     elif isinstance(event, SaveEvent):
         self.v.currentView.saveScreenshot()
def relaxnote(storage, obj, m):
    storage._go()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        # Cutscene toggle: Disable user input
        storage._toggleCutscene(True)
        tr = GlobalServices.getTextRenderer()
        ad = GlobalServices.getAudioDevice()
        
        tr.deleteAll()
        
        # Overlays
        note = OverlayFactory.create("note_big.png")
        togray = OverlayFactory.create_animated_color((0,0,0), 1000, 0, True, 0, 200)
        m.addOverlay(note)
        m.addOverlay(togray)
        
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)
        
        # Text of the note
        y = 150
        ofs = 18
        tr.write("This boy is getting out of hand!",\
                 0, COLOR_TEXT, (100, y + (ofs*0)))
        tr.write("He seems to be less and less certifiably sane, to put it in fancy terms.",\
                 0, COLOR_TEXT, (100, y + (ofs*2)))
        tr.write("I have locked him in his room after what he did to aunt Sophie.",\
                 0, COLOR_TEXT, (100, y + (ofs*3)))
        tr.write("This has nothing to do with bad manners anymore, Marnie!",\
                 0, COLOR_TEXT, (100, y + (ofs*4)))
        tr.write("The child is vile and struck by evil, I tell you. Why won't you listen to me, Marnie?",\
                 0, COLOR_TEXT, (100, y + (ofs*5)))
        tr.write("This, this is not your child anymore. Please be reasonable and get help.",\
                 0, COLOR_TEXT, (100, y + (ofs*6)))
        tr.write("- Harold",\
                 0, COLOR_TEXT, (100, y + (ofs*8)))
        
        # Wait for user input
        storage._pauseUntilClick()
        
        GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
        
        # Delete note overlay
        m.removeOverlay(note)
        m.removeOverlay(togray)
        # Play sound
        ad.play(SOUND, 'journal_page', VOLUME_SOUND)        
        # Delete texts
        tr.deleteAll()
        storage._toggleCutscene(False)
    storage._halt()