예제 #1
0
파일: tnt.cpp 프로젝트: fcjailybo/asgp
/**
 * \brief Load the media required by this class.
 */
void rp::tnt::pre_cache()
{
  super::pre_cache();
  
  get_level_globals().load_model("model/tnt.cm");
  get_level_globals().load_animation("animation/explosion.canim");
} // rp::tnt::pre_cache()
예제 #2
0
/**
 * \brief Load the media required by this class.
 */
void ptb::gorilla::pre_cache()
{
  get_level_globals().load_animation
    ("animation/forest/gorilla/gorilla_soul.canim");
  get_level_globals().load_model("model/forest/gorilla.cm");
  get_level_globals().load_model("model/headstone.cm");
} // gorilla::pre_cache()
예제 #3
0
파일: bonus.cpp 프로젝트: fcjailybo/asgp
/**
 * \brief Load the resources needed by this item.
 */
void rp::bonus::pre_cache()
{
    super::pre_cache();

    set_phantom(true);
    get_level_globals().load_model("model/bonus.cm");
    get_level_globals().load_sound("sound/bwow.ogg");
} // bonus::pre_cache()
예제 #4
0
/**
 * \brief Search players.
 */
void ptb::shared_camera::search_players()
{
  if ( m_first_player == NULL )
    m_first_player = util::find_player( get_level_globals(), 1 );

  if ( m_second_player == NULL )
    m_second_player = util::find_player( get_level_globals(), 2 );
} // shared_camera::search_players()
/**
 * \brief Search players.
 */
void ptb::hideout_revealing::search_players()
{
  if ( m_first_player == NULL )
    m_first_player = util::find_player( get_level_globals(), 1 );

  if ( m_second_player == NULL )
    m_second_player = util::find_player( get_level_globals(), 2 );
} // hideout_revealing::search_players()
예제 #6
0
/**
 * \brief Load the resources required by this item.
 */
void ptb::power_effect::pre_cache()
{
  get_level_globals().load_animation("animation/effect/power/air_effect.canim");
  get_level_globals().load_animation
    ("animation/effect/power/fire_effect.canim");
  get_level_globals().load_animation
    ("animation/effect/power/water_effect.canim");
} // power_effect::pre_cache()
/**
 * \brief Do one step in the progression of the layer.
 * \param elapsed_time Elapsed time since the last call.
 */
void
ptb::player_arrows_layer::progress( bear::universe::time_type elapsed_time )
{
  search_players();

  if ( m_data_1 != NULL )
    m_data_1->adjust_arrow
      (get_level_globals(), get_level().get_camera_focus() );

  if ( m_data_2 != NULL )
    m_data_2->adjust_arrow
      (get_level_globals(), get_level().get_camera_focus() );
} // player_arrows_layer::progress()
예제 #8
0
/**
 * \brief Send a notification on status layer when the honeypot is found.
 * \param index Index of player that finds honeypot. 
 */
void ptb::honeypot::send_notification(unsigned int index)
{
  std::ostringstream s;
  s << "honeypot " << m_id;
  std::string name(s.str());

  status_layer_notification_message msg;

  bear::visual::sprite sp = 
    get_level_globals().auto_sprite
    ( "gfx/ui/bonus-icons/bonus-icons.png", name );
  msg.set_notification( index, sp, gettext(name.c_str()));

  get_level_globals().send_message
    ( PTB_STATUS_LAYER_DEFAULT_TARGET_NAME, msg );
} // honeypot::send_notification()
예제 #9
0
/**
 * \brief Initialize the component.
 */
void tunnel::energy_component::build()
{
  m_sprite =
    get_level_globals().auto_sprite( "gfx/status/status.png", "heart" );

  super::build();
} // energy_component::build()
/**
 * \brief Initialize the component.
 */
void ptb::honeypots_component::build()
{
  m_honeypot = 
    get_level_globals().auto_sprite("gfx/ui/status/status.png", "shiny jar");
   
  super::build();
} // honeypots_component::build()
/**
 * \brief Render the players oxygen.
 * \param e (out) The scene elements.
 */
