broadcast players joined and finalized
This commit is contained in:
+21
-15
@@ -233,6 +233,8 @@ void GameState::Reset()
|
|||||||
void GameState::JoinPlayer( PlayerNumber pn )
|
void GameState::JoinPlayer( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
this->m_bSideIsJoined[pn] = true;
|
this->m_bSideIsJoined[pn] = true;
|
||||||
|
MESSAGEMAN->Broadcast( (Message)(MESSAGE_SIDE_JOINED_P1+pn) );
|
||||||
|
|
||||||
if( this->m_MasterPlayerNumber == PLAYER_INVALID )
|
if( this->m_MasterPlayerNumber == PLAYER_INVALID )
|
||||||
this->m_MasterPlayerNumber = pn;
|
this->m_MasterPlayerNumber = pn;
|
||||||
|
|
||||||
@@ -241,6 +243,21 @@ void GameState::JoinPlayer( PlayerNumber pn )
|
|||||||
this->BeginGame();
|
this->BeginGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GameState::GetCoinsNeededToJoin() const
|
||||||
|
{
|
||||||
|
int iCoinsToCharge = 0;
|
||||||
|
|
||||||
|
if( GAMESTATE->GetCoinMode() == COIN_PAY )
|
||||||
|
iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit;
|
||||||
|
|
||||||
|
// If joint premium don't take away a credit for the 2nd join.
|
||||||
|
if( GAMESTATE->GetPremium() == PREMIUM_JOINT &&
|
||||||
|
GAMESTATE->GetNumSidesJoined() == 1 )
|
||||||
|
iCoinsToCharge = 0;
|
||||||
|
|
||||||
|
return iCoinsToCharge;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Game flow:
|
* Game flow:
|
||||||
*
|
*
|
||||||
@@ -777,21 +794,6 @@ bool GameState::PlayersCanJoin() const
|
|||||||
return GetNumSidesJoined() == 0 || this->m_pCurStyle == NULL; // selecting a style finalizes the players
|
return GetNumSidesJoined() == 0 || this->m_pCurStyle == NULL; // selecting a style finalizes the players
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameState::EnoughCreditsToJoin() const
|
|
||||||
{
|
|
||||||
switch( GAMESTATE->GetCoinMode() )
|
|
||||||
{
|
|
||||||
case COIN_PAY:
|
|
||||||
return GAMESTATE->m_iCoins >= PREFSMAN->m_iCoinsPerCredit;
|
|
||||||
case COIN_HOME:
|
|
||||||
case COIN_FREE:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
ASSERT(0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int GameState::GetNumSidesJoined() const
|
int GameState::GetNumSidesJoined() const
|
||||||
{
|
{
|
||||||
int iNumSidesJoined = 0;
|
int iNumSidesJoined = 0;
|
||||||
@@ -2003,6 +2005,8 @@ public:
|
|||||||
static int GetSongBeat( T* p, lua_State *L ) { lua_pushnumber(L, p->m_fSongBeat ); return 1; }
|
static int GetSongBeat( T* p, lua_State *L ) { lua_pushnumber(L, p->m_fSongBeat ); return 1; }
|
||||||
static int PlayerUsingBothSides( T* p, lua_State *L ) { lua_pushboolean(L, p->PlayerUsingBothSides() ); return 1; }
|
static int PlayerUsingBothSides( T* p, lua_State *L ) { lua_pushboolean(L, p->PlayerUsingBothSides() ); return 1; }
|
||||||
static int GetCoins( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iCoins ); return 1; }
|
static int GetCoins( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iCoins ); return 1; }
|
||||||
|
static int IsSideJoined( T* p, lua_State *L ) { lua_pushboolean(L, p->m_bSideIsJoined[(PlayerNumber)IArg(1)] ); return 1; }
|
||||||
|
static int GetCoinsNeededToJoin( T* p, lua_State *L ) { lua_pushnumber(L, p->GetCoinsNeededToJoin() ); return 1; }
|
||||||
|
|
||||||
static void Register(lua_State *L)
|
static void Register(lua_State *L)
|
||||||
{
|
{
|
||||||
@@ -2041,6 +2045,8 @@ public:
|
|||||||
ADD_METHOD( GetSongBeat )
|
ADD_METHOD( GetSongBeat )
|
||||||
ADD_METHOD( PlayerUsingBothSides )
|
ADD_METHOD( PlayerUsingBothSides )
|
||||||
ADD_METHOD( GetCoins )
|
ADD_METHOD( GetCoins )
|
||||||
|
ADD_METHOD( IsSideJoined )
|
||||||
|
ADD_METHOD( GetCoinsNeededToJoin )
|
||||||
|
|
||||||
Luna<T>::Register( L );
|
Luna<T>::Register( L );
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ public:
|
|||||||
int m_iGameSeed, m_iStageSeed;
|
int m_iGameSeed, m_iStageSeed;
|
||||||
|
|
||||||
bool PlayersCanJoin() const; // true if it's not too late for a player to join
|
bool PlayersCanJoin() const; // true if it's not too late for a player to join
|
||||||
bool EnoughCreditsToJoin() const; // true if an unjoined player can join by pressint start
|
int GetCoinsNeededToJoin() const;
|
||||||
|
bool EnoughCreditsToJoin() const { return GetCoinsNeededToJoin() <= 0; }
|
||||||
int GetNumSidesJoined() const;
|
int GetNumSidesJoined() const;
|
||||||
|
|
||||||
const Game* GetCurrentGame();
|
const Game* GetCurrentGame();
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ static const CString MessageNames[] = {
|
|||||||
"MadeChoiceP1",
|
"MadeChoiceP1",
|
||||||
"MadeChoiceP2",
|
"MadeChoiceP2",
|
||||||
"CoinInserted",
|
"CoinInserted",
|
||||||
|
"SideJoinedP1",
|
||||||
|
"SideJoinedP2",
|
||||||
|
"PlayersFinalized",
|
||||||
};
|
};
|
||||||
XToString( Message, NUM_MESSAGES );
|
XToString( Message, NUM_MESSAGES );
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ enum Message
|
|||||||
MESSAGE_MADE_CHOICE_P1,
|
MESSAGE_MADE_CHOICE_P1,
|
||||||
MESSAGE_MADE_CHOICE_P2,
|
MESSAGE_MADE_CHOICE_P2,
|
||||||
MESSAGE_COIN_INSERTED,
|
MESSAGE_COIN_INSERTED,
|
||||||
|
MESSAGE_SIDE_JOINED_P1,
|
||||||
|
MESSAGE_SIDE_JOINED_P2,
|
||||||
|
PLAYERS_FINALIZED,
|
||||||
NUM_MESSAGES,
|
NUM_MESSAGES,
|
||||||
MESSAGE_INVALID
|
MESSAGE_INVALID
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -215,19 +215,12 @@ bool Screen::JoinInput( const MenuInput &MenuI )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* subtract coins */
|
/* subtract coins */
|
||||||
int iCoinsToCharge = 0;
|
int iCoinsNeededToJoin = GAMESTATE->GetCoinsNeededToJoin();
|
||||||
if( GAMESTATE->GetCoinMode() == COIN_PAY )
|
|
||||||
iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit;
|
|
||||||
|
|
||||||
// If joint premium don't take away a credit for the 2nd join.
|
if( GAMESTATE->m_iCoins < iCoinsNeededToJoin )
|
||||||
if( GAMESTATE->GetPremium() == PREMIUM_JOINT &&
|
|
||||||
GAMESTATE->GetNumSidesJoined() == 1 )
|
|
||||||
iCoinsToCharge = 0;
|
|
||||||
|
|
||||||
if( GAMESTATE->m_iCoins < iCoinsToCharge )
|
|
||||||
return false; // not enough coins
|
return false; // not enough coins
|
||||||
else
|
else
|
||||||
GAMESTATE->m_iCoins -= iCoinsToCharge;
|
GAMESTATE->m_iCoins -= iCoinsNeededToJoin;
|
||||||
|
|
||||||
// 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