//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &inputdata - 
//-----------------------------------------------------------------------------
void CTFIntermission::InputActivate( inputdata_t &inputdata )
{
	CTFGameRules *pCTFGameRules = TFGameRules();
	if ( pCTFGameRules )
	{
		pCTFGameRules->GoToIntermission();
	}
}
예제 #2
0
//-----------------------------------------------------------------------------
// Frame-based update
//-----------------------------------------------------------------------------
void CTFFourTeamMenu::OnTick()
{
	if (TFGameRules() && !TFGameRules()->IsFourTeamGame())
		return; // How did you even get here?

	// update the number of players on each team
	C_Team *pRed = GetGlobalTeam(TF_TEAM_RED);
	C_Team *pBlue = GetGlobalTeam(TF_TEAM_BLUE);
	C_Team *pGreen = GetGlobalTeam(TF_TEAM_GREEN);
	C_Team *pYellow = GetGlobalTeam(TF_TEAM_YELLOW);

	if (!pRed || !pBlue || !pGreen || !pYellow)
		return;

	// set our team counts
	SetDialogVariable("redcount", pRed->Get_Number_Players());
	SetDialogVariable("bluecount", pBlue->Get_Number_Players());
	SetDialogVariable("greencount", pGreen->Get_Number_Players());
	SetDialogVariable("yellowcount", pYellow->Get_Number_Players());

	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

	if (!pLocalPlayer)
		return;

	CTFGameRules *pRules = TFGameRules();

	if (!pRules)
		return;

	// check if teams are unbalanced
	m_bRedDisabled = m_bBlueDisabled = false;

	int iHeavyTeam, iLightTeam;

	bool bUnbalanced = pRules->AreTeamsUnbalanced(iHeavyTeam, iLightTeam);

	int iCurrentTeam = pLocalPlayer->GetTeamNumber();

	if ((bUnbalanced && iHeavyTeam == TF_TEAM_RED) || (pRules->WouldChangeUnbalanceTeams(TF_TEAM_RED, iCurrentTeam)))
	{
		m_bRedDisabled = true;
	}

	if ((bUnbalanced && iHeavyTeam == TF_TEAM_BLUE) || (pRules->WouldChangeUnbalanceTeams(TF_TEAM_BLUE, iCurrentTeam)))
	{
		m_bBlueDisabled = true;
	}

	if (m_pSpecTeamButton && m_pSpecLabel)
	{
		ConVarRef mp_allowspectators("mp_allowspectators");
		if (mp_allowspectators.IsValid())
		{
			if (mp_allowspectators.GetBool())
			{
				if (!m_pSpecTeamButton->IsVisible())
				{
					m_pSpecTeamButton->SetVisible(true);
					m_pSpecLabel->SetVisible(true);
				}
			}
			else
			{
				if (m_pSpecTeamButton->IsVisible())
				{
					m_pSpecTeamButton->SetVisible(false);
					m_pSpecLabel->SetVisible(false);
				}
			}
		}
	}
}
예제 #3
0
//-----------------------------------------------------------------------------
// Frame-based update
//-----------------------------------------------------------------------------
void CTFTeamMenu::OnTick()
{
	// update the number of players on each team

	// enable or disable buttons based on team limit

	C_Team *pRed = GetGlobalTeam( TF_TEAM_RED );
	C_Team *pBlue = GetGlobalTeam( TF_TEAM_BLUE );

	if ( !pRed || !pBlue )
		return;

	// set our team counts
	SetDialogVariable( "bluecount", pBlue->Get_Number_Players() );
	SetDialogVariable( "redcount", pRed->Get_Number_Players() );

	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

	if ( !pLocalPlayer )
		return;

	CTFGameRules *pRules = TFGameRules();

	if ( !pRules )
		return;

	// check if teams are unbalanced
	m_bRedDisabled = m_bBlueDisabled = false;

	int iHeavyTeam, iLightTeam;

	bool bUnbalanced = pRules->AreTeamsUnbalanced( iHeavyTeam, iLightTeam );
	
	int iCurrentTeam = pLocalPlayer->GetTeamNumber();

	if ( ( bUnbalanced && iHeavyTeam == TF_TEAM_RED ) || ( pRules->WouldChangeUnbalanceTeams( TF_TEAM_RED, iCurrentTeam ) ) )
	{
		m_bRedDisabled = true;
	}

	if ( ( bUnbalanced && iHeavyTeam == TF_TEAM_BLUE ) || ( pRules->WouldChangeUnbalanceTeams( TF_TEAM_BLUE, iCurrentTeam ) ) )
	{
		m_bBlueDisabled = true;
	}

	if ( m_pSpecTeamButton && m_pSpecLabel )
	{
		ConVarRef mp_allowspectators( "mp_allowspectators" );
		if ( mp_allowspectators.IsValid() )
		{
			if ( mp_allowspectators.GetBool() )
			{
				if ( !m_pSpecTeamButton->IsVisible() )
				{
					m_pSpecTeamButton->SetVisible( true );
					m_pSpecLabel->SetVisible( true );
				}
			}
			else
			{
				if ( m_pSpecTeamButton->IsVisible() )
				{
					m_pSpecTeamButton->SetVisible( false );
					m_pSpecLabel->SetVisible( false );
				}
			}
		}
	}
}