void ptb::throwable_item_component::render( scene_element_list& e ) const
{
  bear::visual::coordinate_type pos_y = height() / 2;

  bear::visual::scene_sprite s1
    ( get_render_position().x, 
      ( pos_y - m_throwable_item_animation.get_sprite().height() ) / 2 + 
      get_render_position().y, 
      m_throwable_item_animation.get_sprite());

  bear::visual::scene_writing s2
    ( get_render_position().x + 
      m_throwable_item_animation.get_max_size().x + s_margin, 
      ( pos_y - m_throwable_item.get_height() ) / 2 + 
      get_render_position().y , m_throwable_item );

  e.push_back( s1 );
  e.push_back( s2 );

  floating_bonus_list::const_iterator it;
  for ( it = m_floating_bonus.begin(); 
	it != m_floating_bonus.end(); ++it )
    {
      bear::visual::scene_sprite sp2
	( it->get_position().x, it->get_position().y, 
          get_level_globals().auto_sprite( "gfx/ui/ui-1.png", it->get_name() ));
      e.push_back( sp2 );
    } 
} // throwable_item_component::render()
/**
 * \brief The fonction called when there is a new bonus.
 * \param animation The name of the new bonus. */
void ptb::throwable_item_component::create_floating_bonus
( const std::string& name )
{
  bear::visual::animation anim =
    get_level_globals().auto_sprite( "gfx/ui/ui-1.png", name );

  bear::visual::position_type rate(0,0);
  if ( get_player() != NULL )
    {
      rate.x = 
        ( get_player().get_left() - 
          get_player().get_level().get_camera_center().x) /
        get_player().get_level().get_camera()->get_width();
      rate.y = 
        ( get_player().get_bottom() - 
          get_player().get_level().get_camera_center().y) /
        get_player().get_level().get_camera()->get_height();
    }

  bear::visual::position_type pos(get_layer_size()/2);
  pos.x += ( rate.x * get_layer_size().x);
  pos.y += ( rate.y * get_layer_size().y);
  
  if ( ( pos.x <= get_layer_size().x ) && ( pos.y <= get_layer_size().y ) && 
       ( pos.x + anim.width() >= 0 ) && 
       ( pos.y + anim.height() >= 0 ) )
    {
      floating_bonus f(name);

      m_floating_bonus.push_back(f);
      m_floating_bonus.back().set_position
        ( pos - anim.get_size()/2, 
          get_render_position() - anim.get_size()/2);
    }
} // throwable_item_component::create_floating_bonus
/**
 * \brief The fonction called when the throwable item changes.
 * \param animation The new animation */
void ptb::throwable_item_component::on_throwable_item_changed
( const std::string& animation )
{
  m_throwable_item_animation = get_level_globals().get_animation( animation );
  update_inactive_position();
  on_throwable_item_changed();
} // throwable_item_component::on_throwable_item_changed()
/**
 * \brief Send a notification on status layer.
 * \param index Index of player that discovers hideout. 
 * \param found Number of found hideout.
 * \param total Number of hideout.
 */
void ptb::hideout_bonus_item::send_notification
(unsigned int index, unsigned int found, unsigned int total)
{
  status_layer_notification_message msg;
  
  std::ostringstream oss;
  oss << gettext("Great explorer") << " " 
      << found << "/" << total;

  bear::visual::sprite sp = 
    get_level_globals().auto_sprite
    ( "gfx/ui/bonus-icons/bonus-icons.png", "hideouts" );
  msg.set_notification( index, sp, oss.str());

  get_level_globals().send_message
    ( PTB_STATUS_LAYER_DEFAULT_TARGET_NAME, msg );
} // hideout_bonus_item::send_notification()
예제 #15
0
/**
 * \brief Initialise the item.
 */
void ptb::gorilla::on_enters_layer()
{
  super::on_enters_layer();

  set_model_actor( get_level_globals().get_model("model/forest/gorilla.cm") );
  start_model_action("idle");
  m_progress = &gorilla::progress_idle;
} // gorilla::on_enters_layer()
예제 #16
0
/**
 * \brief Scan if there is a player in a given direction.
 * \param left_orientation True if the orientation is toward the left.
 * \param distance The distance of scan.
 */
