Beispiel #1
0
    def _put_loot_on_ground(self, enemy_death_position: Tuple[int, int],
                            loot: List[LootEntry]):
        for loot_entry in loot:
            if len(loot) > 1:
                position_offset = (random.randint(-20,
                                                  20), random.randint(-20, 20))
            else:
                position_offset = (0, 0)
            loot_position = sum_of_vectors(enemy_death_position,
                                           position_offset)

            if loot_entry.money_amount:
                money_pile_on_ground = create_money_pile_on_ground(
                    loot_entry.money_amount, loot_position)
                self.game_state.money_piles_on_ground.append(
                    money_pile_on_ground)
            elif loot_entry.item_type:
                item_on_ground = create_item_on_ground(loot_entry.item_type,
                                                       loot_position)
                self.game_state.items_on_ground.append(item_on_ground)
            elif loot_entry.consumable_type:
                consumable_on_ground = create_consumable_on_ground(
                    loot_entry.consumable_type, loot_position)
                self.game_state.consumables_on_ground.append(
                    consumable_on_ground)
Beispiel #2
0
    def _put_loot_on_ground(self, enemy_death_position: Tuple[int, int],
                            loot: List[LootEntry]):
        for loot_entry in loot:
            if len(loot) > 1:
                position_offset = (random.randint(-20,
                                                  20), random.randint(-20, 20))
            else:
                position_offset = (0, 0)
            loot_position = sum_of_vectors(enemy_death_position,
                                           position_offset)

            if isinstance(loot_entry, MoneyLootEntry):
                money_pile_on_ground = create_money_pile_on_ground(
                    loot_entry.amount, loot_position)
                self.game_state.money_piles_on_ground.append(
                    money_pile_on_ground)
            elif isinstance(loot_entry, ItemLootEntry):
                item_id = randomized_item_id(loot_entry.item_type)
                item_on_ground = create_item_on_ground(item_id, loot_position)
                self.game_state.items_on_ground.append(item_on_ground)
            elif isinstance(loot_entry, SuffixedItemLootEntry):
                item_id = randomized_suffixed_item_id(loot_entry.item_type,
                                                      loot_entry.suffix_id)
                item_on_ground = create_item_on_ground(item_id, loot_position)
                self.game_state.items_on_ground.append(item_on_ground)
            elif isinstance(loot_entry, ConsumableLootEntry):
                consumable_on_ground = create_consumable_on_ground(
                    loot_entry.consumable_type, loot_position)
                self.game_state.consumables_on_ground.append(
                    consumable_on_ground)
 def money(amount: int):
     entity = create_money_pile_on_ground(amount, (0, 0)).world_entity
     e = MapEditorWorldEntity(
         entity.sprite,
         (entity.pygame_collision_rect.w, entity.pygame_collision_rect.h))
     e.money_amount = amount
     return e
Beispiel #4
0
def _add_money(amount: int, game_state, snapped_mouse_world_position):
    already_has_money = any([
        x for x in game_state.money_piles_on_ground
        if x.world_entity.get_position() == snapped_mouse_world_position
    ])
    if not already_has_money:
        money_pile_on_ground = create_money_pile_on_ground(
            amount, snapped_mouse_world_position)
        game_state.money_piles_on_ground.append(money_pile_on_ground)
    def _put_loot_on_ground(self, enemy_death_position: Tuple[int, int],
                            loot: List[LootEntry]):
        for loot_entry in loot:
            if len(loot) > 1:
                position_offset = (random.randint(-20,
                                                  20), random.randint(-20, 20))
            else:
                position_offset = (0, 0)
            loot_position = sum_of_vectors(enemy_death_position,
                                           position_offset)

            if isinstance(loot_entry, MoneyLootEntry):
                money_pile_on_ground = create_money_pile_on_ground(
                    loot_entry.amount, loot_position)
                self.game_state.game_world.money_piles_on_ground.append(
                    money_pile_on_ground)
            elif isinstance(loot_entry, ItemLootEntry):
                item_id = randomized_item_id(loot_entry.item_type)
                item_on_ground = create_item_on_ground(item_id, loot_position)
                self.game_state.game_world.items_on_ground.append(
                    item_on_ground)
            elif isinstance(loot_entry, AffixedItemLootEntry):
                item_id = loot_entry.item_id
                item_on_ground = create_item_on_ground(item_id, loot_position)
                self.game_state.game_world.items_on_ground.append(
                    item_on_ground)
                loot_center_pos = (loot_position[0] + ITEM_ENTITY_SIZE[0] // 2,
                                   loot_position[1] + ITEM_ENTITY_SIZE[1] // 2)
                self.game_state.game_world.visual_effects.append(
                    VisualCircle((170, 200, 170), loot_center_pos, 30, 40,
                                 Millis(500), 2))
                self.game_state.game_world.visual_effects.append(
                    VisualCircle((70, 100, 70), loot_center_pos, 25, 35,
                                 Millis(500), 2))
            elif isinstance(loot_entry, ConsumableLootEntry):
                consumable_on_ground = create_consumable_on_ground(
                    loot_entry.consumable_type, loot_position)
                self.game_state.game_world.consumables_on_ground.append(
                    consumable_on_ground)
Beispiel #6
0
 def deserialize(data) -> MoneyPileOnGround:
     return create_money_pile_on_ground(data["amount"], data["position"])