void
FlipLevelTransformer::transform_sector(Sector* sector)
{
  float height = sector->get_height();

  for(Sector::GameObjects::iterator i = sector->gameobjects.begin();
      i != sector->gameobjects.end(); ++i) {
    GameObject* object = *i;

    TileMap* tilemap = dynamic_cast<TileMap*> (object);
    if(tilemap) {
      transform_tilemap(height, tilemap);
    }
    Player* player = dynamic_cast<Player*> (object);
    if(player) {
      Vector pos = player->get_pos();
      pos.y = height - pos.y - player->get_bbox().get_height();
      player->move(pos);
      continue;
    }
    BadGuy* badguy = dynamic_cast<BadGuy*> (object);
    if(badguy) {
      transform_badguy(height, badguy);
    }
    Flower* flower = dynamic_cast<Flower*> (object);
    if(flower) {
      transform_flower(flower);
    }
    Platform* platform = dynamic_cast<Platform*> (object);
    if(platform) {
      transform_platform(height, *platform);
    }
    Block* block = dynamic_cast<Block*> (object);
    if(block) {
      transform_block(height, *block);
    }
    MovingObject* mobject = dynamic_cast<MovingObject*> (object);
    if(mobject) {
      transform_moving_object(height, mobject);
    }
  }
  for(Sector::SpawnPoints::iterator i = sector->spawnpoints.begin();
      i != sector->spawnpoints.end(); ++i) {
    transform_spawnpoint(height, *i);
  }

  if(sector->camera != 0 && sector->player != 0)
    sector->camera->reset(sector->player->get_pos());
}
예제 #2
0
void
FlipLevelTransformer::transform_sector(Sector* sector)
{
  float height = sector->get_height();

  for(auto& object : sector->get_objects()) {
    auto tilemap = dynamic_cast<TileMap*>(object.get());
    if(tilemap) {
      transform_tilemap(height, *tilemap);
    }
    auto player = dynamic_cast<Player*>(object.get());
    if(player) {
      Vector pos = player->get_pos();
      pos.y = height - pos.y - player->get_bbox().get_height();
      player->move(pos);
      continue;
    }
    auto badguy = dynamic_cast<BadGuy*>(object.get());
    if(badguy) {
      transform_badguy(height, *badguy);
    }
    auto flower = dynamic_cast<Flower*>(object.get());
    if(flower) {
      transform_flower(*flower);
    }
    auto platform = dynamic_cast<Platform*>(object.get());
    if(platform) {
      transform_platform(height, *platform);
    }
    auto block = dynamic_cast<Block*>(object.get());
    if(block) {
      transform_block(height, *block);
    }
    auto mobject = dynamic_cast<MovingObject*>(object.get());
    if(mobject) {
      transform_moving_object(height, *mobject);
    }
  }
  for(auto& spawnpoint : sector->m_spawnpoints) {
    transform_spawnpoint(height, *spawnpoint);
  }

  if(sector->m_camera != nullptr && sector->m_player != nullptr)
    sector->m_camera->reset(sector->m_player->get_pos());
}