bool ptb::gorilla::scan
( bool left_orientation, bear::universe::coordinate_type distance ) const
{
  bool result = false;

  player_proxy p1 = util::find_player( get_level_globals(), 1 );
  player_proxy p2 = util::find_player( get_level_globals(), 2 );

  if( p1 != NULL )
    result =
      scan_for_player(p1, left_orientation, distance);

  if ( !result && (p2 != NULL) )
    result =
      scan_for_player(p2, left_orientation, distance);

  return result;
} // gorilla::scan()
예제 #17
0
파일: bonus.cpp 프로젝트: fcjailybo/asgp
/**
 * \brief Give the bonus.
 * \param c The cart of the collision.
 */
void rp::bonus::give_bonus( cart* c )
{
    if ( m_type == cart_element )
        c->give_element();
    else if ( m_type == plunger )
        c->give_plunger_bonus();

    get_level_globals().play_sound("sound/bwow.ogg");
} // bonus::give_bonus()
예제 #18
0
파일: tnt.cpp 프로젝트: fcjailybo/asgp
/**
 * \brief Do post creation actions.
 */
void rp::tnt::on_enters_layer()
{
  super::on_enters_layer();

  m_explosed = false;
  set_mass(100);
  set_model_actor( get_level_globals().get_model("model/tnt.cm") );
  start_model_action("idle");
} // rp::tnt::on_enters_layer()
예제 #19
0
/**
 * \brief The toggle is activated, pause the gamex.
 * \param activator The item who activated this toggle.
 */
void rp::pause_game::on_toggle_on
( bear::engine::base_item* activator )
{
  super::on_toggle_on(activator);

  pause_message msg;
      
  get_level_globals().send_message( m_layer_name, msg );
} // pause_game::on_toggle_on()
/**
 * \brief Do one step in the progression of the item.
 * \param elapsed_time Elapsed time since the last call.
 */
void ptb::add_players_camera::progress
( bear::universe::time_type elapsed_time )
{
  if ( m_camera )
    {
      player_proxy p = util::find_player( get_level_globals(), 1 );

      if ( p!=NULL )
        m_camera->add_item(p.get_player_instance());

      p = util::find_player( get_level_globals(), 2 );

      if ( p!=NULL )
        m_camera->add_item(p.get_player_instance());
    }

  kill();
} // add_players_camera::progress()
예제 #21
0
/**
 * \brief Initialise the item.
 */
void ptb::friend_ghost::on_enters_layer()
{
  super::on_enters_layer();

  set_model_actor
    ( get_level_globals().get_model("model/castle/friend_ghost.cm") );
  start_model_action("wait");
  set_origin();
} // friend_ghost::on_enters_layer()
예제 #22
0
/**
 * \brief Initialize the component.
 */
void rp::boss_component::build()
{
  m_sprite =
    get_level_globals().auto_sprite( "gfx/boss/lady.png", "lady middle" );

  const double r = m_sprite.width() / m_sprite.height();
  m_sprite.set_height( 44 );
  m_sprite.set_width( m_sprite.height() * r );

  super::build();
} // boss_component::build()
/**
 * \brief Function called when the toggle is activated.
 * \param activator The activator of the toggle.
 */
void ptb::level_score_record::on_toggle_on(bear::engine::base_item *activator)
{
  const double value = m_value.evaluate();
  const std::string medal( m_score_table.get_medal_name( value ) );

  score_message msg
    ( m_score_table, value, medal, m_score_format,
      game_variables::get_string_default(m_next_level) );
  get_level_globals().send_message
    ( game_variables::get_string_default(m_window_layer), msg );
} // level_score_record::on_toggle_on()
예제 #24
0
파일: zeppelin.cpp 프로젝트: fcjailybo/asgp
/**
 * \brief Do post creation actions.
 */
void rp::zeppelin::on_enters_layer()
{
  super::on_enters_layer();

  if ( get_rendering_attributes().is_mirrored() )
    {
      get_rendering_attributes().mirror(false);
      set_model_actor
        ( get_level_globals().get_model("model/zeppelin/zeppelin-mirror.cm") );
    }
  else
     set_model_actor
      ( get_level_globals().get_model("model/zeppelin/zeppelin.cm") );

  start_model_action("idle");

  if ( m_item != NULL )
    create_item();

  create_interactive_item(*this, 1.5);
} // rp::zeppelin::on_enters_layer()
예제 #25
0
파일: bonus.cpp 프로젝트: fcjailybo/asgp
/**
 * \brief Init mark in cart_element action.
 * \param name The name of the mark.
 */
