Exemple #1
0
    def loadLevelAgain(self):
        print "Number 2"
        global storyboard_level
        data_file = os.path.join('storyboards',str(model.storyboard_file),'data','data'+str(storyboard_level)+'.pkl')
                
        graphics_file = 'graphics_layout.pkl'
        load_level_obj.new_level_stats(data_file,graphics_file)
        # Seeking in the storyboard to the current level
        model.game_controller.reset_time()
        closeStoryBoardFile()
        openStoryBoardFile()
        lev = 1
        while not lev == storyboard_level:
            obj = pickle.load(storyboardfile)
            if ((obj[0] == 'actionTrue') or (obj[0] == 'action')) and (obj[1][0] == 2):
                lev += 1

        if not storyboard_level == 1:
            run = True
            if obj[0] == 'actionTrue':

                while run :
                    obj = pickle.load(storyboardfile)
                    if obj[1][0] == 3:
                        run = False

        # End of seeking


        event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
        game_events.EventQueue.add(event)
    def loadLevelAgain(self):
        data_file = 'data'+str(storyboard_level)+'.pkl'
        graphics_file = 'graphics_layout.pkl'
        load_level_obj.new_level_stats(data_file,graphics_file)
 
        # Seeking in the storyboard to the current level
        
        closeStoryBoardFile()
        openStoryBoardFile()
        lev = 1
        while not lev == storyboard_level:
            obj = pickle.load(storyboardfile)
            if ((obj[0] == 'actionTrue') or (obj[0] == 'action')) and (obj[1][0] == 2):
                lev += 1

        if not storyboard_level == 1:
            run = True
            if obj[0] == 'actionTrue':
                    
                while run :
                    obj = pickle.load(storyboardfile)
                    if obj[1][0] == 3:
                        run = False
        
        # End of seeking
            
            
        event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
        game_events.EventQueue.add(event)
Exemple #3
0
    def loadNextLevel(self):

        global storyboard_level   
        data_file = os.path.join('storyboards',str(model.storyboard_file),'data','data'+str(storyboard_level+1)+'.pkl')
               
        model.game_controller.reset_time()
        graphics_file = 'graphics_layout.pkl'
        storyboard_level += 1
        load_level_obj.new_level_stats(data_file,graphics_file)
        event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
        game_events.EventQueue.add(event)
 def loadNextLevel(self):
     
     global storyboard_level
     
     data_file = 'data'+str(storyboard_level+1)+'.pkl'
     print data_file
     graphics_file = 'graphics_layout.pkl'
     storyboard_level += 1
     load_level_obj.new_level_stats(data_file,graphics_file)
     event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
     game_events.EventQueue.add(event)
Exemple #5
0
 def checkDelay(self):
     ''' To be called when checking the delay
     '''
     timeElapsed = self.timerClock.tick(30)
     if not (timeElapsed>1000):
         self.time += timeElapsed
     if self.time < self.timer:
         return False
     else:
         event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
         game_events.EventQueue.add(event)
         return True
Exemple #6
0
    def Chat(self,data):
        '''
            Chat text should be a list with first the name
            of the character and then his dialogue,

        '''
        if gui_buttons.gui_obj.get_child_win_flag():
            gui_buttons.gui_obj.close_child_win()
        if gui_buttons.gui_obj.get_win_flag():
            gui_buttons.gui_obj.close_win()

        text = data[0]
        bckgnd = data[1]
        chat.showChat(text,bckgnd)
        event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
        game_events.EventQueue.add(event)
