Пример #1
0
void
InfoBlock::hit(Player& player)
{
  start_bounce(&player);

  //if (!stopped) {
  //  ringing->remove_me();
  //  stopped = true;
  //}

  if (dest_pct != 1) {

    // first hide all other InfoBlocks' messages in same sector
    Sector* parent = Sector::current();
    if (!parent) return;
    for (Sector::GameObjects::iterator i = parent->gameobjects.begin(); i != parent->gameobjects.end(); ++i) {
      InfoBlock* block = dynamic_cast<InfoBlock*>(i->get());
      if (!block) continue;
      if (block != this) block->hide_message();
    }

    // show our message
    show_message();

  } else {
    hide_message();
  }
}
Пример #2
0
void
Yeti::drop_stalactite()
{
  // make a stalactite falling down and shake camera a bit
  Sector::current()->camera->shake(.1f, 0, 10);

  Player* player = this->get_nearest_player();
  if (!player) return;

  Sector* sector = Sector::current();
  for(Sector::GameObjects::iterator i = sector->gameobjects.begin();
      i != sector->gameobjects.end(); ++i) {
    YetiStalactite* stalactite = dynamic_cast<YetiStalactite*>(i->get());
    if(stalactite && stalactite->is_hanging()) {
      if (hit_points >= 3) {
        // drop stalactites within 3 of player, going out with each jump
        float distancex = fabsf(stalactite->get_bbox().get_middle().x - player->get_bbox().get_middle().x);
        if(distancex < stomp_count*32) {
          stalactite->start_shaking();
        }
      }
      else { /* if (hitpoints < 3) */
        // drop every 3rd pair of stalactites
        if(((((int)stalactite->get_pos().x + 16) / 64) % 3) == (stomp_count % 3)) {
          stalactite->start_shaking();
        }
      }
    } /* if(stalactite && stalactite->is_hanging()) */
  }
}
Пример #3
0
void
SecretAreaTrigger::event(Player& , EventType type)
{
  if(type == EVENT_TOUCH) {
    if (!message_displayed) {
      message_timer.start(MESSAGE_TIME);
      message_displayed = true;
      Sector::current()->get_level()->stats.secrets++;

      if (fade_tilemap != "") {
        // fade away tilemaps
        Sector& sector = *Sector::current();
        for(Sector::GameObjects::iterator i = sector.gameobjects.begin(); i != sector.gameobjects.end(); ++i) {
          TileMap* tm = dynamic_cast<TileMap*>(i->get());
          if (!tm) continue;
          if (tm->get_name() != fade_tilemap) continue;
          tm->fade(0.0, 1.0);
        }
      }

      if(script != "") {
        std::istringstream stream(script);
        Sector::current()->run_script(stream, "SecretAreaScript");
      }
    }
  }
}
Пример #4
0
void
WeakBlock::spreadHit()
{
  //Destroy adjacent weakblocks if applicable
  if(linked) {
    Sector* sector = Sector::current();
    if (!sector) {
      log_debug << "no current sector" << std::endl;
      return;
    }
    for(Sector::GameObjects::iterator i = sector->gameobjects.begin(); i != sector->gameobjects.end(); ++i) {
      WeakBlock* wb = dynamic_cast<WeakBlock*>(i->get());
      if (!wb) continue;
      if (wb == this) continue;
      if (wb->state != STATE_NORMAL) continue;
      float dx = fabsf(wb->get_pos().x - bbox.p1.x);
      float dy = fabsf(wb->get_pos().y - bbox.p1.y);
      if ((dx <= 32.5) && (dy <= 32.5)) wb->startBurning();
    }
  }
}