Continue after cutscene

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11328 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-06-24 01:22:42 +00:00
parent 1caba55886
commit 3901ea9840
3 changed files with 61 additions and 1 deletions

View File

@ -33,6 +33,8 @@
#include "tracks/track_object.hpp"
#include "utils/ptr_vector.hpp"
#include <algorithm>
class XMLNode;
/**
@ -82,6 +84,21 @@ public:
/** Disables or enables an animation. */
void setPlaying(bool playing) {m_playing = playing; }
// ------------------------------------------------------------------------
float getAnimationDuration() const
{
float duration = -1;
const Ipo* currIpo;
for_in (currIpo, m_all_ipos)
{
duration = std::max(duration, currIpo->getEndTime());
}
return duration;
}
}; // AnimationBase
#endif

View File

@ -21,13 +21,16 @@
#include <IMeshSceneNode.h>
#include <ISceneManager.h>
#include "animations/animation_base.hpp"
#include "audio/music_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "io/file_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_model.hpp"
#include "karts/kart_properties.hpp"
#include "modes/overworld.hpp"
#include "physics/physics.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp"
#include "tracks/track_object.hpp"
@ -52,6 +55,9 @@ CutsceneWorld::CutsceneWorld() : World()
void CutsceneWorld::init()
{
World::init();
m_duration = -1.0f;
//const btTransform &s = getTrack()->getStartTransform(0);
//const Vec3 &v = s.getOrigin();
m_camera = irr_driver->getSceneManager()
@ -84,7 +90,18 @@ void CutsceneWorld::init()
m_sounds_to_trigger[frame / FPS].push_back(curr);
}
}
if (dynamic_cast<AnimationBase*>(curr) != NULL)
{
m_duration = std::max(m_duration, dynamic_cast<AnimationBase*>(curr)->getAnimationDuration());
}
}
if (m_duration <= 0.0f)
{
fprintf(stderr, "[CutsceneWorld] WARNING: cutscene has no duration\n");
}
} // CutsceneWorld
//-----------------------------------------------------------------------------
@ -118,6 +135,19 @@ const std::string& CutsceneWorld::getIdent() const
void CutsceneWorld::update(float dt)
{
m_time += dt;
/*
if (m_time > m_duration)
{
printf("DONE!\n");
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
//OverWorld::enterOverWorld();
return;
}
*/
World::update(dt);
World::updateTrack(dt);
@ -156,12 +186,21 @@ void CutsceneWorld::update(float dt)
}
} // update
//-----------------------------------------------------------------------------
void CutsceneWorld::enterRaceOverState()
{
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
OverWorld::enterOverWorld();
}
//-----------------------------------------------------------------------------
/** The battle is over if only one kart is left, or no player kart.
*/
bool CutsceneWorld::isRaceOver()
{
return false;
return m_time > m_duration;
} // isRaceOver
//-----------------------------------------------------------------------------

View File

@ -40,6 +40,8 @@ class CutsceneWorld : public World
scene::ICameraSceneNode* m_camera;
std::map<float, std::vector<TrackObject*> > m_sounds_to_trigger;
float m_duration;
public:
@ -68,6 +70,8 @@ public:
{
m_race_gui = NULL;
}
virtual void enterRaceOverState() OVERRIDE;
}; // CutsceneWorld