Exemple #7
0
    def update(self):

        global Hospital
        global House
        global School
        global Workshop
        global ppl


        self.time += self.clock.tick()
        if self.time >= 100:
            self.counter +=1
            self.time = 0
            if self.counter <50:
                threades.transform_obj.move_free((-self.prev_disp[0],-self.prev_disp[1]))
                self.prev_disp = self.move_dir[int(random.random()*25)]
                threades.transform_obj.move_free(self.prev_disp)
            if self.counter >20 and self.counter <60:
                self.alpha +=6
                self.image.fill((0,0,0,int(self.alpha)))
                #threades.screen.blit(self.image,(0,40))
            if self.counter==40:
                display_text = model.text_file.earthquake_hit_text
                threades.message.push_message(display_text,'high')
            if self.counter == 80:
                threades.audio.play_music(True,'soundtrack')
                display_earthquake_images()
                threades.demolish_facility('Hospital')
                threades.demolish_facility('House')
                threades.demolish_facility('House')
                threades.demolish_facility('House')
                threades.demolish_facility('School')
                threades.demolish_facility('Workshop')
                model.ppl.change_total_population(-10)
            if self.counter > 81:
                if self.alpha >=2:
                    self.alpha -=2
                self.image.fill((0,0,0,int(self.alpha)))
                #threades.screen.blit(self.image,(0,40))
            if self.counter >220:
                event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
                game_events.EventQueue.add(event)
                threades.natural_calamities.remove(earth_quake)
    def update(self):

        global Hospital
        global House
        global School
        global Workshop
        global ppl

        self.counter += 1
        if self.counter < 50:
            threades.transform_obj.move_free(
                (-self.prev_disp[0], -self.prev_disp[1]))
            self.prev_disp = self.move_dir[int(random.random() * 25)]
            threades.transform_obj.move_free(self.prev_disp)
        if self.counter > 20 and self.counter < 50:
            self.alpha += 8
            self.image.set_alpha(self.alpha)
        if self.counter == 40:
            display_text = _(
                ' Your Village Sheylan has ben hit by an Earthquake')
            threades.message.push_message(display_text, 'high')
        if self.counter == 80:
            display_earthquake_images()
            threades.demolish_facility('Hospital')
            threades.demolish_facility('House')
            threades.demolish_facility('House')
            threades.demolish_facility('House')
            threades.demolish_facility('School')
            threades.demolish_facility('Workshop')
            model.ppl.change_total_population(-10)
        if self.counter > 81:
            if self.alpha > 2:
                self.alpha -= 2
            self.image.set_alpha(self.alpha)
        if self.counter > 180:
            event = game_events.Event(type=game_events.ACTIONCOMPLETEEVENT,
                                      facility_name='',
                                      res_name='',
                                      res_quantity=0)
            game_events.EventQueue.add(event)
            threades.natural_calamities.remove(earthquake)
Exemple #9
0
    def showFailureWindow(self,text):

        self.brown_color = (255,214,150)
        self.green_color = (0,250,0)
        self.black_color = (0,0,0)
        myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(40))

        # Custom gui.Window Style
        win_style = gui.defaultWindowStyle.copy()
        win_style['font'] = myfont1
        win_style['font-color'] = self.brown_color
        win_style['bg-color'] = (0,0,0)
        win_style['border-color'] = self.brown_color
        win_style['border-width'] = 2

        st_desktop = gui.Desktop()
        clock = pygame.time.Clock()
        clock.tick(30)

        # Calculating position and size of window from the size of the threades.desktop
        position_win =threades.resize_pos((150.0,100.0))
        size_win =threades.resize_pos((900.0,500.0))

        # Creating window
        self.win = gui.Window(position = position_win, size = size_win, parent = st_desktop, text = " FoodForce2" , style = win_style, shadeable = False, closeable = False,moveable = False)
        #self.win.onClose = lambda button: self.main_menu(self.pause_flag)
        #self.win.surf.set_alpha(140) This seems to be redundant as translucency doesnt seems to work properly

        myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20))
        labelStyleCopy = gui.defaultLabelStyle.copy()
        labelStyleCopy['border-width'] = 0
        labelStyleCopy['wordwrap'] = True
        labelStyleCopy['autosize'] = False
        labelStyleCopy['font'] = myfont2
        labelStyleCopy['font-color'] = self.brown_color
        labelStyleCopy['border-color'] = self.black_color

        self.storyboardwin_run = True
        #logo =  pygame.image.load(os.path.join('data', 'logo.png')).convert()
        #ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250)))

        #self.instructions_counter = 0
        label = gui.Label(position = threades.resize_pos((100.0,100.0),(900.0,500.0),self.win.size),size = threades.resize_pos((700.0,340.0),(900.0,500.0),self.win.size), parent = self.win, text = text, style = labelStyleCopy)

        gl_time = 0

        st_desktop.update()
        st_desktop.draw()
        pygame.display.update()
        
        while self.storyboardwin_run:
            pygame.display.set_caption('FoodForce2')

            for e in gui.setEvents(pygame.event.get()):
                if e.type == KEYDOWN:
                    if e.key == 27:  # For escape key
                        self.storyboardwin_run = False
                #if e.type == MOUSEBUTTONDOWN:
                    #if e.button == 1:
                        #self.storyboardwin_run = False
                    
            gl_time += clock.tick(30)
            if gl_time >= 17000:
                self.storyboardwin_run = False




        event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
        game_events.EventQueue.add(event)
Exemple #10
0
 def showInstructionMessage(self,text):
     
     thread_instruction = threading.Thread(target = gui_buttons.showMessages.addMessage, args=[text,True]).start()
     event = game_events.Event(type = game_events.ACTIONCOMPLETEEVENT, facility_name = '', res_name = '' , res_quantity = 0)
     game_events.EventQueue.add(event)