예제 #1
0
class Level(LevelBase):
    prevlevel = 0
    dialog = 0
    pdialog = 0
    timer = 0
    oldPos = (0, 0)
    dialog = 0
    btimer = 0
    lockedatmessage = 0
    inbattle = 0
    
    def __init__(self, g, player_new, dimentions, p = 0):
        LevelBase.__init__(self, g, player_new, dimentions)
        self.prevlevel = p
        self.title = 'Airport'
        # current level
        TW,TH = 32,32

        # load tile set
        g.tga_load_tiles(os.path.join("textures",  "tiles6.png"), (TW,TH), self.tdata)
        g.tga_load_level(os.path.join("levels",  "level28.tga"), 1)
        g.bounds = pygame.Rect(TW,TH,(len(g.tlayer[0])-2)*TW,(len(g.tlayer)-2)*TH)
        g.code_events(self.edata)

        self.vats = Inventory(g, 'plane')
        self.vats.pos((18, 9))

        g.run_codes(self.cdata,(0,0,g.dimentions[0],g.dimentions[1]))
        self.g.player.hidden = 0
        self.pan_camera(None)
        self.initBack('bg3.png', 190, 512)
        self.effect = GameEffect(g,'wind')
        pygame.mixer.music.load(os.path.join("ambient",  "amb15.ogg"))
        pygame.mixer.music.play(40000)
        
        self.fox = Character("fox.png","facefox.tga", g, 'fox')
        self.fox.pos((31, 15))
        self.fox.direction = 0
        self.fox.health = 40
        self.fox.healthmax = 40

        self.director = Character("director.png","facedirector.png", g, 'director')
        self.director.pos((36, 16))
        self.director.direction = 1
        
        if 'scene16' in g.saveData:
            self.fox.hidden = 1
        if 'scene17' in g.saveData:
            self.fox.feeling = 'dead'
            self.director.hidden = 1
        # plane is gone if you got imas backup tape
        if 'i_tape' in g.saveData:
            self.vats.removeself()
        self.invbox = 0


    # ugly, ugly monsters
    def add_monster (self,g,r,a):
        Monster5(self.g, (r.rect.x, r.rect.y))

    # upon moving
    def playerMove(self, g,r,a):
        print 'player move'
        if self.prevlevel == 29:
            g.player.rect.x,g.player.rect.y = r.rect.x,r.rect.y - 2
            g.view.x = r.rect.x
            g.view.y = r.rect.y


    # draw back of level
    def draw_back(self):
        test = self.draw_gradent((105,70,70), (0, 30, 255))
        self.g.screen.blit(test, (0,0))

    # when you're over a change level tile
    def change_level(self, g,r,a):
        if a.__class__.__name__ != 'Player':
            return
        if g.player.pos[0] == 64:
            g.currentLevel = 29
        if g.player.pos[0] == 1:
            g.currentLevel = 27
        print g.player.pos

    # level events
    def level_loop(self):
        g = self.g

        if self.g.player.pos[0] > 24:
            if not 'scene16' in g.saveData:
                g.intermission = 1
                self.pan_camera(self.fox)
                if self.dialog == 0:
                    self.dialog = 1

                if self.dialog != 0:
                    if g.keyup:
                        self.dialog += 1
                        self.contains_msg_box_counter = 0
                if self.dialog == 2:
                    g.intermission = 1
                    str = "The plane is ready. "
                    self.info_box(str,self.director)
                if self.dialog == 3:
                    str = "Him, again?"
                    self.fox.direction = 1
                    self.fox.feeling = 'sad'
                    self.info_box(str,self.director)
                if self.dialog == 4:
                    str = "You still havn't killed him?"
                    self.info_box(str,self.director)
                    self.fox.direction = 0
                if self.dialog == 5:
                    str = "This is your last chance. Finish him!"
                    self.info_box(str,self.director)
                    self.director.walkto((35, 16))
                if self.dialog == 6:
                    g.intermission = 0
                    g.saveData['scene16'] = 1
                    self.dialog = 0
                    self.fox.attacking = 3

        if self.director.hasWalkedTo((35,16)):
            self.director.hidden = 1
        if self.fox.attacking != 0 and self.fox.feeling != 'dead':
            self.fox.draw_health_meter()
            self.g.clayer[16][6] = 1
            self.g.tlayer[16][6] = 30
        else:
            if self.fox.health <= 0:
                self.fox.rect.y += 2 # gravity
            self.g.clayer[16][6] = 0
            self.g.tlayer[16][6] = 0
            if g.player.pos == (35, 16):
                if g.event:
                    g.currentLevel = 29

        # make the last health increase
        if self.fox.feeling == 'dead':
            if not 'scene17' in g.saveData:
                self.invbox = Inventory(g, 'healthincrease5', (self.fox.rect.x, self.fox.rect.y))
            g.saveData['scene17'] = 1
            if self.invbox:
                self.invbox.rect.y += 3



           
        if self.oldPos != g.player.pos:
            self.dialog = 0
            self.oldPos = g.player.pos
            self.timer = 0
