Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// Purpose:
// Output : int
//-----------------------------------------------------------------------------
float CHudPlayerOverlay::GetAlphaFrac( void )
{
    //
    // return fmod( gpGlobals->curtime, 1.0f );

    C_BaseTFPlayer *local = C_BaseTFPlayer::GetLocalPlayer();
    if ( !local )
        return 1.0;

    C_BaseTFPlayer *pPlayer = m_hPlayer.Get();
    if (!pPlayer || (pPlayer->GetTeamNumber() == local->GetTeamNumber()) )
        return 1.0f;

    return pPlayer->GetOverlayAlpha();
}
//-----------------------------------------------------------------------------
// Frame-based update
//-----------------------------------------------------------------------------
void CVehicleBayVGuiScreen::OnTick()
{
	BaseClass::OnTick();

	if (!GetEntity())
		return;

	C_BaseTFPlayer *pLocalPlayer = C_BaseTFPlayer::GetLocalPlayer();
	if ( !pLocalPlayer )
		return;

	int nBankResources = pLocalPlayer ? pLocalPlayer->GetBankResources() : 0;

	// Set the vehicles costs
	for ( int i = 0; i < NUM_VEHICLES; i++ )
	{
		if ( !m_pVehicleButtons[i] )
			continue;

		char buf[128];
		int iCost = CalculateObjectCost( g_ValidVehicles[i], pLocalPlayer->GetNumObjects( g_ValidVehicles[i] ), pLocalPlayer->GetTeamNumber() );
		Q_snprintf( buf, sizeof( buf ), "%s : %d", GetObjectInfo( g_ValidVehicles[i] )->m_pStatusName, iCost );
		m_pVehicleButtons[i]->SetText( buf );
		// Can't build if the game hasn't started
		if ( CurrentActIsAWaitingAct() )
		{
			m_pVehicleButtons[i]->SetEnabled( false );
		}
		else
		{
			m_pVehicleButtons[i]->SetEnabled( nBankResources >= iCost );
		}
	}
}
Exemplo n.º 3
0
void CHudPlayerOverlay::OnTick( )
{
    BaseClass::OnTick();

    if (!IsLocalPlayerInTactical() || !engine->IsInGame())
    {
        Hide();
        return;
    }

    // Don't draw if I'm not visible in the tactical map
    if ( MapData().IsEntityVisibleToTactical( GetEntity() ) == false )
    {
        Hide();
        return;
    }

    // Don't draw it if I'm on team 0 (haven't decided on a team)
    C_BaseTFPlayer *pPlayer = m_hPlayer.Get();
    if (!pPlayer || (pPlayer->GetTeamNumber() == 0) || (pPlayer->GetClass() == TFCLASS_UNDECIDED))
    {
        Hide();
        return;
    }

    SetVisible( true );

    char *pName = g_PR->Get_Name( m_PlayerNum );
    if ( pName )
    {
        m_pName->SetName( pName );
    }
    else
    {
        Hide();
        return;
    }

    Vector pos, screen;

    C_BaseTFPlayer *tf2player = dynamic_cast<C_BaseTFPlayer *>( GetEntity() );
    int iteam = 0;
    int iclass = 0;
    if ( tf2player )
    {
        iteam	= tf2player->GetTeamNumber();
        iclass	= tf2player->PlayerClass();

        // FIXME: Get max health for player
        m_pHealth->SetHealth( (float)tf2player->GetHealth() / (float)100.0f );
    }

    m_pClass->SetImage( 0 );
    if ( iteam != 0 && iclass != TFCLASS_UNDECIDED )
        m_pClass->SetTeamAndClass( iteam, iclass );

    // Update our position on screen
    int sx, sy;
    GetEntityPosition( sx, sy );

    // Set the position
    SetPos( (int)(sx + m_OffsetX + 0.5f), (int)(sy + m_OffsetY + 0.5f));

    // Add it in
    m_pHealth->SetVisible( true );
    m_pName->SetVisible( true );
    m_pClass->SetVisible( true );

    if ( MapData().m_Players[ m_PlayerNum - 1 ].m_bSelected )
    {
        m_pSelected->SetVisible( true );
    }
    else
    {
        m_pSelected->SetVisible( false );
    }

    if ( MapData().m_Players[ m_PlayerNum - 1 ].m_nSquadNumber != 0 )
    {
        char sz[ 32 ];
        Q_snprintf( sz, sizeof( sz ), "%i", MapData().m_Players[ m_PlayerNum - 1 ].m_nSquadNumber );

        m_pSquad->SetSquad( sz );
        m_pSquad->SetVisible( true );
    }
    else
    {
        m_pSquad->SetVisible( false );
    }

    // Hide details if it's an enemy
    if ( ArePlayersOnSameTeam( engine->GetPlayer(), m_PlayerNum ) == false )
    {
        m_pHealth->SetVisible( false );
        m_pName->SetVisible( false );
        m_pSelected->SetVisible( false );
        m_pSquad->SetVisible( false );

        // Only show class icon
        m_pClass->SetVisible( true );
    }
}