broadcast GoalComplete

This commit is contained in:
Chris Danford
2005-04-09 09:34:54 +00:00
parent 9b01704f5d
commit dc7f16ed32
4 changed files with 50 additions and 0 deletions
+33
View File
@@ -554,6 +554,12 @@ void GameState::Update( float fDelta )
if( m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut > 0 )
m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut = max( 0, m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut - fDelta );
if( !m_bGoalComplete[p] && IsGoalComplete(p) )
{
m_bGoalComplete[p] = true;
MESSAGEMAN->Broadcast( (Message)(MESSAGE_GOAL_COMPLETE_P1+p) );
}
}
}
@@ -643,6 +649,8 @@ void GameState::ResetStageStatistics()
m_pPlayerState[p]->m_iLastPositiveSumOfAttackLevels = 0;
m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut = 0; // PlayerAI not affected
m_bGoalComplete[p] = false;
}
@@ -1830,6 +1838,31 @@ bool GameState::IsPlayerDead( PlayerNumber pn ) const
return GAMESTATE->m_pPlayerState[pn]->m_HealthState == PlayerState::DEAD;
}
float GameState::GetGoalPercentComplete( PlayerNumber pn )
{
if( !PROFILEMAN->IsUsingProfile(pn) )
return 0;
const Profile *pProfile = PROFILEMAN->GetProfile(pn);
const StageStats &ssAccum = STATSMAN->GetAccumStageStats();
const StageStats &ssCurrent = STATSMAN->m_CurStageStats;
const PlayerStageStats &pssAccum = ssAccum.m_player[pn];
const PlayerStageStats &pssCurrent = ssCurrent.m_player[pn];
float fActual = 0;
float fGoal = 0;
switch( pProfile->m_GoalType )
{
case GOAL_CALORIES:
fActual = pssAccum.fCaloriesBurned + pssCurrent.fCaloriesBurned;
fGoal = pProfile->m_iGoalCalories;
break;
case GOAL_TIME:
fActual = ssAccum.fGameplaySeconds + ssCurrent.fGameplaySeconds;
fGoal = pProfile->m_iGoalSeconds;
break;
}
return fActual / fGoal;
}
// lua start
+7
View File
@@ -182,6 +182,9 @@ public:
// used in PLAY_MODE_RAVE
float m_fTugLifePercentP1;
// used in workout
bool m_bGoalComplete[NUM_PLAYERS];
void GetUndisplayedBeats( const PlayerState* pPlayerState, float TotalSeconds, float &StartBeat, float &EndBeat ) const; // only meaningful when a NoteField is in use
void LaunchAttack( PlayerNumber target, const Attack& a );
@@ -290,6 +293,10 @@ public:
BroadcastOnChangePtr<Steps> m_pEditSourceSteps;
BroadcastOnChange<StepsType> m_stEditSource;
// Workout stuff
float GetGoalPercentComplete( PlayerNumber pn );
bool IsGoalComplete( PlayerNumber pn ) { return GetGoalPercentComplete( pn ) >= 1; }
// Lua
void PushSelf( lua_State *L );
};
+8
View File
@@ -15,6 +15,12 @@ static const CString MessageNames[NUM_MESSAGES] = {
"EditStepsTypeChanged",
"EditSourceStepsChanged",
"EditSourceStepsTypeChanged",
"EditPreferredDifficutyP1Changed",
"EditPreferredDifficutyP2Changed",
"EditPreferredCourseDifficutyP1Changed",
"EditPreferredCourseDifficutyP2Changed",
"GoalCompleteP1",
"GoalCompleteP2",
};
XToString( Message, NUM_MESSAGES );
@@ -57,6 +63,8 @@ void MessageManager::Unsubscribe( IMessageSubscriber* pSubscriber, Message m )
void MessageManager::Broadcast( const CString& sMessage ) const
{
ASSERT( !sMessage.empty() );
map<CString,SubscribersSet>::const_iterator iter = m_MessageToSubscribers.find( sMessage );
if( iter == m_MessageToSubscribers.end() )
return;
+2
View File
@@ -26,6 +26,8 @@ enum Message
MESSAGE_EDIT_PREFERRED_DIFFICULTY_P2_CHANGED,
MESSAGE_EDIT_PREFERRED_COURSE_DIFFICULTY_P1_CHANGED,
MESSAGE_EDIT_PREFERRED_COURSE_DIFFICULTY_P2_CHANGED,
MESSAGE_GOAL_COMPLETE_P1,
MESSAGE_GOAL_COMPLETE_P2,
NUM_MESSAGES,
MESSAGE_INVALID
};