示例#1
0
    def __init__(self, game):
        super().__init__(game, game.width / 2, game.height / 2, game.width,
                         game.height)
        self.elements = []
        self.update_while_tween = False
        self.in_tween = False

        margin_top = 50
        margin_left = 100

        carousel_width = SkillView.width * 3 + SkillGroupElement.gap * 2

        group_elements = []

        for skill_group in SkillManager.get_instance().groups.values():
            group = SkillGroupElement(game, margin_left + 50, 0, skill_group,
                                      self)
            group_elements.append(group)

        self.carousel = Carousel(game, margin_left + 50, margin_top + 300,
                                 carousel_width, SkillView.height,
                                 group_elements)

        self.skill_name = Tween(
            Label(self.game,
                  margin_left + carousel_width + 300,
                  margin_top,
                  350,
                  80,
                  "<>",
                  80,
                  color=(52, 152, 219)).set_fade_tick(30, "pause"),
            {'opacity': 255}, [])

        self.font = Render.load_font()

        empty_surface = Surface((500, self.game.height - margin_top - 150))
        empty_surface.set_colorkey((240, 240, 240))
        empty_surface.fill((240, 240, 240))
        empty_surface.set_alpha(0)

        self.empty_surface = empty_surface

        self.skill_desc = Tween(
            Image(self.game, margin_left + carousel_width + 300,
                  margin_top + 150, empty_surface), {'opacity': 255}, [])

        self.skill_price = Tween(
            Label(self.game,
                  margin_left + carousel_width + 300,
                  margin_top + 150 + 150,
                  350,
                  80,
                  "필요 SP   1",
                  32,
                  color=(52, 152, 219)).set_fade_tick(30, "pause"),
            {'opacity': 255}, [])

        self.current_sp = Tween(
            Label(self.game,
                  margin_left + carousel_width + 300,
                  margin_top + 150 + 150 + 40,
                  350,
                  80,
                  "현재 SP   0",
                  32,
                  color=(52, 152, 219)).set_fade_tick(30, "pause"),
            {'opacity': 255}, [])

        self.skill_score = Tween(
            Label(self.game,
                  margin_left + carousel_width + 300 + 500 - 250,
                  margin_top + 150 + 150,
                  350,
                  80,
                  "필요 점수   0",
                  32,
                  color=(52, 152, 219)).set_fade_tick(30, "pause"),
            {'opacity': 255}, [])

        self.current_score = Tween(
            Label(self.game,
                  margin_left + carousel_width + 300 + 500 - 250,
                  margin_top + 150 + 150 + 40,
                  350,
                  80,
                  "현재 점수   0",
                  32,
                  color=(52, 152, 219)).set_fade_tick(30, "pause"),
            {'opacity': 255}, [])

        self.buy_button_image = Surface((500, 100))
        Render(self.buy_button_image)\
            .fill((52, 152, 219))\
            .write_text(250, 50, "Enter 키로 구매", color=(240, 240, 240), size=50)

        self.disabled_button_image = Surface((500, 100))
        Render(self.disabled_button_image)\
            .fill((220, 220, 220))\
            .write_text(250, 50, "구매할 수 없음", color=(180, 180, 180), size=50)

        self.already_bought_button_image = Surface((500, 100))
        Render(self.already_bought_button_image)\
            .fill((220, 220, 220))\
            .write_text(250, 50, "이미 구매함", color=(180, 180, 180), size=50)

        self.buy_button = Tween(
            Image(self.game, margin_left + carousel_width + 300,
                  margin_top + 150 + 150 + 40 + 100, self.buy_button_image),
            {'opacity': 255}, [])

        self.skill_ui = [
            self.skill_name, self.skill_desc, self.skill_price,
            self.current_sp, self.skill_score, self.current_score,
            self.buy_button
        ]

        self.update_skill()

        self.elements.extend(
            (self.carousel,
             Label(self.game, margin_left, margin_top, 250, 50, "SkillTree",
                   50).set_fade_tick(30, "pause")))

        self.elements.extend(self.skill_ui)