本文整理汇总了C++中C_BaseCombatWeapon::GetMaxClip1方法的典型用法代码示例。如果您正苦于以下问题:C++ C_BaseCombatWeapon::GetMaxClip1方法的具体用法?C++ C_BaseCombatWeapon::GetMaxClip1怎么用?C++ C_BaseCombatWeapon::GetMaxClip1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_BaseCombatWeapon
的用法示例。
在下文中一共展示了C_BaseCombatWeapon::GetMaxClip1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Paint
void CHUDQuickInfo::Paint()
{
//BB: KILL THIS CRAP!
return;
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if ( player == NULL )
return;
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon == NULL )
return;
float fX, fY;
bool bBehindCamera = false;
CHudCrosshair::GetDrawPosition( &fX, &fY, &bBehindCamera );
// if the crosshair is behind the camera, don't draw it
if( bBehindCamera )
return;
int xCenter = (int)fX;
int yCenter = (int)fY - m_icon_lb->Height() / 2;
float scalar = 138.0f/255.0f;
// Check our health for a warning
int health = player->GetHealth();
if ( health != m_lastHealth )
{
UpdateEventTime();
m_lastHealth = health;
if ( health <= HEALTH_WARNING_THRESHOLD )
{
if ( m_warnHealth == false )
{
m_healthFade = 255;
m_warnHealth = true;
CLocalPlayerFilter filter;
C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, "HUDQuickInfo.LowHealth" );
}
}
else
{
m_warnHealth = false;
}
}
// Check our ammo for a warning
int ammo = pWeapon->Clip1();
if ( ammo != m_lastAmmo )
{
UpdateEventTime();
m_lastAmmo = ammo;
// Find how far through the current clip we are
float ammoPerc = (float) ammo / (float) pWeapon->GetMaxClip1();
// Warn if we're below a certain percentage of our clip's size
if (( pWeapon->GetMaxClip1() > 1 ) && ( ammoPerc <= ( 1.0f - CLIP_PERC_THRESHOLD )))
{
if ( m_warnAmmo == false )
{
m_ammoFade = 255;
m_warnAmmo = true;
CLocalPlayerFilter filter;
C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, "HUDQuickInfo.LowAmmo" );
}
}
else
{
m_warnAmmo = false;
}
}
Color clrNormal = gHUD.m_clrNormal;
clrNormal[3] = 255 * scalar;
m_icon_c->DrawSelf( xCenter, yCenter, clrNormal );
if( IsX360() )
{
// Because the fixed reticle draws on half-texels, this rather unsightly hack really helps
// center the appearance of the quickinfo on 360 displays.
xCenter += 1;
}
if ( !hud_quickinfo.GetInt() )
return;
int sinScale = (int)( fabs(sin(gpGlobals->curtime*8.0f)) * 128.0f );
// Update our health
if ( m_healthFade > 0.0f )
{
DrawWarning( xCenter - (m_icon_lb->Width() * 2), yCenter, m_icon_lb, m_healthFade );
}
else
//.........这里部分代码省略.........
示例2: Paint
void CHUDQuickInfo::Paint()
{
CHudTexture *icon_c = gHUD.GetIcon( "crosshair" );
CHudTexture *icon_rb = gHUD.GetIcon( "crosshair_right" );
CHudTexture *icon_lb = gHUD.GetIcon( "crosshair_left" );
if ( !icon_c || !icon_rb || !icon_lb )
return;
int xCenter = ( ScreenWidth() / 2 ) - icon_c->Width() / 2;
int yCenter = ( ScreenHeight() / 2 ) - icon_c->Height() / 2;
int scalar;
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if ( player == NULL )
return;
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon == NULL )
return;
//Get our values
int health = player->GetHealth();
int ammo = pWeapon->Clip1();
if ( m_fDamageFade > 0.0f )
{
m_fDamageFade -= (gpGlobals->frametime * 200.0f);
}
//Check our health for a warning
if ( health != m_lastHealth )
{
if ( health < m_lastHealth )
{
m_fDamageFade = QINFO_FADE_TIME;
}
m_fFade = QINFO_FADE_TIME;
m_lastHealth = health;
if ( health <= HEALTH_WARNING_THRESHOLD )
{
if ( m_warnHealth == false )
{
m_healthFade = 255;
m_warnHealth = true;
CLocalPlayerFilter filter;
C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, "HUDQuickInfo.LowHealth" );
}
}
else
{
m_warnHealth = false;
}
}
// Check our ammo for a warning
if ( ammo != m_lastAmmo )
{
m_fFade = QINFO_FADE_TIME;
m_lastAmmo = ammo;
if ( ( (float) ammo / (float) pWeapon->GetMaxClip1() ) <= ( 1.0f - CLIP_PERC_THRESHOLD ) )
{
if ( m_warnAmmo == false )
{
m_ammoFade = 255;
m_warnAmmo = true;
CLocalPlayerFilter filter;
C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, "HUDQuickInfo.LowAmmo" );
}
}
else
{
m_warnAmmo = false;
}
}
//Get our crosshair intensity
if ( m_fFade > 0.0f )
{
m_fFade -= (gpGlobals->frametime * 50.0f);
if ( m_fFade < 128.0f )
{
scalar = (int) max( 16, (m_fFade) );
}
else
{
scalar = 128;
}
}
else
{
scalar = 16;
//.........这里部分代码省略.........