void rp::bonus::init_mark( const std::string& name )
{
    bear::engine::model_mark_placement element;

    if ( get_mark_placement( name, element ) )
        set_global_substitute
        ( name,
          new bear::visual::animation
          ( get_level_globals().auto_sprite
            ( "gfx/cart-theme/"+ game_variables::get_level_theme()+".png",
              name ) ) );
} // bonus::init_mark()
/**
 * \brief Search players.
 */
void ptb::player_arrows_layer::search_players( )
{
  if ( m_data_1 == NULL )
    {
      player_proxy p( util::find_player( get_level_globals(), 1 ) );

      if ( p != NULL )
        m_data_1 = new player_data
          ( get_size(), p,
            get_level_globals().auto_sprite
            ("gfx/ui/status/status.png", "arrow 1"),
            get_level_globals().get_font("font/Fava-black.ttf", 30) );
    }

  if ( game_variables::get_players_count() == 2 )
    if ( m_data_2 == NULL )
      {
        player_proxy p( util::find_player( get_level_globals(), 2 ) );

        if ( p != NULL )
          m_data_2 = new player_data
            ( get_size(), p,
              get_level_globals().auto_sprite
              ("gfx/ui/status/status.png", "arrow 2"),
              get_level_globals().get_font("font/Fava-black.ttf", 30) );
      }
} // player_arrows_layer::search_players( )
예제 #27
0
/**
 * \brief Initialize the item.
 */
void rp::switching::on_enters_layer()
{
  super::on_enters_layer();

  set_model_actor( get_level_globals().get_model("model/switching.cm") );
  start_model_action(m_initial_state);
   
  bear::engine::model_mark_placement mark;

  if ( get_mark_placement("sign", mark) )
    create_interactive_item
        (*this, 0.25, 0, mark.get_position() - get_center_of_mass() );
} // rp::switching::on_enters_layer()
예제 #28
0
파일: cursor.cpp 프로젝트: fcjailybo/asgp
/**
 * \brief Do post creation actions.
 */
void rp::cursor::on_enters_layer()
{
  super::on_enters_layer();  

  if ( ! m_sprite.is_valid() )
    {
      m_sprite = 
        get_level_globals().auto_sprite( "gfx/status/cursor.png", "default" );
      set_size( m_sprite.get_size() );
    }

  m_target_position = get_center_of_mass();
} // cursor::on_enters_layer()
/**
 * \brief Initialize the component.
 */
void ptb::corrupting_bonus_component::build()
{
  std::ostringstream oss;
  oss << game_variables::get_corrupting_bonus_count();
  m_text_corrupting_bonus.create(m_font, oss.str());
  m_text_corrupting_bonus->set_intensity(1, 0.8, 0);
  m_last_corrupting_bonus_count = game_variables::get_corrupting_bonus_count();

  m_corrupting_bonus =
    get_level_globals().get_animation("animation/corrupting-bonus.canim");
  m_corrupting_bonus.set_size( m_corrupting_bonus.get_size() / 2 );

  super::build();
} // corrupting_bonus_component::build()
예제 #30
0
/**
 * \brief Create  components.
 */
void tunnel::status_layer::create_components()
{
  // ############## BOTTOM RIGHT #########################
  bear::visual::position_type pos_top( s_margin, get_size().y - s_margin );

  // score  
  energy_component* e = new energy_component
    (get_level_globals(), pos_top, bear::universe::zone::top_zone, 
     status_component::left_placement,
     status_component::top_placement,get_size(),
     200, false); 
  e->build();
  m_components.push_back(e);
  pos_top.y = pos_top.y - e->height() - s_margin;
  
  // crystal  
  crystal_component* c = new crystal_component
    (get_level_globals(), pos_top, bear::universe::zone::top_zone, 
     status_component::left_placement,
     status_component::top_placement,get_size(),
     200, false); 
  c->build();
  m_components.push_back(c);
  pos_top.y = pos_top.y - c->height() - s_margin;

  // lives
  /*
  pos_bottom.x = get_size().x - s_margin;
  status_component* l = new lives_component
    (get_level_globals(), pos_bottom, bear::universe::zone::bottom_zone, 
     status_component::right_placement,
     status_component::bottom_placement,get_size(),
     m_score_background.get_size().y, false); 
  l->build();
  m_components.push_back(l);
  */
} // status_layer::create_components()