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


C++ C_BaseObject::GetBuildingAlertLevel方法代码示例

本文整理汇总了C++中C_BaseObject::GetBuildingAlertLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ C_BaseObject::GetBuildingAlertLevel方法的具体用法?C++ C_BaseObject::GetBuildingAlertLevel怎么用?C++ C_BaseObject::GetBuildingAlertLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在C_BaseObject的用法示例。


在下文中一共展示了C_BaseObject::GetBuildingAlertLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RecalculateAlertState

void CHudBuildingStatusContainer::RecalculateAlertState( void )
{
	BuildingHudAlert_t maxAlertLevel = BUILDING_HUD_ALERT_NONE;

	// find our highest warning level
	for ( int i = 0; i < m_BuildingPanels.Count(); i++ )
	{
		CBuildingStatusItem *pItem = m_BuildingPanels.Element(i);
		C_BaseObject * pObj = pItem->GetRepresentativeObject();

		if ( pObj )
		{
			BuildingHudAlert_t alertLevel = pObj->GetBuildingAlertLevel();
			if ( alertLevel > maxAlertLevel )
			{
				maxAlertLevel = alertLevel;
			}
		}
	}

	if ( maxAlertLevel != m_AlertLevel )
	{
		if ( maxAlertLevel >= BUILDING_HUD_ALERT_VERY_LOW_AMMO )
		{
			m_flNextBeep = gpGlobals->curtime;	// beep asap
			m_iNumBeepsToBeep = tf_hud_num_building_alert_beeps.GetInt();
		}

		m_AlertLevel = maxAlertLevel;
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:31,代码来源:tf_hud_building_status.cpp

示例2: OnTick

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBuildingStatusItem::OnTick()
{
	// We only tick while active and with a valid built object
	C_BaseObject *pObj = GetRepresentativeObject();

	if ( !pObj )	// implies not active
	{
		if ( m_bActive )
		{
			// we lost our object. force relayout to inactive mode
			InvalidateLayout();

			// tell our parent that we're gone
			IGameEvent *event = gameeventmanager->CreateEvent( "building_info_changed" );
			if ( event )
			{
				event->SetInt( "building_type", GetRepresentativeObjectType() );
				gameeventmanager->FireEventClientSide( event );
			}
		}

		// We don't want to tick while inactive regardless
		return;
	}

	float flHealth = (float)pObj->GetHealth() / (float)pObj->GetMaxHealth();

	m_pHealthBar->SetProgress( flHealth );

	if ( pObj->IsBuilding() )
	{
		m_pBuildingPanel->SetVisible( true );
		m_pRunningPanel->SetVisible( false );

		m_pBuildingProgress->SetProgress( pObj->GetPercentageConstructed() );
	}
	else
	{
		m_pBuildingPanel->SetVisible( false );
		m_pRunningPanel->SetVisible( true );
	}

	// what is our current alert state?
	BuildingHudAlert_t alertLevel = pObj->GetBuildingAlertLevel();

	if ( alertLevel <= BUILDING_HUD_ALERT_NONE )
	{
		// if the tray is out, hide it
		if ( m_pAlertTray->IsTrayOut() )
		{
			m_pAlertTray->HideTray();
			m_pWrenchIcon->SetVisible( false );
			m_pSapperIcon->SetVisible( false );
		}
	}
	else
	{
		if ( !m_pAlertTray->IsTrayOut() )
		{
			m_pAlertTray->ShowTray();
		}

		m_pAlertTray->SetAlertType( alertLevel );

		m_pWrenchIcon->SetVisible( false );
		m_pSapperIcon->SetVisible( false );

		if ( m_pAlertTray->GetAlertType() != BUILDING_HUD_ALERT_NONE &&
			m_pAlertTray->GetPercentDeployed() >= 1.0f )
		{
			switch( m_pAlertTray->GetAlertType() )
			{
			case BUILDING_HUD_ALERT_LOW_AMMO:
			case BUILDING_HUD_ALERT_LOW_HEALTH:
			case BUILDING_HUD_ALERT_VERY_LOW_AMMO:
			case BUILDING_HUD_ALERT_VERY_LOW_HEALTH:
				m_pWrenchIcon->SetVisible( true );
				break;

			case BUILDING_HUD_ALERT_SAPPER:
				m_pSapperIcon->SetVisible( true );
				break;

			case BUILDING_HUD_ALERT_NONE:
			default:
				break;
			}
		}
	}	
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:93,代码来源:tf_hud_building_status.cpp


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