예제 #2
0
class Level(LevelBase):
    prevlevel = 0
    dialog = 0
    pdialog = 0
    timer = 0
    oldPos = (0, 0)
    dialog = 0
    btimer = 0
    fadein = 0
    watertimer = 0
    
    def __init__(self, g, player_new, dimentions, p = 0):
        LevelBase.__init__(self, g, player_new, dimentions)
        self.prevlevel = p
        self.title = 'Office'

        # current level
        currentLevel = os.path.join("levels",  "level13.tga")

        TW,TH = 32,32

        # load tile set
        tileTexture = os.path.join("textures",  "tiles4.png")
        g.tga_load_tiles(tileTexture, (TW,TH), self.tdata)
        g.tga_load_level(currentLevel, 1)
        g.bounds = pygame.Rect(TW,TH,(len(g.tlayer[0])-2)*TW,(len(g.tlayer)-2)*TH)
        g.code_events(self.edata)
        g.run_codes(self.cdata,(0,0,g.dimentions[0],g.dimentions[1]))

        # intermission!
        self.fox = Character("fox.png","facefox.tga", g, 'fox')
        self.fox.pos((27, 13))
        self.fox.direction = 0
        self.fox.hidden = 1

        self.assistant = Character("assistant.png","faceassistant.png", g)
        self.assistant.pos((28, 9))
        self.assistant.direction = 0
        self.assistant.feeling = 'pulled'
        self.assistant.hidden = 1

        self.director = Character("director.png","facedirector.png", g, 'director')
        self.director.pos((32, 14))
        self.director.direction = 1
        self.director.feeling = 'sit'

        if 'scene18' in g.saveData:
            self.director.hidden = 1
            self.dialog = 15
            g.intermission = 0
            self.switches[0].open = 1

        
    # ugly, ugly monsters
    def add_monster (self,g,r,a):
        print 'add_monster ',r.rect
        #Enemy(self.g, (r.rect.x, r.rect.y), 'monster0')
        Monster0(self.g, (r.rect.x, r.rect.y))

    # upon moving
    def playerMove(self, g,r,a):
        if self.prevlevel == 14:
            g.player.rect.x,g.player.rect.y = r.rect.x,r.rect.y
            g.view.x = r.rect.x
            g.view.y = r.rect.y

            # you also wake up here if you've just killed robot
            if 'scene18' in g.saveData:
                self.fadein = 1


    # when you're over a change level tile
    def change_level(self, g,r,a):
        if a.__class__.__name__ != 'Player':
            return
        print g.player.pos
        if g.player.pos[1] == 23:
            g.currentLevel = 12

    # level events
    def level_loop(self):
        g = self.g

        if g.keyup and self.timer > 30:
            if self.dialog > 0 and self.dialog != 10 and self.dialog != 9 and self.dialog != 11 and self.dialog != 15:
                self.dialog += 1
                self.contains_msg_box_counter = 0

        if g.player.pos == (24, 11) or g.player.pos == (24, 12) or g.player.pos == (24, 13) or g.player.pos == (24, 14):
            if self.dialog == 0:
                self.dialog = 1
                g.intermission = 1
                self.pan_camera(self.fox)
                self.fox.pos((27, 8))
                self.timer = 0
        if self.dialog == 1:
            str = "Fox:"
            str += "\nI got her"
            self.info_box(str, self.fox)
            self.fox.walkto((28, 13))
            self.assistant.walkto((29, 14))
            self.fox.hidden = 0
            self.assistant.hidden = 0
            if self.switches[0].open:
                self.switches[0].pull_switch()
        elif self.dialog == 2:
            self.assistant.feeling = 'worried'
            str = "..."
            str += "\nGood. "
            self.director.feeling = 'sitawake'
            self.info_box(str, self.director)
        elif self.dialog == 3:
            str = "Take her to the prison."
            self.info_box(str, self.director)
        elif self.dialog == 4:
            str = "What is this?"
            self.info_box(str, self.director)
            self.fox.feeling = 'sad'
        elif self.dialog == 5:
            str = "Fox:"
            str += "\nAh..."
            self.info_box(str, self.fox)
            self.fox.direction = 1
        elif self.dialog == 6:
            str = "Fox:"
            str += "\nIt's her clone she made, Director Victoria"
            self.info_box(str, self.fox)
            self.fox.direction = 1
        elif self.dialog == 7:
            str = "Director Victoria:"
            str += "\nI can see that! You failed to get rid of her illegal friend? Useless!"
            self.info_box(str, self.director)
            self.director.feeling = 'sitangry'
            self.fox.direction = 0
        elif self.dialog == 8:
            str = "Director Victoria:"
            str += "\nThis time get rid of him. Put her in the incarceration hole."
            self.info_box(str, self.director)
            self.fox.feeling = 'normal'
            self.director.feeling = 'normal'
        elif self.dialog == 9:
            self.fox.faceup = 1
            self.assistant.hidden = 1
            self.btimer += 1
            if self.btimer > 40:
                self.director.walkto((36, 14))
                self.fox.faceup = 0
                self.dialog = 10
                self.director.direction = 0
                self.pan_camera(g.player)
        elif self.dialog == 10:
            self.btimer += 1
            if self.btimer > 40:
                # start another boss battle
                self.fox.attacking = 2
                self.fox.health = 50
                self.fox.healthmax = 50
                self.dialog = 11
                g.intermission = 0
        elif self.dialog == 11:
            if self.fox.attacking != 0: # kill the fox!
                self.fox.draw_health_meter()
            else:
                self.dialog = 12
                self.timer = 0
        elif self.dialog == 12:
            str = "Fox:"
            str += "\nNot again!"
            self.info_box(str, self.fox)
            self.pan_camera(self.fox)
            g.intermission = 1
        elif self.dialog == 13:
            str = "Fox:"
            str += "\nWhatever. I'm out of here"
            self.info_box(str, self.fox)
        elif self.dialog == 14:
            g.intermission = 0
            self.fox.jump_out()
            self.dialog = 15
            self.btimer = 0
        elif self.dialog == 15:
            self.btimer += 1
            if self.btimer >= 30:
                self.fox.hidden = 1




        # give a wee message that director locked the door behind her. bitch.
        if g.player.pos == (36, 14):
            if g.event:
                self.pdialog = 1
            if self.pdialog == 1:
                if 'i_jailkey' in g.saveData:
                    g.currentLevel = 34
                else:
                    str = "\nThe door is locked."
                    self.info_box(str)

        
        # the tunnel to the jail pit (prompt player for option)
        if not 'scene18' in g.saveData:
            # director f***s off
            if self.director.hasWalkedTo((36, 14)):
                self.director.hidden = 1
                self.g.tlayer[14][36] = 42
            if g.player.pos == (29, 14) and self.fox.hidden == 1:
                if g.event and g.level.option_gui == 0:
                    g.level.option_gui = 1
                    g.intermission = 1
                    self.contains_msg_box_counter = 0
                    self.pan_camera(None)
            if g.level.option_gui != 0: # dialog open
                str = "\nJump in the pipe?"
                self.info_box(str)
            if g.level.option_gui == 3: #selected yes
                g.level.option_gui = 0
                self.g.currentLevel = 14
                g.intermission = 0
            if g.level.option_gui == 4: #selected no
                g.level.option_gui = 0
                g.intermission = 0
        else:
            self.g.tlayer[14][36] = 42
            self.watertimer += 1
            if self.watertimer % 2 == 0:
                Effect(self.g, 'water', (29 * 32, 14* 32 + 3))

            
        #(7, 14)
        if self.switches[0].open:
           self.g.clayer[14][7] = 0
           self.g.tlayer[14][7] = 7
        else:
           self.g.clayer[14][7] = 1
           self.g.tlayer[14][7] = 9

        # fade in 
        if self.fadein!=0:
            self.fadein += 1
            if self.fadein < 64:
                self.g.player.animation = 1
                self.g.player.dieanimation = 1
                g.intermission = 1
                alpha = self.fadein * 4
                self.g.screen.fill((alpha,alpha,alpha), None, BLEND_MULT)
            else:
                self.g.player.animation = 0
                self.g.player.dieanimation = 0
                g.intermission = 0
                self.fadein = 0

        # if you're moving
        if self.oldPos != g.player.pos:
            self.pdialog = 0
        self.oldPos = g.player.pos
        self.timer += 1

        
