示例#1
0
    def __init__(self, game_session, UITowerIni):
        self.mous_pos = (0, 0)
        self.game_session = game_session
        self.next_click_action = None
        self.args = [Tracker(), self, self.game_session]
        self.was_action = False
        self.observer = ObservVidget()

        towers = SettingsReader().read(UITowerIni)["tower_set"].split(",")
        special_buttons = SettingsReader().read(UITowerIni)["other"].split(",")
        window = inject.instance(IWindowProvider)().get_window()
        offset = 0
        for tower in towers:
            tower = tower.replace("\n", "")
            surface = get_drawing_instance(tower)
            self.args[0].add(
                Button(ButtonSummonTower(tower),
                       (offset, window.get_height() - surface.get_height()),
                       (surface.get_width(), surface.get_height()), tower))
            offset += surface.get_width()

        for button in special_buttons:
            button = button.replace("\n", "")
            surface = get_drawing_instance(button)
            self.args[0].add(
                Button(
                    get_button(button)(),
                    (offset, window.get_height() - surface.get_height()),
                    (surface.get_width(), surface.get_height()), button))
            offset += surface.get_width()
示例#2
0
 def update_vidget(self):
     self.surface.fill((128, 128, 128))
     if self.__target__ != None:
         self.surface.blit(get_drawing_instance(self.__target__.name),
                           (0, 0))
         offset = 40
         if (mb.bestiariy.__contains__(self.__target__.name)):
             for key in mb.bestiariy[self.__target__.name][1]:
                 offset += 10
                 myfont = pygame.font.SysFont('Comic Sans MS', 10)
                 self.surface.blit(
                     myfont.render(
                         '{0}: {1}'.format(
                             key,
                             mb.bestiariy[self.__target__.name][1][key]),
                         False, (255, 242, 0)), (0, offset))
         elif (tb.bestiariy.__contains__(self.__target__.name)):
             for key in tb.bestiariy[self.__target__.name][1]:
                 offset += 10
                 myfont = pygame.font.SysFont('Comic Sans MS', 10)
                 self.surface.blit(
                     myfont.render(
                         '{0}: {1}'.format(
                             key,
                             tb.bestiariy[self.__target__.name][1][key]),
                         False, (255, 242, 0)), (0, offset))
示例#3
0
 def act(self,*args):
     camera = CameraView().get_view_point()
     window = args[0]
     drawing_surface = get_drawing_instance(self.__target__.name)
     game_object_cords = self.__target__.get_cords()
     drawing_object_cords = (
     game_object_cords[0] - drawing_surface.get_width() / 2, game_object_cords[1] - drawing_surface.get_height() / 2)
     window.blit(drawing_surface, (drawing_object_cords[0] - camera[0],drawing_object_cords[1] - camera[1]))
示例#4
0
 def act(self,*args):
     camera = CameraView().get_view_point()
     window = args[0]
     drawing_surface = get_drawing_instance(self.__target__.name)
     game_object_cords = self.__target__.get_cords()
     offset = (drawing_surface.get_width()/2,drawing_surface.get_height()/2)
     drawing_object_cords = (game_object_cords[0] - offset[0] - camera[0],game_object_cords[1] - offset[1] - camera[1])
     window.blit(drawing_surface,drawing_object_cords)
     DrawHpBarAction(self.__target__).act(offset,*args)
示例#5
0
    def __init__(self,level):
        self.clock = Clock()
        game_scenario = GameLoader().load(level)
        self.map = game_scenario["map_name"]
        self.gold = game_scenario["gold"]
        self.life = game_scenario["life_counter"]
        self.args = list([0,Tracker(),Tracker(),Tracker(),self,Tracker()])
        self.__track_monster_spawn__(game_scenario)
        settings = inject.instance(IGameSessionSettingsProvider)().get_settings()
        self.min_time_delay = int(settings['min_time_delay'])
        self.event_run_range = [1,2,3,5]

        map = get_drawing_instance(self.map).get_size()
        window = inject.instance(IWindowProvider)().get_window().get_size()

        CameraView().max_view = (max(map[0] - window[0],0),max(map[1] - window[1],0))
示例#6
0
 def act(self,*args):
     window = args[0]
     window.blit(get_drawing_instance(self.button.name),self.button.cords)
示例#7
0
 def act(self,*args):
     camera_cords = CameraView().get_view_point()
     window = args[0]
     window.blit(get_drawing_instance(self.map_name),(0 - camera_cords[0],0 - camera_cords[1]))