87 |
namespace |
namespace |
88 |
{ |
{ |
89 |
PlayerList players; |
PlayerList players; |
90 |
int icurrent_player = 0; |
unsigned icurrent_player = 0; |
91 |
bool current_player_inhibit_pickup = false; |
bool current_player_inhibit_pickup = false; |
92 |
|
|
93 |
} |
} |
94 |
|
|
95 |
void |
void |
284 |
void |
void |
285 |
player::LevelFinished() |
player::LevelFinished() |
286 |
{ |
{ |
287 |
for (unsigned i=0; i<players.size(); ++i) |
for (unsigned i=0; i<players.size(); ++i) { |
|
{ |
|
288 |
for (unsigned j=0; j<players[i].actors.size(); ++j) { |
for (unsigned j=0; j<players[i].actors.size(); ++j) { |
289 |
Actor *a = players[i].actors[j]; |
Actor *a = players[i].actors[j]; |
290 |
SendMessage(a, "disappear"); |
SendMessage(a, "disappear"); |
|
// world::GrabActor(a); |
|
|
// display::ReplaceSprite(a->get_spriteid(), "ring-anim"); |
|
291 |
} |
} |
292 |
} |
} |
293 |
} |
} |
373 |
** Returns true if all actors are dead and they cannot be respawned |
** Returns true if all actors are dead and they cannot be respawned |
374 |
** (i.e., their owners don't have any extra lifes left). |
** (i.e., their owners don't have any extra lifes left). |
375 |
*/ |
*/ |
376 |
bool |
static bool |
377 |
player::AllActorsDead() |
AllPlayersDead() |
378 |
{ |
{ |
379 |
|
bool all_players_dead=true; |
380 |
|
unsigned old_player = icurrent_player; |
381 |
for (unsigned i=0; i<players.size(); ++i) { |
for (unsigned i=0; i<players.size(); ++i) { |
382 |
|
bool actors_dead=true; |
383 |
for (unsigned j=0; j<players[i].actors.size(); ++j) { |
for (unsigned j=0; j<players[i].actors.size(); ++j) { |
384 |
Actor *a = players[i].actors[j]; |
Actor *a = players[i].actors[j]; |
385 |
if (!a->is_dead() || resurrect_actor(i,a)) |
if (!a->is_dead() || resurrect_actor(i,a)) |
386 |
return false; |
all_players_dead = actors_dead = false; |
387 |
|
} |
388 |
|
if (actors_dead && i==icurrent_player) { |
389 |
|
// Switch to next player if this one is dead |
390 |
|
unsigned nextplayer = (icurrent_player+1) % players.size(); |
391 |
|
SetCurrentPlayer (nextplayer); |
392 |
} |
} |
393 |
} |
} |
394 |
return true; |
if (all_players_dead) |
395 |
|
SetCurrentPlayer(old_player); |
396 |
|
return all_players_dead; |
397 |
} |
} |
398 |
|
|
399 |
void |
void |
409 |
|
|
410 |
// Update the respawn list or restart the game when all actors are |
// Update the respawn list or restart the game when all actors are |
411 |
// dead and no extra lifes are left. |
// dead and no extra lifes are left. |
412 |
if (player::AllActorsDead()) { |
if (AllPlayersDead()) { |
413 |
enigma::RestartLevel(); |
enigma::RestartGame(); |
|
// change_state(PLAYERDEAD); |
|
414 |
} |
} |
415 |
} |
} |
416 |
|
|