예제 #3
0
class Level(LevelBase):
    prevlevel = 0
    dialog = 0
    pdialog = 0
    timer = 0
    oldPos = (0, 0)
    dialog = 0
    btimer = 0
    fillingwithwater = 0
    
    def __init__(self, g, player_new, dimentions, p = 0):
        LevelBase.__init__(self, g, player_new, dimentions)
        self.prevlevel = p
        self.title = 'Jail'

        # current level
        TW,TH = 32,32

        # load tile set
        tileTexture = os.path.join("textures",  "tiles5.png")
        g.tga_load_tiles(tileTexture, (TW,TH), self.tdata)
        currentLevel = os.path.join("levels",  "level14.tga")
        g.tga_load_level(currentLevel, 1)
        g.bounds = pygame.Rect(TW,TH,(len(g.tlayer[0])-2)*TW,(len(g.tlayer)-2)*TH)
        g.code_events(self.edata)

        self.robot = Character("robot0.png","facerobot.tga", g,'robot')
        self.robot.pos((13, 20))
        self.robot.direction = 0
        
        #(2, 3) 'i_arms' in g.saveData
        self.arms = Inventory(g, 'arms')
        self.arms.pos((2,3))

        # if you've given her arms
        if 'scene7' in g.saveData:
            self.dialog = 6
            self.robot.feeling = 'arms'

        # if you read the newspaper, she fights you to get to the top
        self.newspaper = 0
        if 'scene17' in g.saveData:
            self.newspaper = Inventory(g, "newspaper")
            self.newspaper.pos((6, 20))

        if 'scene19' in g.saveData:
            self.robot.feeling = 'dead'
            self.robot.hidden = 1

        g.run_codes(self.cdata,(0,0,g.dimentions[0],g.dimentions[1]))

    # upon moving
    def playerMove(self, g,r,a):
        if self.prevlevel == 15:
            g.player.rect.x,g.player.rect.y = r.rect.x,r.rect.y
            g.view.x = r.rect.x
            g.view.y = r.rect.y

    # when you're over a change level tile
    def change_level(self, g,r,a):
        if a.__class__.__name__ != 'Player':
            return
        if g.player.pos[0] == 38:
            g.currentLevel = 15

    # level events
    def level_loop(self):
        g = self.g

        if 'scene7' in g.saveData:
            self.g.clayer[4][18] = 0
            self.g.tlayer[4][18] = 1
        else:
            self.g.clayer[4][18] = 1
            self.g.tlayer[4][18] = 25

        # player position
        if g.player.pos == (13, 20) and not 'scene18' in g.saveData:
            if g.event:
                self.pdialog = 1
                if 'i_arms' in g.saveData:
                    self.pdialog = 2
            if self.pdialog == 0:
                if not 'scene7' in g.saveData:
                    self.robot.feeling = 'blink'
            if self.pdialog == 1:
                self.dialog = 0
                self.robot.feeling = ''
                str = "Hello! Welcome to the Octagon Correctional Facility."
                str += "\nYou must be a visitor, as you weren't tagged when you arrived."
                str += "\nI'd love to help you, but I've misplaced my arms."
                self.info_box(str, self.robot)
            elif self.pdialog == 2:
                if g.keyup and self.timer > 30:
                    self.dialog += 1
                    self.timer = 0
                    self.contains_msg_box_counter = 0
                if 'scene7' in g.saveData and self.dialog == 1:
                    self.dialog = 6 # if you already got the item
                if self.dialog == 1:
                    self.robot.feeling = 'happy'
                    str = "Ah! you found some arms!"
                    g.intermission = 1
                    g.player.staylooking = 1
                    self.info_box(str, self.robot)
                elif self.dialog == 2:
                    self.robot.feeling = 'arms'
                    str = "Thank you"
                    g.saveData['i_arms'] = 0
                    g.player.staylooking = 1
                    self.info_box(str, self.robot)
                elif self.dialog == 3:
                    self.robot.feeling = 'arms'
                    str = "Ima? Yes a girl was automatically transferred to a holding cell "
                    str += "\nacross to the jail. She's been stored in a cell across the complex. "
                    self.info_box(str, self.robot)
                    g.player.staylooking = 1
                elif self.dialog == 4:
                    str = "I'll open the door for you so you can get out."
                    self.info_box(str, self.robot)
                    g.player.staylooking = 1
                elif self.dialog == 5:
                    g.saveData['scene7'] = 1
                    g.player.staylooking = 0
                    g.intermission = 0
                    self.dialog = 7
                elif self.dialog == 6:
                    self.robot.feeling = 'arms'
                    str = "Your friend was automatically transferred to a holding cell."
                    self.info_box(str, self.robot)

        if 'scene17' in g.saveData:
            if not 'scene18' in g.saveData:
                if self.newspaper and self.newspaper.gotten:
                    if g.intermission == 0:
                        self.timer = 0
                    str = "What are you doing? Don't touch that!"
                    self.info_box(str, self.robot)
                    g.intermission = 1
                    g.player.direction = 0
                    if g.keyup and self.timer > 30:
                        g.saveData['scene18'] = 1
                        g.intermission = 0
                        self.robot.attacking = 1

        if self.robot.attacking != 0 and self.robot.feeling != 'dead':
            self.robot.draw_health_meter()
            self.g.clayer[17][18] = 1
            self.g.tlayer[17][18] = 11
        else:
            self.g.clayer[17][18] = 0
            self.g.tlayer[17][18] = 10

        if self.robot.feeling == 'dead':
            if not 'scene19' in g.saveData:
                Inventory(self.g, 'drawingwater', (192, 536 - 64))
                Inventory(self.g, 'waterfall', (15 * 32, 16 * 32))
                g.shake_screen()
                g.player.maxspeed = 3
                g.player.jump_gravity = 7
                self.fillingwithwater = 1
            g.saveData['scene19'] = 1

        # filling the level with water
        if (self.fillingwithwater != 0):
            self.fillingwithwater += 1
            self.g.clayer[17][18] = 1
            self.g.tlayer[17][18] = 11
            

            if self.fillingwithwater > 450 and self.fillingwithwater < 550:
                self.info_box("\nYou can't hold your breath for much longer.")

            if self.fillingwithwater > 750 and self.fillingwithwater < 850:
                self.info_box("\nYou are feeling lightheaded")


            # fade to black when dead
            fadouttime = 1000
            if self.fillingwithwater > fadouttime and self.fillingwithwater < fadouttime+64:
                g.intermission = 1
                self.g.player.animation = 1
                self.g.player.dieanimation = 1
                alpha = 255 - (self.fillingwithwater - fadouttime) * 4
                self.g.screen.fill((alpha,alpha,alpha), None, BLEND_MULT)
            if self.fillingwithwater >= fadouttime+64:
                self.g.screen.fill((0,0,0))
                self.g.player.animation = 0
                self.g.player.dieanimation = 0
            if self.fillingwithwater > 1100:
                g.currentLevel = 13




        #(15, 16) test


        # if you're moving
        if self.oldPos != g.player.pos:
            self.pdialog = 0
            self.dialog = 0
        self.oldPos = g.player.pos
        self.timer += 1

        
