return;
end_sequence = ENDSEQUENCE_RUNNING;
- endsequence_timer.start(level->extro_length); // 7 seconds until we finish the map
+ endsequence_timer.start(level->extro_length);
last_x_pos = -1;
sound_manager->play_music("music/" + level->extro_music, false);
currentsector->player->invincible_timer.start(level->extro_length);
+ // Stop all clocks.
+ for(std::vector<GameObject*>::iterator i = currentsector->gameobjects.begin();
+ i != currentsector->gameobjects.end(); ++i)
+ {
+ GameObject* obj = *i;
+
+ LevelTime* lt = dynamic_cast<LevelTime*> (obj);
+ if(lt)
+ lt->stop();
+ }
+
if(sequencename == "fireworks") {
currentsector->add_object(new Fireworks());
}
static const float TIME_WARNING = 20;
LevelTime::LevelTime(const lisp::Lisp& reader)
+: final_level_time(0.f), final_remaining_time(0.f)
{
float time = -1;
lisp::ListIterator iter(&reader);
char str[60];
- if(time_left.get_timeleft() < 0) {
+ if(get_remaining_time() < 0) {
context.draw_text(white_text, _("TIME's UP"), Vector(SCREEN_WIDTH/2, BORDER_Y),
CENTER_ALLIGN, LAYER_FOREGROUND1);
- } else if (time_left.get_timeleft() > TIME_WARNING
+ } else if (get_remaining_time() > TIME_WARNING
|| int(game_time * 2.5) % 2) {
- snprintf(str, sizeof(str), " %d", int(time_left.get_timeleft()));
+ snprintf(str, sizeof(str), " %d", int(get_remaining_time()));
context.draw_text(white_text, _("TIME"),
Vector(SCREEN_WIDTH/2, BORDER_Y), CENTER_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2 + 4*16, BORDER_Y),
float
LevelTime::get_level_time()
{
+ if (!time_left.started())
+ return final_level_time;
return time_left.get_period();
}
float
LevelTime::get_remaining_time()
{
+ if (!time_left.started())
+ return final_remaining_time;
return time_left.get_timeleft();
}
+void
+LevelTime::stop()
+{
+ final_level_time = time_left.get_period();
+ final_remaining_time = time_left.get_timeleft();
+ time_left.stop();
+}
+
IMPLEMENT_FACTORY(LevelTime, "leveltime");