Move all random character selection to a separate function and make everything call that.

Make BeginnerHelper attempt to randomly select a character if one isn't selected.
This commit is contained in:
Thad Ward
2003-08-25 00:45:12 +00:00
parent d834608f0d
commit cf23c9c14c
4 changed files with 27 additions and 17 deletions
+6
View File
@@ -99,6 +99,12 @@ void BeginnerHelper::Initialize( int iDancePadType )
for( int pl=0; pl<NUM_PLAYERS; pl++ ) // Load players
{
// if there is no character set, try loading a random one.
if( GAMESTATE->m_pCurCharacters[pl] == NULL )
{
GAMESTATE->m_pCurCharacters[pl] = GAMESTATE->GetRandomCharacter();
}
if( GAMESTATE->m_PreferredDifficulty[pl] == DIFFICULTY_BEGINNER && GAMESTATE->m_pCurCharacters[pl] != NULL )
{
// Load textures
+2 -2
View File
@@ -107,8 +107,8 @@ void GameState::Reset()
for( p=0; p<NUM_PLAYERS; p++ )
{
if( PREFSMAN->m_bShowDancingCharacters && m_pCharacters.size() )
m_pCurCharacters[p] = m_pCharacters[rand()%m_pCharacters.size()];
if( PREFSMAN->m_bShowDancingCharacters )
m_pCurCharacters[p] = GetRandomCharacter();
else
m_pCurCharacters[p] = NULL;
}
+7
View File
@@ -94,6 +94,13 @@ public:
return true;
return false;
}
Character* GameState::GetRandomCharacter()
{
if( m_pCharacters.size() )
return m_pCharacters[rand()%m_pCharacters.size()];
else
return NULL;
}
PlayerController m_PlayerController[NUM_PLAYERS];
+12 -15
View File
@@ -55,21 +55,18 @@ ScreenHowToPlay::ScreenHowToPlay() : ScreenAttract("ScreenHowToPlay")
// Display random character+pad
if( GAMESTATE->m_pCharacters.size() )
{
int iRnd;
iRnd = rand() % ( GAMESTATE->m_pCharacters.size() );
if( iRnd != 0 )
{
m_mCharacter.LoadMilkshapeAscii( GAMESTATE->m_pCharacters[iRnd]->GetModelPath() );
m_mDancePad.LoadMilkshapeAscii("Characters" SLASH "DancePad-DDR.txt");
m_mCharacter.LoadMilkshapeAsciiBones("howtoplay", GAMESTATE->m_pCharacters[iRnd]->GetHowToPlayAnimationPath() );
m_mCharacter.SetRotationX( 40 );
m_mDancePad.SetRotationX( 35 );
m_mCharacter.Command("X,120;Y,300;Zoom,15;RotationY,180;sleep,4.7;linear,1.0;RotationY,360;Zoom,20;X,120;Y,400");
m_mDancePad.Command("X,40;Y,310;Zoom,15;RotationY,180;sleep,4.7;linear,1.0;RotationY,360;Zoom,20;X,230;Y,390");
this->AddChild(&m_mCharacter);
this->AddChild(&m_mDancePad);
}
Character* rndchar = GAMESTATE->GetRandomCharacter();
m_mCharacter.LoadMilkshapeAscii( rndchar->GetModelPath() );
m_mDancePad.LoadMilkshapeAscii("Characters" SLASH "DancePad-DDR.txt");
m_mCharacter.LoadMilkshapeAsciiBones("howtoplay", rndchar->GetHowToPlayAnimationPath() );
m_mCharacter.SetRotationX( 40 );
m_mDancePad.SetRotationX( 35 );
m_mCharacter.Command("X,120;Y,300;Zoom,15;RotationY,180;sleep,4.7;linear,1.0;RotationY,360;Zoom,20;X,120;Y,400");
m_mDancePad.Command("X,40;Y,310;Zoom,15;RotationY,180;sleep,4.7;linear,1.0;RotationY,360;Zoom,20;X,230;Y,390");
this->AddChild(&m_mCharacter);
this->AddChild(&m_mDancePad);
}
//