Screen::JoinInput -> GameState::JoinInput
This commit is contained in:
@@ -344,6 +344,29 @@ void GameState::JoinPlayer( PlayerNumber pn )
|
|||||||
BeginGame();
|
BeginGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Handle an input that can join a player. Return true if the player joined. */
|
||||||
|
bool GameState::JoinInput( PlayerNumber pn )
|
||||||
|
{
|
||||||
|
if( !PlayersCanJoin() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* If this side is already in, don't re-join. */
|
||||||
|
if( m_bSideIsJoined[pn] )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* subtract coins */
|
||||||
|
int iCoinsNeededToJoin = GetCoinsNeededToJoin();
|
||||||
|
|
||||||
|
if( m_iCoins < iCoinsNeededToJoin )
|
||||||
|
return false; // not enough coins
|
||||||
|
|
||||||
|
m_iCoins -= iCoinsNeededToJoin;
|
||||||
|
|
||||||
|
JoinPlayer( pn );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int GameState::GetCoinsNeededToJoin() const
|
int GameState::GetCoinsNeededToJoin() const
|
||||||
{
|
{
|
||||||
int iCoinsToCharge = 0;
|
int iCoinsToCharge = 0;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
void ApplyGameCommand( const RString &sCommand, PlayerNumber pn=PLAYER_INVALID );
|
void ApplyGameCommand( const RString &sCommand, PlayerNumber pn=PLAYER_INVALID );
|
||||||
void BeginGame(); // called when first player joins
|
void BeginGame(); // called when first player joins
|
||||||
void JoinPlayer( PlayerNumber pn );
|
void JoinPlayer( PlayerNumber pn );
|
||||||
|
bool JoinInput( PlayerNumber pn );
|
||||||
void PlayersFinalized(); // called after a style is chosen, which means the number of players is finalized
|
void PlayersFinalized(); // called after a style is chosen, which means the number of players is finalized
|
||||||
void EndGame(); // called on ScreenGameOver, ScreenMusicScroll, ScreenCredits
|
void EndGame(); // called on ScreenGameOver, ScreenMusicScroll, ScreenCredits
|
||||||
void SaveCurrentSettingsToProfile( PlayerNumber pn ); // called at the beginning of each stage
|
void SaveCurrentSettingsToProfile( PlayerNumber pn ); // called at the beginning of each stage
|
||||||
|
|||||||
@@ -219,29 +219,6 @@ RString Screen::GetPrevScreen() const
|
|||||||
return PREV_SCREEN;
|
return PREV_SCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Screen::JoinInput( PlayerNumber pn )
|
|
||||||
{
|
|
||||||
if( !GAMESTATE->PlayersCanJoin() )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* If this side is already in, don't re-join (and re-pay!). */
|
|
||||||
if(GAMESTATE->m_bSideIsJoined[pn])
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* subtract coins */
|
|
||||||
int iCoinsNeededToJoin = GAMESTATE->GetCoinsNeededToJoin();
|
|
||||||
|
|
||||||
if( GAMESTATE->m_iCoins < iCoinsNeededToJoin )
|
|
||||||
return false; // not enough coins
|
|
||||||
|
|
||||||
GAMESTATE->m_iCoins -= iCoinsNeededToJoin;
|
|
||||||
|
|
||||||
GAMESTATE->JoinPlayer( pn );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Screen::PostScreenMessage( const ScreenMessage SM, float fDelay )
|
void Screen::PostScreenMessage( const ScreenMessage SM, float fDelay )
|
||||||
{
|
{
|
||||||
ASSERT( fDelay >= 0.0 );
|
ASSERT( fDelay >= 0.0 );
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ public:
|
|||||||
virtual ScreenType GetScreenType() const { return ALLOW_OPERATOR_MENU_BUTTON ? game_menu : system_menu; }
|
virtual ScreenType GetScreenType() const { return ALLOW_OPERATOR_MENU_BUTTON ? game_menu : system_menu; }
|
||||||
bool AllowOperatorMenuButton() const { return ALLOW_OPERATOR_MENU_BUTTON; }
|
bool AllowOperatorMenuButton() const { return ALLOW_OPERATOR_MENU_BUTTON; }
|
||||||
|
|
||||||
static bool JoinInput( PlayerNumber pn ); // return true if player joined
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Lua
|
// Lua
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ void ScreenSelect::Input( const InputEventPlus &input )
|
|||||||
if( input.MenuI == MENU_BUTTON_COIN && input.type == IET_FIRST_PRESS )
|
if( input.MenuI == MENU_BUTTON_COIN && input.type == IET_FIRST_PRESS )
|
||||||
this->UpdateSelectableChoices();
|
this->UpdateSelectableChoices();
|
||||||
|
|
||||||
if( input.MenuI == MENU_BUTTON_START && input.type == IET_FIRST_PRESS && JoinInput(input.pn) )
|
if( input.MenuI == MENU_BUTTON_START && input.type == IET_FIRST_PRESS && GAMESTATE->JoinInput(input.pn) )
|
||||||
{
|
{
|
||||||
// HACK: Only play start sound for the 2nd player who joins. The
|
// HACK: Only play start sound for the 2nd player who joins. The
|
||||||
// start sound for the 1st player will be played by ScreenTitleMenu
|
// start sound for the 1st player will be played by ScreenTitleMenu
|
||||||
|
|||||||
Reference in New Issue
Block a user