コード例 #1
0
ファイル: Door.cpp プロジェクト: lambdaloop/solarus
/**
 * @brief Updates the entity.
 */
void Door::update() {

  Detector::update();

  if (!initialized) {
    update_dynamic_tiles();
    initialized = true;
  }

  if (is_closed()
      && get_opening_method() == OPENING_BY_EXPLOSION
      && get_equipment().has_ability("detect_weak_walls")
      && Geometry::get_distance(get_center_point(), get_hero().get_center_point()) < 40
      && !is_suspended()
      && System::now() >= next_hint_sound_date) {
    Sound::play("cane");
    next_hint_sound_date = System::now() + 500;
  }

  if (is_changing() && get_sprite().is_animation_finished()) {
    // Toggle door_open when the changing animation finishes.
    set_open(is_opening());
  }

  if (is_saved() && !is_changing()) {
    bool open_in_savegame = get_savegame().get_boolean(savegame_variable);
    if (open_in_savegame && is_closed()) {
      set_opening();
    }
    else if (!open_in_savegame && is_open()) {
      set_closing();
    }
  }
}
コード例 #2
0
ファイル: Door.cpp プロジェクト: lambdaloop/solarus
/**
 * @brief Makes the door immediately open or closed.
 * @param door_open true to make it opened, false to make it closed.
 */
void Door::set_open(bool door_open) {

  state = door_open ? OPEN : CLOSED;

  if (door_open) {
    set_collision_modes(COLLISION_NONE); // to avoid being the hero's facing entity
  }
  else {
    get_sprite().set_current_animation("closed");
    set_collision_modes(COLLISION_FACING_POINT | COLLISION_SPRITE);

    // ensure that we are not closing the door on the hero
    if (is_on_map() && overlaps(get_hero())) {
      get_hero().avoid_collision(*this, (get_direction() + 2) % 4);
    }
  }

  if (is_on_map()) {
    update_dynamic_tiles();

    if (is_saved()) {
      get_savegame().set_boolean(savegame_variable, door_open);
    }

    if (door_open) {
      get_lua_context().door_on_opened(*this);
    }
    else {
      get_lua_context().door_on_closed(*this);
    }
  }
}
コード例 #3
0
ファイル: Stairs.cpp プロジェクト: joshuarobinson/solarus
/**
 * \brief Notifies this entity that it was just enabled or disabled.
 * \param enabled \c true if the entity is now enabled.
 *
 * All dynamic tiles whose prefix is "stairsname_enabled"
 * and "stairsame_disabled" will be updated depending on the stairs state
 * (where stairsname is the name of the stairs).
 */
void Stairs::notify_enabled(bool enabled) {

  Detector::notify_enabled(enabled);

  update_dynamic_tiles();
}
コード例 #4
0
ファイル: Stairs.cpp プロジェクト: joshuarobinson/solarus
/**
 * \brief Notifies this entity that its map has just become active.
 */
void Stairs::notify_map_started() {

  MapEntity::notify_map_started();
  update_dynamic_tiles();
}
コード例 #5
0
ファイル: Stairs.cpp プロジェクト: Aerospyke/solarus
/**
 * @brief Notifies this entity that it was just enabled or disabled.
 * @param enabled true if the entity is now enabled
 *
 * All dynamic tiles whose prefix is "stairsname_enabled"
 * and "stairsame_disabled" will be updated depending on the stairs state
 * (where stairsname is the name of the stairs).
 */
void Stairs::notify_enabled(bool enabled) {
  update_dynamic_tiles();
}
コード例 #6
0
ファイル: Stairs.cpp プロジェクト: Fordi/Solarus-PSP
/**
 * \copydoc MapEntity::notify_creating
 */
void Stairs::notify_creating() {

  Detector::notify_creating();
  update_dynamic_tiles();
}