当前位置: 首页>>代码示例>>C++>>正文


C++ CBaseCombatWeapon::GetSecondaryAmmoType方法代码示例

本文整理汇总了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));
	}
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:71,代码来源:c_manhack_screen.cpp


注:本文中的CBaseCombatWeapon::GetSecondaryAmmoType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。