+ return;
+ }
+
+ // abort if a sequence is already playing
+ if (end_sequence) return;
+
+ if (sequencename == "endsequence") {
+
+ // Determine walking direction for Tux
+ /*float xst = 1.f, xend = 2.f;
+ for(std::vector<GameObject*>::iterator i = currentsector->gameobjects.begin(); i != currentsector->gameobjects.end(); i++) {
+ SequenceTrigger* st = dynamic_cast<SequenceTrigger*>(*i);
+ if(!st)
+ continue;
+ if(st->get_sequence_name() == "stoptux")
+ xend = st->get_pos().x;
+ else if(st->get_sequence_name() == "endsequence")
+ xst = st->get_pos().y;
+ }
+
+ if (xst > xend) {
+ end_sequence = new EndSequenceWalkLeft();
+ } else {
+ end_sequence = new EndSequenceWalkRight();
+ }*/
+ if (currentsector->get_players()[0]->physic.get_velocity_x() < 0) {
+ end_sequence = new EndSequenceWalkLeft();
+ } else {
+ end_sequence = new EndSequenceWalkRight();
+ }
+ }
+ else if (sequencename == "fireworks") end_sequence = new EndSequenceFireworks();
+ else {
+ log_warning << "Unknown sequence '" << sequencename << "'. Ignoring." << std::endl;
+ return;
+ }
+
+ currentsector->add_object(end_sequence);
+ end_sequence->start();
+
+ sound_manager->play_music("music/leveldone.ogg", false);
+ currentsector->player->invincible_timer.start(10000.0f);
+
+ // 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();