Ejemplo n.º 1
0
 def _visual_sprite(self, visual_sprite: VisualSprite):
     position = visual_sprite.position
     animation_progress = visual_sprite.animation_progress()
     sprite = visual_sprite.sprite
     if sprite in self.images_by_sprite:
         image_with_relative_position = self._get_image_for_sprite(
             sprite, Direction.DOWN, animation_progress)
         self.world_render.image_with_relative_pos(image_with_relative_position, position)
     else:
         raise Exception("Unhandled sprite: " + str(sprite))
 def apply_enemy_collision(self, npc: NonPlayerCharacter, game_state: GameState, projectile: Projectile):
     damage_was_dealt = deal_player_damage_to_enemy(game_state, npc, 1, DamageType.MAGIC)
     if damage_was_dealt:
         npc.gain_buff_effect(get_buff_effect(BUFF_TYPE), DEBUFF_DURATION)
         victim_center_pos = npc.world_entity.get_center_position()
         visual_effect_pos = (victim_center_pos[0] - ENTANGLING_ROOTS_SIZE[0] // 2,
                              victim_center_pos[1] - ENTANGLING_ROOTS_SIZE[1] // 2)
         debuff_visual_effect = VisualSprite(Sprite.DECORATION_ENTANGLING_ROOTS_EFFECT, visual_effect_pos,
                                             DEBUFF_DURATION, npc.world_entity)
         game_state.game_world.visual_effects.append(debuff_visual_effect)
         play_sound(SoundId.ABILITY_ENTANGLING_ROOTS_HIT)
     projectile.has_collided_and_should_be_removed = True
Ejemplo n.º 3
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.game_world.player_entity

    player_center_pos = player_entity.get_center_position()
    game_state.game_world.visual_effects.append(
        VisualCircle((150, 150, 250), player_center_pos, 95, 190, Millis(200), 3))
    affected_enemies = game_state.game_world.get_enemies_within_x_y_distance_of(180, player_center_pos)
    effect_position = get_position_from_center_position(player_center_pos, EFFECT_SPRITE_SIZE)
    game_state.game_world.visual_effects.append(
        VisualSprite(Sprite.EFFECT_ABILITY_FROST_NOVA, effect_position, Millis(200), player_entity))
    for enemy in affected_enemies:
        damage_was_dealt = deal_player_damage_to_enemy(game_state, enemy, 5, DamageType.MAGIC
                                                       )
        if damage_was_dealt:
            enemy.gain_buff_effect(get_buff_effect(BuffType.REDUCED_MOVEMENT_SPEED), Millis(4000))
    return AbilityWasUsedSuccessfully()