4
Copyright (C) 2005-2009 Julien Jorge, Sebastien Angibaud
4
Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
6
6
This program is free software; you can redistribute it and/or modify it
7
7
under the terms of the GNU General Public License as published by the
59
57
ptb::link_on_players::link_on_players( const link_on_players& that )
60
58
: super(that), m_strength(that.m_strength),
61
59
m_minimal_length(that.m_minimal_length),
62
m_maximal_length(that.m_maximal_length), m_off(that.m_off),
63
m_single(that.m_single), m_all(that.m_all), m_current_sprite(&m_off),
60
m_maximal_length(that.m_maximal_length),
64
61
m_link_visual(NULL)
66
63
if (that.m_link_visual != NULL)
79
76
/*----------------------------------------------------------------------------*/
81
* \brief Load the resources needed by this item.
83
void ptb::link_on_players::pre_cache()
86
get_level_globals().load_image("gfx/coop/linker.png");
87
} // link_on_players::pre_cache()
89
/*----------------------------------------------------------------------------*/
91
* \brief Initialise the item.
93
void ptb::link_on_players::build()
97
m_off = get_level_globals().auto_sprite("gfx/coop/linker.png", "off");
98
m_single = get_level_globals().auto_sprite("gfx/coop/linker.png", "single");
99
m_all = get_level_globals().auto_sprite("gfx/coop/linker.png", "all");
101
m_current_sprite = &m_off;
102
} // link_on_players::pre_cache()
104
/*----------------------------------------------------------------------------*/
106
* \brief Do one step in the progression of the item.
107
* \param elapsed_time Elapsed time since the last call.
109
void ptb::link_on_players::progress( bear::universe::time_type elapsed_time )
111
m_current_sprite = &m_off;
113
super::progress(elapsed_time);
114
} // link_on_players::progress()
116
/*----------------------------------------------------------------------------*/
118
* \brief Get the sprite representing the item.
119
* \param visuals (out) The sprites of the item, and their positions.
121
void ptb::link_on_players::get_visual
122
( std::list<bear::engine::scene_visual>& visuals ) const
124
super::get_visual( visuals );
126
add_visual( *m_current_sprite, visuals );
127
} // link_on_players::get_visual()
129
/*----------------------------------------------------------------------------*/
131
78
* \brief Set a field of type <real>.
132
79
* \param name The name of the field.
133
80
* \param value The new value of the field.
189
136
/*----------------------------------------------------------------------------*/
191
* \brief One player is colliding with the item.
192
* \param p The player.
194
void ptb::link_on_players::on_one_player( plee* p )
196
m_current_sprite = &m_single;
197
} // link_on_players::on_one_player()
199
/*----------------------------------------------------------------------------*/
201
138
* \brief All players are colliding with the item.
202
139
* \param p1 The first player.
203
140
* \param p2 The second player.
205
void ptb::link_on_players::on_all_players( plee* p1, plee* p2 )
142
void ptb::link_on_players::on_all_players( player* p1, player* p2 )
207
144
// all players does not mean two players in single player game.
208
145
if ( (p1 != NULL) && (p2 != NULL) )
210
m_current_sprite = &m_all;
212
147
if ( !p1->is_linked_to(*p2) )
214
149
bear::universe::link* link