本文整理汇总了C++中CBaseCombatWeapon::GetSecondaryAmmoType方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatWeapon::GetSecondaryAmmoType方法的具体用法?C++ CBaseCombatWeapon::GetSecondaryAmmoType怎么用?C++ CBaseCombatWeapon::GetSecondaryAmmoType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatWeapon
的用法示例。
在下文中一共展示了CBaseCombatWeapon::GetSecondaryAmmoType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTick
//-----------------------------------------------------------------------------
// Ask: Let's update the label, shall we?
//-----------------------------------------------------------------------------
void CManhackScreen::OnTick()
{
BaseClass::OnTick();
// Get our player
CBasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
if ( !pPlayer )
return;
// Get the players active weapon
CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
// If pWeapon is NULL or it doesn't use primary ammo, don't update our screen
if ( !pWeapon || pWeapon->GetSecondaryAmmoType() != GetAmmoDef()->Index( "ManhacksOnline" ) )
return;
// Our RPG isn't clip-based, so we need to check the player's arsenal of rockets
int manhacks = pPlayer->GetAmmoCount( pWeapon->GetSecondaryAmmoType() );
if (m_pManhackOnline)
{
if (manhacks>0)
{
m_pManhackOnline->SetText("ONLINE");
m_pManhackOnline->SetFgColor(Color(0,255,0,255));
}
else
{
m_pManhackOnline->SetText("OFFLINE");
m_pManhackOnline->SetFgColor(Color(255,0,0,255));
}
}
// If our Label exist
if ( m_pManhackCount )
{
char buf[32];
Q_snprintf( buf, sizeof( buf ), "%d", manhacks );
// Set the Labels text to the number of missiles we have left.
m_pManhackCount->SetText( buf );
m_pManhackCount->SetFgColor(Color(255,255,255,255));
}
if ( m_pManhackDistance )
{
char buf[32];
Q_snprintf( buf, sizeof( buf ), "%d", m_iManhackDistance );
// Set the Labels text to the number of missiles we have left.
int xpos, ypos;
m_pManhackDistance->GetPos(xpos,ypos);
int charWidth = vgui::surface()->GetCharacterWidth(m_pManhackDistance->GetFont(),'0');
xpos = 100;
if (m_iManhackDistance>=10)
xpos -= charWidth;
if (m_iManhackDistance>=100)
xpos -= charWidth;
m_pManhackDistance->SetPos(xpos,ypos);
m_pManhackDistance->SetText( buf );
m_pManhackDistance->SetFgColor(Color(255,255,255,255));
}
}