예제 #4
0
class Level(LevelBase):
    prevlevel = 0
    dialog = 0
    pdialog = 0
    timer = 0
    oldPos = (0, 0)
    dialog = 0
    
    def __init__(self, g, player_new, dimentions, p = 0):
        LevelBase.__init__(self, g, player_new, dimentions)
        self.prevlevel = p
        self.title = "Tree House"

        # current level
        currentLevel = os.path.join("levels",  "level7.tga")

        TW,TH = 32,32

        # load tile set
        tileTexture = os.path.join("textures",  "tiles2.png")
        g.tga_load_tiles(tileTexture, (TW,TH), self.tdata)
        g.tga_load_level(currentLevel, 1)
        g.bounds = pygame.Rect(TW,TH,(len(g.tlayer[0])-2)*TW,(len(g.tlayer)-2)*TH)
        g.code_events(self.edata)

        self.fox = Character("fox.png","facefox.tga", g, 'fox')
        self.fox.pos((3, 9))
        self.fox.direction = 0
        self.fox.hidden = 1

        self.assistant = Character("assistant.png","faceassistant.png", g)
        self.assistant.pos((9, 10))
        self.assistant.direction = 0
        
        g.run_codes(self.cdata,(0,0,g.dimentions[0],g.dimentions[1]))
        self.g.player.direction = 1
        g.intermission = 1
        if 'scene5' in g.saveData:
            self.assistant.hidden = 1
            self.fox.hidden = 1
            self.dialog = 10

    # adds a monster. in this level they're rats, and one bird
    def add_monster (self,g,r,a):
        if r.rect == Rect(640, 416, 32, 32):
            Bird(self.g, (r.rect.x, r.rect.y))
        else:
            Rat(self.g, (r.rect.x, r.rect.y))

    # upon moving
    def playerMove(self, g,r,a):
        print g, r, a
        pass

    # when you're over a change level tile
    def change_level(self, g,r,a):
        if a.__class__.__name__ != 'Player':
            return

        # going back to the train tracks
        if g.event:
            if g.player.pos == (11, 10) and self.dialog == 10:
                g.currentLevel = 6
        

    # draw back of level
    def draw_back(self):
        test = self.draw_gradent((60,40,30), (0, 0, 0))
        self.g.screen.blit(test, (0,0))

    # level events
    def level_loop(self):
        g = self.g

        if g.keyup and self.timer > 30:
            if self.dialog < 6:
                self.dialog += 1
                self.contains_msg_box_counter = 0
            if self.dialog == 6 and g.intermission == 1:
                self.dialog += 1
                self.contains_msg_box_counter = 0
            if self.dialog == 9 or self.dialog == 7:
                self.dialog += 1
                self.contains_msg_box_counter = 0

            self.timer = 0

        if self.dialog == 0:
            str = "Ima:"
            str += "\nWelcome to my home"
            self.info_box(str, self.assistant)
        elif self.dialog == 1:
            self.g.player.direction = 1
            self.assistant.direction = 1
            self.fox.hidden = 0
            str = "\nhello!"
            self.info_box(str, self.fox)
        elif self.dialog == 2:
            self.fox.feeling = 'sad'
            str = "I came here to inform you that you Ima broke your "
            str += "\ncontractual obligations. This means I have to take you away."
            self.info_box(str, self.fox)
        elif self.dialog == 3:
            self.fox.feeling = 'normal'
            str = "Who are you?"
            self.info_box(str, self.fox)
        elif self.dialog == 4:
            str = "You must be why I'm here!"
            str += "\nThat means I can squash you!"
            self.info_box(str, self.fox)
        elif self.dialog == 5:
            self.fox.attacking = 1
            self.timer = 0
            self.dialog = 6
            g.intermission = 0
        elif self.dialog == 6:
            if self.fox.attacking != 0: # finishing the battle. Ima gets kidnapped
                self.fox.draw_health_meter()
            else:
                g.intermission = 1
                self.dialog = 7
                self.timer = 0
        elif self.dialog == 7:
            str = "Ah! my face!"
            str += "\nI'm getting out of here."
            self.fox.feeling = 'angry'
            self.info_box(str, self.fox)

        elif self.dialog == 8:
            self.fox.walktorect((self.assistant.rect.x, self.assistant.rect.y))
            self.fox.direction = 0
            if self.fox.rect == Rect(320, 288, 96, 64) or self.fox.rect == Rect(288, 288, 96, 64):
                self.fox.direction = 1
                self.fox.walkto((10, 2))
                self.assistant.walkto((10, 2))
                self.dialog = 9
                self.timer = 0
        elif self.dialog == 9:
            str = "Ima:"
            str += "\nEeeeek!"
            self.assistant.feeling = 'scared'
            self.info_box(str, self.assistant)
            if self.timer > 25:
                self.fox.hidden = 1
                self.assistant.hidden = 1
        elif self.dialog == 10:
            self.dialog = 10
            g.intermission = 0
            g.saveData['scene5'] = 1


        # if you're moving
        if self.oldPos != g.player.pos:
            self.pdialog = 0
        self.oldPos = g.player.pos
        self.timer += 1

        
