Ez2 Checkin. (No song select yet)
This commit is contained in:
@@ -43,15 +43,13 @@ const float PLAYER_OPTIONS_LOCAL_Y[NUM_PLAYERS] = { -10, +10 };
|
||||
const float DIFFICULTY_X[NUM_PLAYERS] = { SCREEN_LEFT+60, SCREEN_RIGHT-60 };
|
||||
const float DIFFICULTY_Y[NUM_PLAYERS] = { SCREEN_BOTTOM-70, SCREEN_BOTTOM-70 };
|
||||
|
||||
const float DEBUG_X = CENTER_X;
|
||||
const float DEBUG_Y = CENTER_Y-70;
|
||||
const float MAX_SECONDS_CAN_BE_OFF_BY = 0.25f;
|
||||
|
||||
const float TIME_BETWEEN_DANCING_COMMENTS = 15;
|
||||
|
||||
|
||||
// received while STATE_DANCING
|
||||
const ScreenMessage SM_PlayMusic = ScreenMessage(SM_User+101);
|
||||
const ScreenMessage SM_MusicEnded = ScreenMessage(SM_User+102);
|
||||
const ScreenMessage SM_SongEnded = ScreenMessage(SM_User+102);
|
||||
const ScreenMessage SM_LifeIs0 = ScreenMessage(SM_User+103);
|
||||
|
||||
|
||||
@@ -64,7 +62,7 @@ const ScreenMessage SM_BeginFailed = ScreenMessage(SM_User+121);
|
||||
const ScreenMessage SM_ShowFailed = ScreenMessage(SM_User+122);
|
||||
const ScreenMessage SM_PlayFailComment = ScreenMessage(SM_User+123);
|
||||
const ScreenMessage SM_HideFailed = ScreenMessage(SM_User+124);
|
||||
const ScreenMessage SM_GoToScreenAfterFail = ScreenMessage(SM_User+125);
|
||||
const ScreenMessage SM_GoToScreenAfterFail = ScreenMessage(SM_User+125);
|
||||
|
||||
|
||||
|
||||
@@ -73,8 +71,6 @@ ScreenGameplay::ScreenGameplay()
|
||||
LOG->WriteLine( "ScreenGameplay::ScreenGameplay()" );
|
||||
|
||||
m_pCurSong = NULL;
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
m_pCurNotes[p] = NULL;
|
||||
|
||||
switch( PREFSMAN->m_PlayMode )
|
||||
{
|
||||
@@ -110,7 +106,7 @@ ScreenGameplay::ScreenGameplay()
|
||||
|
||||
|
||||
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( !GAMEMAN->IsPlayerEnabled(PlayerNumber(p)) )
|
||||
continue;
|
||||
@@ -154,8 +150,12 @@ ScreenGameplay::ScreenGameplay()
|
||||
m_textStageNumber.Load( THEME->GetPathTo(FONT_HEADER2) );
|
||||
m_textStageNumber.TurnShadowOff();
|
||||
m_textStageNumber.SetXY( STAGE_NUMBER_LOCAL_X, STAGE_NUMBER_LOCAL_Y );
|
||||
m_textStageNumber.SetText( PREFSMAN->GetStageText() );
|
||||
m_textStageNumber.SetDiffuseColor( PREFSMAN->GetStageColor() );
|
||||
CString sStageText = PREFSMAN->GetStageText();
|
||||
m_textStageNumber.SetText( sStageText );
|
||||
if( stricmp(sStageText, "Final") == 0 )
|
||||
m_textStageNumber.SetDiffuseColor( D3DXCOLOR(1,0.1f,0.1f,1) ); // red
|
||||
else
|
||||
m_textStageNumber.SetDiffuseColor( D3DXCOLOR(0.3f,1,0.3f,1) ); // green
|
||||
m_frameTop.AddActor( &m_textStageNumber );
|
||||
|
||||
|
||||
@@ -178,7 +178,6 @@ ScreenGameplay::ScreenGameplay()
|
||||
|
||||
m_ScoreDisplay[p].SetXY( SCORE_LOCAL_X[p], SCORE_LOCAL_Y[p] );
|
||||
m_ScoreDisplay[p].SetZoom( 0.8f );
|
||||
m_ScoreDisplay[p].SetDiffuseColor( PlayerToColor(p) );
|
||||
m_frameBottom.AddActor( &m_ScoreDisplay[p] );
|
||||
|
||||
m_textPlayerOptions[p].Load( THEME->GetPathTo(FONT_NORMAL) );
|
||||
@@ -208,13 +207,9 @@ ScreenGameplay::ScreenGameplay()
|
||||
}
|
||||
|
||||
|
||||
m_textDebug.Load( THEME->GetPathTo(FONT_NORMAL) );
|
||||
m_textDebug.SetXY( DEBUG_X, DEBUG_Y );
|
||||
m_textDebug.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
|
||||
this->AddActor( &m_textDebug );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_StarWipe.SetClosed();
|
||||
@@ -267,38 +262,18 @@ ScreenGameplay::~ScreenGameplay()
|
||||
}
|
||||
|
||||
|
||||
void ScreenGameplay::SaveSummary()
|
||||
{
|
||||
// save score summaries
|
||||
if( m_pCurSong != NULL )
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( !GAMEMAN->IsPlayerEnabled((PlayerNumber)p) )
|
||||
continue; // skip
|
||||
|
||||
SONGMAN->m_aGameplayStatistics[p].Add( m_Player[p].GetGameplayStatistics(m_pCurSong, m_pCurNotes[p]) );
|
||||
}
|
||||
|
||||
m_pCurSong = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ScreenGameplay::LoadNextSong()
|
||||
{
|
||||
int p;
|
||||
|
||||
m_pCurSong = m_apSongQueue[m_apSongQueue.GetSize()-1];
|
||||
m_apSongQueue.RemoveAt(m_apSongQueue.GetSize()-1);
|
||||
|
||||
SaveSummary();
|
||||
|
||||
m_pCurSong = m_apSongQueue[0];
|
||||
m_apSongQueue.RemoveAt(0);
|
||||
|
||||
Notes* pNotes[NUM_PLAYERS];
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
m_pCurNotes[p] = m_apNotesQueue[p][0];
|
||||
m_apNotesQueue[p].RemoveAt(0);
|
||||
pNotes[p] = m_apNotesQueue[p][m_apNotesQueue[p].GetSize()-1];
|
||||
m_apNotesQueue[p].RemoveAt(m_apNotesQueue[p].GetSize()-1);
|
||||
}
|
||||
|
||||
|
||||
@@ -310,10 +285,10 @@ void ScreenGameplay::LoadNextSong()
|
||||
if( !GAMEMAN->IsPlayerEnabled(PlayerNumber(p)) )
|
||||
continue;
|
||||
|
||||
m_DifficultyBanner[p].SetFromNotes( PlayerNumber(p), m_pCurNotes[p] );
|
||||
m_DifficultyBanner[p].SetFromNotes( PlayerNumber(p), pNotes[p] );
|
||||
|
||||
|
||||
NoteData* pOriginalNoteData = m_pCurNotes[p]->GetNoteData();
|
||||
NoteData* pOriginalNoteData = pNotes[p]->GetNoteData();
|
||||
|
||||
NoteData newNoteData;
|
||||
pStyleDef->GetTransformedNoteDataForStyle( (PlayerNumber)p, pOriginalNoteData, newNoteData );
|
||||
@@ -322,7 +297,6 @@ void ScreenGameplay::LoadNextSong()
|
||||
(PlayerNumber)p,
|
||||
GAMEMAN->GetCurrentStyleDef(),
|
||||
&newNoteData,
|
||||
m_pCurNotes[p]->m_iMeter,
|
||||
PREFSMAN->m_PlayerOptions[p],
|
||||
&m_LifeMeter[p],
|
||||
&m_ScoreDisplay[p]
|
||||
@@ -330,8 +304,6 @@ void ScreenGameplay::LoadNextSong()
|
||||
}
|
||||
|
||||
m_soundMusic.Load( m_pCurSong->GetMusicPath() );
|
||||
this->SendScreenMessage( SM_PlayMusic, 3 );
|
||||
m_soundMusic.SetPlaybackRate( PREFSMAN->m_SongOptions.m_fMusicRate );
|
||||
|
||||
m_Background.LoadFromSong( m_pCurSong );
|
||||
m_Background.SetDiffuseColor( D3DXCOLOR(0.5f,0.5f,0.5f,1) );
|
||||
@@ -346,10 +318,6 @@ void ScreenGameplay::Update( float fDeltaTime )
|
||||
Screen::Update( fDeltaTime );
|
||||
|
||||
|
||||
if( m_pCurSong == NULL )
|
||||
return;
|
||||
|
||||
|
||||
float fSongBeat, fBPS;
|
||||
float fPositionSeconds = m_soundMusic.GetPositionSeconds();
|
||||
|
||||
@@ -360,7 +328,7 @@ void ScreenGameplay::Update( float fDeltaTime )
|
||||
|
||||
//LOG->WriteLine( "m_fOffsetInBeats = %f, m_fBeatsPerSecond = %f, m_Music.GetPositionSeconds = %f", m_fOffsetInBeats, m_fBeatsPerSecond, m_Music.GetPositionSeconds() );
|
||||
|
||||
const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * PREFSMAN->m_SongOptions.m_fMusicRate;
|
||||
float fMaxBeatDifference = fBPS*MAX_SECONDS_CAN_BE_OFF_BY;
|
||||
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
@@ -388,12 +356,16 @@ void ScreenGameplay::Update( float fDeltaTime )
|
||||
continue;
|
||||
|
||||
if( !m_LifeMeter[p].IsAboutToFail() )
|
||||
{
|
||||
bAllAboutToFail = false;
|
||||
|
||||
if( !m_LifeMeter[p].HasFailed() )
|
||||
bAllFailed = false;
|
||||
}
|
||||
else if( !m_LifeMeter[p].HasFailed() )
|
||||
{
|
||||
bAllFailed = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if( bAllAboutToFail ) m_Background.TurnDangerOn();
|
||||
else m_Background.TurnDangerOff();
|
||||
|
||||
@@ -415,11 +387,9 @@ void ScreenGameplay::Update( float fDeltaTime )
|
||||
|
||||
// Check for end of song
|
||||
if( m_DancingState == STATE_DANCING &&
|
||||
m_soundMusic.GetLengthSeconds() - m_soundMusic.GetPositionSeconds() < 0.5f )
|
||||
{
|
||||
this->SendScreenMessage( SM_MusicEnded, 0 );
|
||||
}
|
||||
|
||||
m_soundMusic.GetLengthSeconds() - m_soundMusic.GetPositionSeconds() < 2 )
|
||||
this->SendScreenMessage( SM_SongEnded, 1 );
|
||||
|
||||
// Check to see if it's time to play a gameplay comment
|
||||
if( PREFSMAN->m_bAnnouncer )
|
||||
{
|
||||
@@ -438,52 +408,31 @@ void ScreenGameplay::Update( float fDeltaTime )
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Send crossed row messages to Player
|
||||
//
|
||||
int iRowNow = BeatToNoteRowNotRounded( fSongBeat );
|
||||
static int iRowLastCrossed = 0;
|
||||
|
||||
for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( !GAMEMAN->IsPlayerEnabled( (PlayerNumber)p ) )
|
||||
continue; // skip
|
||||
|
||||
m_Player[p].CrossedRow( r, fSongBeat, fMaxBeatDifference );
|
||||
}
|
||||
}
|
||||
|
||||
iRowLastCrossed = iRowNow;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// play assist ticks
|
||||
//
|
||||
// Sound cards have a latency between when a sample is Play()ed and when the sound
|
||||
// will start coming out the speaker. Compensate for this by boosting
|
||||
// fPositionSeconds ahead
|
||||
if( PREFSMAN->m_SongOptions.m_AssistType == SongOptions::ASSIST_TICK )
|
||||
{
|
||||
//
|
||||
// play assist ticks
|
||||
//
|
||||
// Sound cards have a latency between when a sample is Play()ed and when the sound
|
||||
// will start coming out the speaker. Compensate for this by boosting
|
||||
// fPositionSeconds ahead
|
||||
fPositionSeconds += (SOUND->GetPlayLatency()+0.06f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.06 seconds to make them play a tiny bit earlier
|
||||
m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS );
|
||||
|
||||
int iRowNow = BeatToNoteRowNotRounded( fSongBeat );
|
||||
static int iRowLastCrossed = 0;
|
||||
int iIndexNow = BeatToNoteIndexNotRounded( fSongBeat );
|
||||
static int iIndexLastCrossed = 0;
|
||||
|
||||
bool bAnyoneHasANote = false; // set this to true if any player has a note at one of the indicies we crossed
|
||||
|
||||
for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update
|
||||
for( int i=iIndexLastCrossed+1; i<=iIndexNow; i++ ) // for each index we crossed since the last update
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( !GAMEMAN->IsPlayerEnabled( (PlayerNumber)p ) )
|
||||
continue; // skip
|
||||
|
||||
m_Player[p].CrossedRow( r, fSongBeat, fMaxBeatDifference );
|
||||
bAnyoneHasANote |= m_Player[p].IsThereANoteAtRow( r );
|
||||
bAnyoneHasANote |= m_Player[p].IsThereANoteAtIndex( i );
|
||||
break; // this will only play the tick for the first player that is joined
|
||||
}
|
||||
}
|
||||
@@ -492,7 +441,7 @@ void ScreenGameplay::Update( float fDeltaTime )
|
||||
m_soundAssistTick.PlayRandom();
|
||||
|
||||
|
||||
iRowLastCrossed = iRowNow;
|
||||
iIndexLastCrossed = iIndexNow;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -511,44 +460,6 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
|
||||
float fSongBeat, fBPS;
|
||||
m_pCurSong->GetBeatAndBPSFromElapsedTime( m_soundMusic.GetPositionSeconds(), fSongBeat, fBPS );
|
||||
|
||||
|
||||
// Handle special keys to adjust the offset
|
||||
if( type == IET_FIRST_PRESS && DeviceI.device == DEVICE_KEYBOARD )
|
||||
{
|
||||
switch( DeviceI.button )
|
||||
{
|
||||
case DIK_F9:
|
||||
m_pCurSong->SetBeatOffsetInSeconds( m_pCurSong->GetBeatOffsetInSeconds()-0.01f );
|
||||
break;
|
||||
case DIK_F10:
|
||||
m_pCurSong->SetBeatOffsetInSeconds( m_pCurSong->GetBeatOffsetInSeconds()+0.01f );
|
||||
break;
|
||||
case DIK_F11:
|
||||
m_pCurSong->SetBeatOffsetInSeconds( m_pCurSong->GetBeatOffsetInSeconds()-(1/fBPS) );
|
||||
break;
|
||||
case DIK_F12:
|
||||
m_pCurSong->SetBeatOffsetInSeconds( m_pCurSong->GetBeatOffsetInSeconds()+(1/fBPS) );
|
||||
break;
|
||||
}
|
||||
|
||||
switch( DeviceI.button )
|
||||
{
|
||||
case DIK_F9:
|
||||
case DIK_F10:
|
||||
case DIK_F11:
|
||||
case DIK_F12:
|
||||
m_textDebug.SetText( ssprintf("Offset = %f.", m_pCurSong->GetBeatOffsetInSeconds()) );
|
||||
m_textDebug.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
|
||||
m_textDebug.StopTweening();
|
||||
m_textDebug.BeginTweeningQueued( 3 ); // sleep
|
||||
m_textDebug.BeginTweeningQueued( 0.5f ); // fade out
|
||||
m_textDebug.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( MenuI.IsValid() )
|
||||
{
|
||||
@@ -567,14 +478,14 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
|
||||
}
|
||||
}
|
||||
|
||||
const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * PREFSMAN->m_SongOptions.m_fMusicRate;
|
||||
float fMaxBeatsCanBeOffBy = MAX_SECONDS_CAN_BE_OFF_BY * fBPS;
|
||||
|
||||
if( type == IET_FIRST_PRESS )
|
||||
{
|
||||
if( StyleI.IsValid() )
|
||||
{
|
||||
if( GAMEMAN->IsPlayerEnabled( StyleI.player ) )
|
||||
m_Player[StyleI.player].HandlePlayerStep( fSongBeat, StyleI.col, fMaxBeatDifference );
|
||||
m_Player[StyleI.player].HandlePlayerStep( fSongBeat, StyleI.col, fMaxBeatsCanBeOffBy );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -604,6 +515,8 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
|
||||
if( PREFSMAN->m_bAnnouncer )
|
||||
m_announcerHereWeGo.PlayRandom();
|
||||
m_Background.SetDiffuseColor( D3DXCOLOR(0.8f,0.8f,0.8f,1) );
|
||||
m_soundMusic.Play();
|
||||
m_soundMusic.SetPlaybackRate( PREFSMAN->m_SongOptions.m_fMusicRate );
|
||||
break;
|
||||
case SM_User+6:
|
||||
break;
|
||||
@@ -622,33 +535,21 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
|
||||
this->SendScreenMessage( SM_BeginFailed, 0 );
|
||||
m_DancingState = STATE_OUTRO;
|
||||
break;
|
||||
|
||||
case SM_PlayMusic:
|
||||
m_soundMusic.Play();
|
||||
m_soundMusic.SetPlaybackRate( PREFSMAN->m_SongOptions.m_fMusicRate );
|
||||
break;
|
||||
case SM_MusicEnded:
|
||||
case SM_SongEnded:
|
||||
if( m_DancingState == STATE_OUTRO ) // gameplay already ended
|
||||
return; // ignore
|
||||
|
||||
if( m_apSongQueue.GetSize() > 0 )
|
||||
if( m_bBothHaveFailed ) // fail them
|
||||
{
|
||||
LoadNextSong();
|
||||
this->SendScreenMessage( SM_BeginFailed, 0 );
|
||||
}
|
||||
else
|
||||
else // cleared
|
||||
{
|
||||
if( m_bBothHaveFailed ) // fail them
|
||||
{
|
||||
this->SendScreenMessage( SM_BeginFailed, 0 );
|
||||
}
|
||||
else // cleared
|
||||
{
|
||||
m_StarWipe.CloseWipingRight( SM_ShowCleared );
|
||||
if( PREFSMAN->m_bAnnouncer )
|
||||
m_announcerCleared.PlayRandom(); // crowd cheer
|
||||
}
|
||||
m_DancingState = STATE_OUTRO;
|
||||
m_StarWipe.CloseWipingRight( SM_ShowCleared );
|
||||
if( PREFSMAN->m_bAnnouncer )
|
||||
m_announcerCleared.PlayRandom(); // crowd cheer
|
||||
}
|
||||
m_DancingState = STATE_OUTRO;
|
||||
break;
|
||||
|
||||
// received while STATE_OUTRO
|
||||
@@ -661,8 +562,16 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
|
||||
SCREENMAN->SendMessageToTopScreen( SM_GoToResults, 1 );
|
||||
break;
|
||||
case SM_GoToResults:
|
||||
SaveSummary();
|
||||
SCREENMAN->SetNewScreen( new ScreenResults(false) );
|
||||
{
|
||||
// send score summaries to the PREFSMAN object so ScreenResults can grab it.
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( !GAMEMAN->IsPlayerEnabled((PlayerNumber)p) )
|
||||
continue; // skip
|
||||
m_Player[p].GetGameplayStatistics( SONGMAN->m_GameplayStatistics[PREFSMAN->m_iNumArcadeStages-1][p] );
|
||||
}
|
||||
SCREENMAN->SetNewScreen( new ScreenResults(false) );
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user