A bit better formatting in world status
This commit is contained in:
parent
507d9566a0
commit
47b46558f2
@ -44,7 +44,9 @@ WorldStatus::WorldStatus()
|
||||
m_play_racestart_sounds = true;
|
||||
|
||||
IrrlichtDevice *device = irr_driver->getDevice();
|
||||
if (device->getTimer()->isStopped()) device->getTimer()->start();
|
||||
|
||||
if (device->getTimer()->isStopped())
|
||||
device->getTimer()->start();
|
||||
} // WorldStatus
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -56,13 +58,15 @@ void WorldStatus::reset()
|
||||
m_auxiliary_timer = 0.0f;
|
||||
// Using SETUP_PHASE will play the track into sfx first, and has no
|
||||
// other side effects.
|
||||
m_phase = UserConfigParams::m_race_now ? RACE_PHASE : SETUP_PHASE;
|
||||
m_phase = UserConfigParams::m_race_now ? RACE_PHASE : SETUP_PHASE;
|
||||
m_previous_phase = UNDEFINED_PHASE;
|
||||
// Just in case that the game is reset during the intro phase
|
||||
m_track_intro_sound->stop();
|
||||
|
||||
IrrlichtDevice *device = irr_driver->getDevice();
|
||||
if (device->getTimer()->isStopped()) device->getTimer()->start();
|
||||
|
||||
if (device->getTimer()->isStopped())
|
||||
device->getTimer()->start();
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -74,7 +78,9 @@ WorldStatus::~WorldStatus()
|
||||
sfx_manager->deleteSFX(m_start_sound);
|
||||
sfx_manager->deleteSFX(m_track_intro_sound);
|
||||
IrrlichtDevice *device = irr_driver->getDevice();
|
||||
if (device->getTimer()->isStopped()) device->getTimer()->start();
|
||||
|
||||
if (device->getTimer()->isStopped())
|
||||
device->getTimer()->start();
|
||||
} // ~WorldStatus
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -96,14 +102,12 @@ void WorldStatus::setClockMode(const ClockType mode, const float initial_time)
|
||||
void WorldStatus::enterRaceOverState()
|
||||
{
|
||||
// Don't enter race over if it's already race over
|
||||
if( m_phase == DELAY_FINISH_PHASE
|
||||
|| m_phase == RESULT_DISPLAY_PHASE
|
||||
|| m_phase == FINISH_PHASE )
|
||||
if (m_phase == DELAY_FINISH_PHASE || m_phase == RESULT_DISPLAY_PHASE ||
|
||||
m_phase == FINISH_PHASE)
|
||||
return;
|
||||
|
||||
m_phase = DELAY_FINISH_PHASE;
|
||||
m_auxiliary_timer = 0.0f;
|
||||
|
||||
} // enterRaceOverState
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -120,7 +124,7 @@ void WorldStatus::terminateRace()
|
||||
*/
|
||||
void WorldStatus::update(const float dt)
|
||||
{
|
||||
switch(m_phase)
|
||||
switch (m_phase)
|
||||
{
|
||||
// Note: setup phase must be a separate phase, since the race_manager
|
||||
// checks the phase when updating the camera: in the very first time
|
||||
@ -148,7 +152,9 @@ void WorldStatus::update(const float dt)
|
||||
if (UserConfigParams::m_artist_debug_mode &&
|
||||
race_manager->getNumberOfKarts() == 1 &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
{
|
||||
m_auxiliary_timer += dt * 6;
|
||||
}
|
||||
|
||||
// Work around a bug that occurred on linux once:
|
||||
// the sfx_manager kept on reporting that it is playing,
|
||||
@ -156,61 +162,86 @@ void WorldStatus::update(const float dt)
|
||||
// ... phase. Since the sound effect is about 3 seconds
|
||||
// long, we use the aux timer to force the next phase
|
||||
// after 3.5 seconds.
|
||||
if(m_track_intro_sound->getStatus()==SFXManager::SFX_PLAYING
|
||||
&& m_auxiliary_timer<3.5f)
|
||||
if (m_track_intro_sound->getStatus() == SFXManager::SFX_PLAYING &&
|
||||
m_auxiliary_timer < 3.5f)
|
||||
return;
|
||||
|
||||
// Wait before ready phase if sounds are disabled
|
||||
if(!UserConfigParams::m_sfx && m_auxiliary_timer<3.0f)
|
||||
if (!UserConfigParams::m_sfx && m_auxiliary_timer < 3.0f)
|
||||
return;
|
||||
|
||||
m_auxiliary_timer = 0.0f;
|
||||
if (m_play_racestart_sounds) m_prestart_sound->play();
|
||||
|
||||
if (m_play_racestart_sounds)
|
||||
m_prestart_sound->play();
|
||||
|
||||
m_phase = READY_PHASE;
|
||||
for(unsigned int i=0; i<World::getWorld()->getNumKarts(); i++)
|
||||
|
||||
for (unsigned int i = 0; i < World::getWorld()->getNumKarts(); i++)
|
||||
{
|
||||
World::getWorld()->getKart(i)->startEngineSFX();
|
||||
}
|
||||
|
||||
break;
|
||||
case READY_PHASE:
|
||||
if(m_auxiliary_timer>1.0)
|
||||
if (m_auxiliary_timer > 1.0)
|
||||
{
|
||||
if (m_play_racestart_sounds) m_prestart_sound->play();
|
||||
m_phase=SET_PHASE;
|
||||
if (m_play_racestart_sounds)
|
||||
{
|
||||
m_prestart_sound->play();
|
||||
}
|
||||
|
||||
m_phase = SET_PHASE;
|
||||
}
|
||||
|
||||
m_auxiliary_timer += dt;
|
||||
|
||||
// In artist debug mode, when without opponents, skip the ready/set/go counter faster
|
||||
if (UserConfigParams::m_artist_debug_mode &&
|
||||
race_manager->getNumberOfKarts() == 1 &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
{
|
||||
m_auxiliary_timer += dt*6;
|
||||
}
|
||||
|
||||
return;
|
||||
case SET_PHASE :
|
||||
if(m_auxiliary_timer>2.0)
|
||||
case SET_PHASE:
|
||||
if (m_auxiliary_timer > 2.0)
|
||||
{
|
||||
// set phase is over, go to the next one
|
||||
m_phase=GO_PHASE;
|
||||
if (m_play_racestart_sounds) m_start_sound->play();
|
||||
m_phase = GO_PHASE;
|
||||
if (m_play_racestart_sounds)
|
||||
{
|
||||
m_start_sound->play();
|
||||
}
|
||||
|
||||
World::getWorld()->getTrack()->startMusic();
|
||||
|
||||
// event
|
||||
onGo();
|
||||
}
|
||||
|
||||
m_auxiliary_timer += dt;
|
||||
|
||||
// In artist debug mode, when without opponents, skip the ready/set/go counter faster
|
||||
if (UserConfigParams::m_artist_debug_mode &&
|
||||
race_manager->getNumberOfKarts() == 1 &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
{
|
||||
m_auxiliary_timer += dt*6;
|
||||
}
|
||||
|
||||
return;
|
||||
case GO_PHASE :
|
||||
|
||||
if (m_auxiliary_timer>2.5f && music_manager->getCurrentMusic())
|
||||
music_manager->startMusic(music_manager->getCurrentMusic());
|
||||
|
||||
if(m_auxiliary_timer>3.0f) // how long to display the 'go' message
|
||||
{
|
||||
m_phase=MUSIC_PHASE;
|
||||
music_manager->startMusic(music_manager->getCurrentMusic());
|
||||
}
|
||||
|
||||
if (m_auxiliary_timer > 3.0f) // how long to display the 'go' message
|
||||
{
|
||||
m_phase = MUSIC_PHASE;
|
||||
}
|
||||
|
||||
m_auxiliary_timer += dt;
|
||||
@ -219,31 +250,38 @@ void WorldStatus::update(const float dt)
|
||||
if (UserConfigParams::m_artist_debug_mode &&
|
||||
race_manager->getNumberOfKarts() == 1 &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
{
|
||||
m_auxiliary_timer += dt*6;
|
||||
}
|
||||
|
||||
break;
|
||||
case MUSIC_PHASE:
|
||||
// how long to display the 'music' message
|
||||
if(m_auxiliary_timer>stk_config->m_music_credit_time)
|
||||
m_phase=RACE_PHASE;
|
||||
if (m_auxiliary_timer>stk_config->m_music_credit_time)
|
||||
{
|
||||
m_phase = RACE_PHASE;
|
||||
}
|
||||
|
||||
m_auxiliary_timer += dt;
|
||||
break;
|
||||
case RACE_PHASE:
|
||||
// Nothing to do for race phase, switch to delay finish phase
|
||||
// happens when
|
||||
break;
|
||||
case DELAY_FINISH_PHASE :
|
||||
case DELAY_FINISH_PHASE:
|
||||
{
|
||||
m_auxiliary_timer += dt;
|
||||
|
||||
// Change to next phase if delay is over
|
||||
if(m_auxiliary_timer > stk_config->m_delay_finish_time)
|
||||
if (m_auxiliary_timer > stk_config->m_delay_finish_time)
|
||||
{
|
||||
m_phase = RESULT_DISPLAY_PHASE;
|
||||
terminateRace();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case RESULT_DISPLAY_PHASE :
|
||||
case RESULT_DISPLAY_PHASE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -256,7 +294,7 @@ void WorldStatus::update(const float dt)
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(m_clock_mode)
|
||||
switch (m_clock_mode)
|
||||
{
|
||||
case CLOCK_CHRONO:
|
||||
m_time += dt;
|
||||
@ -297,11 +335,14 @@ void WorldStatus::setTime(const float time)
|
||||
*/
|
||||
void WorldStatus::pause(Phase phase)
|
||||
{
|
||||
assert(m_previous_phase==UNDEFINED_PHASE);
|
||||
assert(m_previous_phase == UNDEFINED_PHASE);
|
||||
|
||||
m_previous_phase = m_phase;
|
||||
m_phase = phase;
|
||||
IrrlichtDevice *device = irr_driver->getDevice();
|
||||
if (!device->getTimer()->isStopped()) device->getTimer()->stop();
|
||||
|
||||
if (!device->getTimer()->isStopped())
|
||||
device->getTimer()->stop();
|
||||
} // pause
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -314,5 +355,7 @@ void WorldStatus::unpause()
|
||||
// in pause to detect incorrect pause/unpause sequences.
|
||||
m_previous_phase = UNDEFINED_PHASE;
|
||||
IrrlichtDevice *device = irr_driver->getDevice();
|
||||
if (device->getTimer()->isStopped()) device->getTimer()->start();
|
||||
|
||||
if (device->getTimer()->isStopped())
|
||||
device->getTimer()->start();
|
||||
} // unpause
|
||||
|
Loading…
x
Reference in New Issue
Block a user