예제 #5
0
class Level(LevelBase):
    prevlevel = 0
    dialog = 0
    pdialog = 0
    timer = 0
    oldPos = (0, 0)
    dialog = 0
    btimer = 0
    lockedatmessage = 0
    inbattle = 0
    
    def __init__(self, g, player_new, dimentions, p = 0):
        LevelBase.__init__(self, g, player_new, dimentions)
        self.prevlevel = p
        self.title = 'Office Complex Top'
        # current level
        TW,TH = 32,32

        # load tile set
        g.tga_load_tiles(os.path.join("textures",  "tiles6.png"), (TW,TH), self.tdata)
        g.tga_load_level(os.path.join("levels",  "level31.tga"), 1)
        g.bounds = pygame.Rect(TW,TH,(len(g.tlayer[0])-2)*TW,(len(g.tlayer)-2)*TH)
        g.code_events(self.edata)
        self.initBack('bg1.png', 730)

        self.backuptape = Inventory(g, 'tape', (37, 22))
        self.backuptape.pos((37, 22))
        self.backup = Character('backup.png', 'facebackup.png', g, 'backup')
        self.backup.pos((28, 25))
        self.backup.direction = 0
        if 'scene21' in g.saveData:
            self.backup.hidden = 1
        # coming back and saying high to the guy.
        if 'scene20' in g.saveData and not 'scene21' in g.saveData:
            del g.saveData['scene20']

        g.run_codes(self.cdata,(0,0,g.dimentions[0],g.dimentions[1]))
        self.coins = 0


    # upon moving
    def playerMove(self, g,r,a):
        print 'player move'

    # draw back of level
    def draw_back(self):
        test = self.draw_gradent((105,70,70), (0, 30, 255))
        self.g.screen.blit(test, (0,0))

    # when you're over a change level tile
    def change_level(self, g,r,a):
        if a.__class__.__name__ != 'Player':
            return
        print g.player.pos
        if g.player.pos[0] == 1:
            g.currentLevel = 30

    # level events
    def level_loop(self):
        g = self.g



        # Some hints as to the past
        if g.player.pos == (28, 25) and not 'scene20' in g.saveData:
            if self.pdialog != 0:
                if g.keyup:
                    self.contains_msg_box_counter = 0
                    self.pdialog += 1
            if g.event and self.pdialog == 0:
                self.backup.face_the_player()
                g.intermission = 1
                self.pdialog = 1
                self.backup.walkto((29, 25))
                self.backup.direction = 1
                g.player.direction = 0

            if self.pdialog == 2:
                str = "Hello"
                self.info_box(str, self.backup)
            elif self.pdialog == 3:
                str = "You don't know me..."
                str += "\nbut I know you, ha. Haha!"
                self.info_box(str, self.backup)
            elif self.pdialog == 4:
                str = "Who knows if I'm myself, when I am who what's on a tape? "
                str += "\nSeveral times I've been built because of a timer."
                str += "\nWhat happened in between these gaps is anyone's guess."
                self.info_box(str, self.backup)
            elif self.pdialog == 5:
                str = "You came to tell me what you're doing."
                str += "\nBut I already know!"
                self.info_box(str, self.backup)
            elif self.pdialog == 6:
                str = "See, you can't have her tape."
                str += "\nI need it. For the future, you see."
                self.info_box(str, self.backup)
            elif self.pdialog == 7:
                str = "The insult 'tool' never really fits to most situations."
                str += "\nBut now it's apt!"
                self.info_box(str, self.backup)
            elif self.pdialog == 8:
                str = "...sudo apt!"
                self.info_box(str, self.backup)
            elif self.pdialog == 9:
                str = "..."
                self.info_box(str, self.backup)
            elif self.pdialog == 10:
                str = "Now you die!"
                self.info_box(str, self.backup)
            elif self.pdialog == 11:
                g.saveData['scene20'] = 1
                self.backup.attacking = 1
                self.backup.dy = -10.0
                self.pdialog = 20
                self.backup.walkto(None)
        else:
            g.intermission = 0

        if 'scene20' in g.saveData:
            if not 'scene21' in g.saveData:
                self.backup.draw_health_meter()

        if self.backup.health <= 0:
            if not 'scene21' in g.saveData:
                g.saveData['scene21'] = 1
                self.backup.attacking = 0
                self.backup.dead = 1
                self.coins = Inventory(g, 'coin', (self.backup.rect.x, self.backup.rect.y) )

        if self.coins:
            self.coins.rect.y += 5
            self.backup.rect.y += 5


        if self.oldPos != g.player.pos:
            self.pdialog = 0
        self.oldPos = g.player.pos