more fixes to Oni and courses

This commit is contained in:
Chris Danford
2002-07-27 19:29:51 +00:00
parent f202bbe680
commit 936fabbe85
98 changed files with 1634 additions and 1156 deletions
+205 -121
View File
@@ -15,6 +15,7 @@
#include "ScreenManager.h"
#include "ScreenSelectMusic.h"
#include "ScreenSelectCourse.h"
#include "ScreenEvaluation.h"
#include "GameConstantsAndTypes.h"
#include "PrefsManager.h"
@@ -28,6 +29,7 @@
#include "GameState.h"
#include "ScoreDisplayNormal.h"
#include "ScoreDisplayOni.h"
#include "ScreenPrompt.h"
//
// Defines
@@ -61,19 +63,19 @@ const float TIME_BETWEEN_DANCING_COMMENTS = 13;
// received while STATE_DANCING
const ScreenMessage SM_NotesEnded = ScreenMessage(SM_User+102);
const ScreenMessage SM_LastNotesEnded = ScreenMessage(SM_User+103);
const ScreenMessage SM_LifeIs0 = ScreenMessage(SM_User+104);
// received while STATE_OUTRO
const ScreenMessage SM_ShowCleared = ScreenMessage(SM_User+111);
const ScreenMessage SM_HideCleared = ScreenMessage(SM_User+112);
const ScreenMessage SM_GoToResults = ScreenMessage(SM_User+113);
const ScreenMessage SM_GoToScreenAfterBack = ScreenMessage(SM_User+113);
const ScreenMessage SM_GoToStateAfterCleared= ScreenMessage(SM_User+114);
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);
@@ -81,6 +83,9 @@ ScreenGameplay::ScreenGameplay()
{
LOG->WriteLine( "ScreenGameplay::ScreenGameplay()" );
m_bAutoPlayerWasOn = PREFSMAN->m_bAutoPlay;
m_bChangedOffsetOrBPM = false;
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_ARCADE:
@@ -116,7 +121,6 @@ ScreenGameplay::ScreenGameplay()
m_DancingState = STATE_INTRO;
m_fTimeLeftBeforeDancingComment = TIME_BETWEEN_DANCING_COMMENTS;
m_bBothHaveFailed = false;
m_Background.SetDiffuseColor( D3DXCOLOR(0.4f,0.4f,0.4f,1) );
@@ -157,7 +161,7 @@ ScreenGameplay::ScreenGameplay()
m_pLifeMeter[p]->SetXY( LIFE_LOCAL_X[p], LIFE_LOCAL_Y[p] );
m_frameTop.AddSubActor( m_pLifeMeter[p] );
if( GAMESTATE->GetCurGame() == GAME_EZ2 )
if( GAMESTATE->m_CurGame == GAME_EZ2 )
{
m_pScoreDisplay[p]->SetXY( SCORE_LOCALEZ2_X[p], SCORE_LOCALEZ2_Y[p] );
m_pScoreDisplay[p]->SetZoom( 0.5f );
@@ -178,7 +182,7 @@ ScreenGameplay::ScreenGameplay()
m_textStageNumber.SetText( GAMESTATE->GetStageText() );
m_textStageNumber.SetDiffuseColor( GAMESTATE->GetStageColor() );
if( GAMESTATE->GetCurGame() == GAME_EZ2 )
if( GAMESTATE->m_CurGame == GAME_EZ2 )
{
m_textStageNumber.SetXY( STAGE_NUMBER_LOCAL_X, STAGE_NUMBER_LOCALEZ2_Y );
}
@@ -202,7 +206,7 @@ ScreenGameplay::ScreenGameplay()
m_frameBottom.SetXY( CENTER_X, SCREEN_BOTTOM - m_sprBottomFrame.GetZoomedHeight()/2 );
if( GAMESTATE->GetCurGame() != GAME_EZ2 )
if( GAMESTATE->m_CurGame != GAME_EZ2 )
{
m_sprBottomFrame.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_BOTTOM_FRAME) );
m_frameBottom.AddSubActor( &m_sprBottomFrame );
@@ -235,7 +239,7 @@ ScreenGameplay::ScreenGameplay()
if( !GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) )
continue;
if( GAMESTATE->GetCurGame() != GAME_EZ2 )
if( GAMESTATE->m_CurGame != GAME_EZ2 )
{
m_pScoreDisplay[p]->SetXY( SCORE_LOCAL_X[p], SCORE_LOCAL_Y[p] );
m_pScoreDisplay[p]->SetZoom( 0.8f );
@@ -269,7 +273,7 @@ ScreenGameplay::ScreenGameplay()
m_DifficultyBanner[p].SetXY( DIFFICULTY_X[p], fDifficultyY );
this->AddSubActor( &m_DifficultyBanner[p] );
if( GAMESTATE->GetCurGame() != GAME_EZ2 )
if( GAMESTATE->m_CurGame != GAME_EZ2 )
{
float fDifficultyY = DIFFICULTY_Y[p];
if( GAMESTATE->m_PlayerOptions[p].m_bReverseScroll )
@@ -287,8 +291,6 @@ ScreenGameplay::ScreenGameplay()
m_StarWipe.SetClosed();
this->AddSubActor( &m_StarWipe );
@@ -312,6 +314,10 @@ ScreenGameplay::ScreenGameplay()
m_sprFailed.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
this->AddSubActor( &m_sprFailed );
m_Fade.SetClosed();
m_Fade.SetOpened();
this->AddSubActor( &m_Fade );
m_soundFail.Load( THEME->GetPathTo(SOUND_GAMEPLAY_FAILED) );
@@ -445,6 +451,42 @@ void ScreenGameplay::LoadNextSong( bool bPlayMusic )
m_pLifeMeter[p]->NextSong( NULL );
}
bool ScreenGameplay::OneIsHot()
{
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) )
if( !m_pLifeMeter[p]->IsHot() )
return true;
return false;
}
bool ScreenGameplay::AllAreInDanger()
{
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) )
if( !m_pLifeMeter[p]->IsInDanger() )
return false;
return true;
}
bool ScreenGameplay::AllAreFailing()
{
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) )
if( !m_pLifeMeter[p]->IsFailing() )
return false;
return true;
}
bool ScreenGameplay::AllFailedEarlier()
{
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled(p) )
if( !m_pLifeMeter[p]->FailedEarlier() )
return false;
return true;
}
void ScreenGameplay::Update( float fDeltaTime )
{
@@ -484,45 +526,6 @@ void ScreenGameplay::Update( float fDeltaTime )
m_Player[p].Update( fDeltaTime, fSongBeat, fMaxBeatDifference );
}
// check for fail
switch( GAMESTATE->m_SongOptions.m_FailType )
{
case SongOptions::FAIL_ARCADE:
case SongOptions::FAIL_END_OF_SONG:
{
if( m_bBothHaveFailed )
break; // if they have already failed, don't bother checking again
// check for both players fail
bool bAllInDanger = true;
bool bAllAreFailing = true;
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsPlayerEnabled(PlayerNumber(p)) )
continue;
if( !m_pLifeMeter[p]->IsInDanger() )
bAllInDanger = false;
if( !m_pLifeMeter[p]->IsFailing() )
bAllAreFailing = false;
}
if( bAllInDanger ) m_Background.TurnDangerOn();
else m_Background.TurnDangerOff();
if( bAllAreFailing )
{
m_bBothHaveFailed = true;
SCREENMAN->SendMessageToTopScreen( SM_LifeIs0, 0 );
}
}
break;
case SongOptions::FAIL_OFF:
break;
}
// update seconds into play
for( p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled((PlayerNumber)p) && !m_pLifeMeter[p]->FailedEarlier() )
@@ -533,29 +536,44 @@ void ScreenGameplay::Update( float fDeltaTime )
{
case STATE_DANCING:
//
// Check for end of song
//
if( fSongBeat > GAMESTATE->m_pCurSong->m_fLastBeat+4 )
this->SendScreenMessage( SM_NotesEnded, 0 );
//
// check for fail
//
switch( GAMESTATE->m_SongOptions.m_FailType )
{
case SongOptions::FAIL_ARCADE:
if( AllAreFailing() )
SCREENMAN->SendMessageToTopScreen( SM_BeginFailed, 0 );
if( AllAreInDanger() )
m_Background.TurnDangerOn();
else
m_Background.TurnDangerOff();
break;
case SongOptions::FAIL_END_OF_SONG:
case SongOptions::FAIL_OFF:
break; // don't check for fail
default:
ASSERT(0);
}
//
// Check to see if it's time to play a gameplay comment
//
m_fTimeLeftBeforeDancingComment -= fDeltaTime;
if( m_fTimeLeftBeforeDancingComment <= 0 )
{
m_fTimeLeftBeforeDancingComment = TIME_BETWEEN_DANCING_COMMENTS; // reset for the next comment
bool bAllInDanger = true;
for( int p=0; p<NUM_PLAYERS; p++ )
if( !m_pLifeMeter[p]->IsInDanger() )
bAllInDanger = false;
bool bOneIsHot = false;
for( p=0; p<NUM_PLAYERS; p++ )
if( m_pLifeMeter[p]->IsHot() )
bOneIsHot = true;
if( bOneIsHot )
if( OneIsHot() )
m_announcerHot.PlayRandom();
else if( bAllInDanger )
else if( AllAreInDanger() )
m_announcerDanger.PlayRandom();
else
m_announcerGood.PlayRandom();
@@ -620,28 +638,6 @@ void ScreenGameplay::Update( float fDeltaTime )
iRowLastCrossed = iRowNow;
}
//
if( m_bBothHaveFailed )
{
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) )
continue;
float fOverrideAdd = m_Player[p].GetOverrideAdd();
if( fOverrideAdd == -1 )
{
m_Player[p].SetOverrideAdd( 0 );
}
else
{
float fNewAdd = min( 1, fOverrideAdd + fDeltaTime );
m_Player[p].SetOverrideAdd( fNewAdd );
}
}
}
}
@@ -665,14 +661,52 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
{
switch( DeviceI.button )
{
case DIK_F11:
case DIK_F12:
case DIK_F8:
PREFSMAN->m_bAutoPlay = !PREFSMAN->m_bAutoPlay;
m_bAutoPlayerWasOn &= PREFSMAN->m_bAutoPlay;
m_textDebug.SetText( ssprintf("Autoplayer %s.", (PREFSMAN->m_bAutoPlay ? "ON" : "OFF")) );
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;
case DIK_F9:
case DIK_F10:
{
m_bChangedOffsetOrBPM = true;
float fOffsetDelta;
switch( DeviceI.button )
{
case DIK_F11: fOffsetDelta = -0.025f; break;
case DIK_F12: fOffsetDelta = +0.025f; break;
case DIK_F9: fOffsetDelta = -0.025f; break;
case DIK_F10: fOffsetDelta = +0.025f; break;
default: ASSERT(0);
}
if( type == IET_FAST_REPEAT )
fOffsetDelta *= 40;
BPMSegment& seg = GAMESTATE->m_pCurSong->GetBPMSegmentAtBeat( fSongBeat );
seg.m_fBPM += fOffsetDelta;
m_textDebug.SetText( ssprintf("Cur BPM = %f.", GAMESTATE->m_pCurSong->m_fBeat0OffsetInSeconds) );
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;
case DIK_F11:
case DIK_F12:
{
m_bChangedOffsetOrBPM = true;
float fOffsetDelta;
switch( DeviceI.button )
{
case DIK_F11: fOffsetDelta = -0.02f; break;
case DIK_F12: fOffsetDelta = +0.02f; break;
default: ASSERT(0);
}
if( type == IET_FAST_REPEAT )
@@ -691,26 +725,60 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
}
}
if( MenuI.IsValid() && MenuI.button == MENU_BUTTON_BACK && type == IET_SLOW_REPEAT && m_DancingState == STATE_DANCING && !m_bBothHaveFailed )
if( MenuI.IsValid() && MenuI.button == MENU_BUTTON_BACK && type == IET_SLOW_REPEAT )
{
m_bBothHaveFailed = true;
SCREENMAN->SendMessageToTopScreen( SM_BeginFailed, 0 );
m_soundMusic.Stop();
this->ClearMessageQueue();
m_Fade.CloseWipingLeft( SM_GoToScreenAfterBack );
}
const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * GAMESTATE->m_SongOptions.m_fMusicRate;
if( type == IET_FIRST_PRESS )
//
// handle a step
//
if( m_DancingState == STATE_DANCING )
{
if( StyleI.IsValid() )
const float fMaxBeatDifference = fBPS * PREFSMAN->m_fJudgeWindow * GAMESTATE->m_SongOptions.m_fMusicRate;
if( type == IET_FIRST_PRESS )
{
if( GAMESTATE->IsPlayerEnabled( StyleI.player ) )
m_Player[StyleI.player].HandlePlayerStep( fSongBeat, StyleI.col, fMaxBeatDifference );
if( StyleI.IsValid() )
{
if( GAMESTATE->IsPlayerEnabled( StyleI.player ) )
m_Player[StyleI.player].HandlePlayerStep( fSongBeat, StyleI.col, fMaxBeatDifference );
}
}
}
}
void SaveChanges( void* pContext )
{
GAMESTATE->m_pCurSong->SaveToSMFile();
}
void DontSaveChanges( void* pContext )
{
GAMESTATE->m_pCurSong->LoadFromSMFile( GAMESTATE->m_pCurSong->GetCacheFilePath() );
}
void ShowSavePrompt( ScreenMessage SM_SendWhenDone )
{
SCREENMAN->AddScreenToTop( new ScreenPrompt(
SM_SendWhenDone,
ssprintf(
"You have changed the offset or BPM of\n"
"%s.\n"
"Would you like to save these changes back\n"
"to the song file?\n"
"Choosing NO will disgard your changes.",
GAMESTATE->m_pCurSong->GetFullTitle() ),
PROMPT_YES_NO,
true,
SaveChanges,
DontSaveChanges
)
);
}
void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
@@ -750,33 +818,32 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
break;
// received while STATE_DANCING
case SM_LifeIs0:
if( GAMESTATE->m_SongOptions.m_FailType == SongOptions::FAIL_ARCADE ) // fail them now!
this->SendScreenMessage( SM_BeginFailed, 0 );
m_DancingState = STATE_OUTRO;
break;
case SM_NotesEnded:
{
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) )
m_Player[p].SaveGameplayStatistics();
GAMESTATE->GetLatestGameplayStatistics().bAutoPlayerWasOn = m_bAutoPlayerWasOn;
LoadNextSong( true );
}
break;
case SM_LastNotesEnded:
if( m_DancingState == STATE_OUTRO ) // gameplay already ended
return; // ignore
{
if( m_DancingState == STATE_OUTRO ) // gameplay already ended
return; // ignore
if( m_bBothHaveFailed ) // fail them
{
this->SendScreenMessage( SM_BeginFailed, 0 );
m_DancingState = STATE_OUTRO;
if( GAMESTATE->m_SongOptions.m_FailType == SongOptions::FAIL_END_OF_SONG && AllFailedEarlier() )
{
this->SendScreenMessage( SM_BeginFailed, 0 );
}
else
{
m_StarWipe.CloseWipingRight( SM_ShowCleared );
m_announcerCleared.PlayRandom(); // crowd cheer
}
}
else // cleared
{
m_StarWipe.CloseWipingRight( SM_ShowCleared );
m_announcerCleared.PlayRandom(); // crowd cheer
}
m_DancingState = STATE_OUTRO;
break;
case SM_100Combo:
@@ -865,9 +932,23 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
break;
case SM_HideCleared:
m_sprCleared.StartBlurring();
SCREENMAN->SendMessageToTopScreen( SM_GoToResults, 1 );
SCREENMAN->SendMessageToTopScreen( SM_GoToStateAfterCleared, 1 );
break;
case SM_GoToResults:
case SM_GoToScreenAfterBack:
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_ARCADE: SCREENMAN->SetNewScreen( new ScreenSelectMusic ); break;
case PLAY_MODE_ONI: SCREENMAN->SetNewScreen( new ScreenSelectCourse ); break;
default: ASSERT(0);
}
break;
case SM_GoToStateAfterCleared:
if( m_bChangedOffsetOrBPM )
{
m_bChangedOffsetOrBPM = false;
ShowSavePrompt( SM_GoToStateAfterCleared );
break;
}
SCREENMAN->SetNewScreen( new ScreenEvaluation(false) );
break;
@@ -896,9 +977,6 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
m_sprFailed.SetTweenZoom( 1.0f ); // come to rest
m_sprFailed.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0.7f) ); // and fade in
// BUGFIX by ANDY: Stage will now reset back to 0 when game ends.
GAMESTATE->m_iCurrentStageIndex = 0;
SCREENMAN->SendMessageToTopScreen( SM_PlayFailComment, 1.5f );
SCREENMAN->SendMessageToTopScreen( SM_HideFailed, 3.0f );
break;
@@ -913,8 +991,14 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
SCREENMAN->SendMessageToTopScreen( SM_GoToScreenAfterFail, 1.5f );
break;
case SM_GoToScreenAfterFail:
if( m_bChangedOffsetOrBPM )
{
m_bChangedOffsetOrBPM = false;
ShowSavePrompt( SM_GoToScreenAfterFail );
break;
}
if( PREFSMAN->m_bEventMode )
SCREENMAN->SetNewScreen( new ScreenSelectMusic );
this->SendScreenMessage( SM_GoToScreenAfterBack, 0 );
else
SCREENMAN->SetNewScreen( new ScreenGameOver );
break;