Example #1
0
    def collected(self):
        self.player.attack_multiplier += self.effect.strength
        self.player.hp += self.effect.heal
        if self.player.hp >= self.player.MAX_HP:
            self.player.hp = self.player.MAX_HP
        self.player.speed_multiplier += self.effect.speed
        self.player.resistance += self.effect.resistance

        start_y = self.center_y
        for attribute in self._effect.__dict__.keys():
            value = self._effect.__getattribute__(attribute)
            if value > 0:
                if value % 1 == 0:
                    msg = f"+{value} {attribute}"
                else:
                    percentage = value * 100
                    msg = f"+{int(percentage)}% {attribute}"

                self.ctx.create_text_indicator(
                    msg,
                    (self.center_x, start_y),
                    color=(0, 255, 0)
                )
                start_y += 20

        SoundManager.add_sound("pickup_0.wav")
        SoundManager.play_sound("pickup_0.wav")

        if self.duration is None:
            self.kill()
Example #2
0
 def hit(self, weapon, attack_multiplier: float = 1.0):
     if self.resistance >= 1.0:
         SoundManager.add_sound("armor.mp3")
         SoundManager.play_sound("armor.mp3")
         pass
     else:
         super().hit(weapon, attack_multiplier)
Example #3
0
    def on_update(self, delta_time: float) -> None:
        if self.slow_down or self.time_slow_ability:
            delta_time = delta_time / s.ON_CARD_HOVER_SLOWDOWN_MULTIPLIER

        if self.charging and self.charge < 100:
            if self.time_slow_ability:
                self.charge += delta_time * 60 * s.ON_CARD_HOVER_SLOWDOWN_MULTIPLIER
            else:
                self.charge += delta_time * 60

        if self.player.is_alive:
            if self.time_slow_ability:
                self.player.on_update(delta_time *
                                      s.ON_CARD_HOVER_SLOWDOWN_MULTIPLIER)
            else:
                self.player.on_update(delta_time)

        self.game_manager.on_update(delta_time)
        self.map.on_update(delta_time)
        self.camera.update()
        self.card_manager.update()

        self.player.update_health_bars(delta_time)

        SoundManager.update(self.slow_down or self.time_slow_ability)
        self.soundtrack_manager.update(self.slow_down
                                       or self.time_slow_ability)
        self.cursor_manager.update()
        self.player.update_health_bars(delta_time)
Example #4
0
 def activate(self, x, y, view_reference):
     floor_stomp = FloorStompMelee(
         center_x=view_reference.player.center_x,
         center_y=view_reference.player.center_y,
     )
     view_reference.game_manager.player_melee_attacks.append(floor_stomp)
     view_reference.game_manager.effects.append(floor_stomp.effect_sprite)
     SoundManager.play_sound(self.activate_sound)
Example #5
0
 def process_right_mouse_press(self, x, y) -> None:
     if self._ability_duration_left > 0:
         print("Ability already active!")
     elif len(self.mana_bar) == self.mana_bar.max_fillers:
         self.mana_bar.clear(len(self.mana_bar))
         self._ability_duration_left = self.selected_ability.duration
         self.selected_ability.activate(x, y, self.view)
         self.view.card_manager.card_manager_enabled = False
     else:
         SoundManager.add_sound("mana_empty.wav")
         SoundManager.play_sound("mana_empty.wav")
Example #6
0
 def __init__(self,
              duration: int,
              activate_sound: str = None,
              deactivate_sound: str = None):
     if duration >= self.base_cool_down:
         raise Exception(
             "Ability duration cannot be higher than base cool-down.")
     self.duration = duration
     self.activate_sound = activate_sound
     self.deactivate_sound = deactivate_sound
     SoundManager.add_sound(activate_sound)
     SoundManager.add_sound(deactivate_sound)
Example #7
0
    def process_left_mouse_press(self, x, y, charge) -> None:
        if time.time() - self.last_shot < self.dexterity:
            SoundManager.add_sound("empty_gun.wav")
            SoundManager.play_sound("empty_gun.wav")
            return

        to_shoot = False
        if charge >= 90 and len(self.mana_bar) >= 3:
            to_shoot = True
            self.mana_bar.clear(3)
        elif charge >= 70 and len(self.mana_bar) >= 2:
            to_shoot = True
            self.mana_bar.clear(2)
        elif charge >= 50 and len(self.mana_bar) >= 1:
            to_shoot = True
            self.mana_bar.remove_filling_part()
        elif charge < 50:
            to_shoot = True

        if not to_shoot:
            SoundManager.add_sound("mana_empty.wav")
            SoundManager.play_sound("mana_empty.wav")
            return

        bullet = ChargedLaserProjectile(
            charge=charge,
            center_x=self.center_x,
            center_y=self.center_y,
            rotate=True,
        )
        bullet.color = self.curr_color_to_rgb()
        bullet.move_to(x, y, set_target=False)
        bullet.play_activate_sound()
        self.view.game_manager.player_projectiles.append(bullet)
        self.last_shot = time.time()

        self.state = States.ATTACKING_RANGED
Example #8
0
 def deactivate(self, game_view_reference):
     game_view_reference.player.reset_stats()
     game_view_reference.player.regenerating_hp = False
     game_view_reference.player.regeneration_hp_value = game_view_reference.player.DEFAULT_HP_REGENERATION_PER_S
     game_view_reference.player.color = (255, 255, 255, 255)
     SoundManager.play_sound(self.deactivate_sound)
Example #9
0
 def activate(self, x, y, game_view_reference):
     game_view_reference.player.resistance = 1.0
     game_view_reference.player.regenerating_hp = True
     game_view_reference.player.regeneration_hp_value = 40
     game_view_reference.player.color = (255, 255, 255, 100)
     SoundManager.play_sound(self.activate_sound)
Example #10
0
 def deactivate(self, game_view_reference):
     game_view_reference.time_slow_ability = False
     SoundManager.play_sound(self.deactivate_sound)
Example #11
0
 def activate(self, x, y, game_view_reference):
     game_view_reference.time_slow_ability = True
     SoundManager.play_sound(self.activate_sound)