本文整理汇总了C++中C_TFPlayer::GetObjectOfType方法的典型用法代码示例。如果您正苦于以下问题:C++ C_TFPlayer::GetObjectOfType方法的具体用法?C++ C_TFPlayer::GetObjectOfType怎么用?C++ C_TFPlayer::GetObjectOfType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_TFPlayer
的用法示例。
在下文中一共展示了C_TFPlayer::GetObjectOfType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendDestroyMessage
bool CHudMenuEngyBuild::SendDestroyMessage( int iSlot )
{
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalPlayer )
return false;
bool bSuccess = false;
int iBuilding = GetBuildingIDFromSlot( iSlot );
C_BaseObject *pObj = pLocalPlayer->GetObjectOfType( iBuilding );
if ( pObj != NULL )
{
char szCmd[128];
Q_snprintf( szCmd, sizeof(szCmd), "destroy %d", iBuilding );
engine->ClientCmd( szCmd );
bSuccess = true;
}
else
{
pLocalPlayer->EmitSound( "Player.DenyWeaponSelection" );
}
return bSuccess;
}
示例2: OnBuildingChanged
void CHudBuildingStatusContainer::OnBuildingChanged( int iBuildingType, bool bBuildingIsDead )
{
bool bFound = false;
for ( int i = 0; i < m_BuildingPanels.Count() && !bFound; i++ )
{
CBuildingStatusItem *pItem = m_BuildingPanels.Element(i);
if ( pItem && pItem->GetRepresentativeObjectType() == iBuildingType )
{
// find the item that represents this building type
C_BaseObject *pObj = NULL;
// find the object
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( pLocalPlayer )
{
pObj = pLocalPlayer->GetObjectOfType( iBuildingType );
pItem->SetObject( pObj );
}
pItem->InvalidateLayout( true );
bFound = true;
RecalculateAlertState();
}
}
}
示例3: UpdateAllBuildings
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudBuildingStatusContainer::UpdateAllBuildings( void )
{
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalPlayer )
return;
for ( int i = 0; i < m_BuildingPanels.Count(); i++ )
{
CBuildingStatusItem *pItem = m_BuildingPanels.Element(i);
if ( pItem )
{
// find the item that represents this building type
C_BaseObject *pObj = NULL;
// find the object
pObj = pLocalPlayer->GetObjectOfType( pItem->GetRepresentativeObjectType() );
pItem->SetObject( pObj );
pItem->InvalidateLayout( true );
RecalculateAlertState();
}
}
}
示例4: SetVisible
void CHudMenuEngyBuild::SetVisible( bool state )
{
if ( state == true )
{
// close the weapon selection menu
engine->ClientCmd( "cancelselect" );
bool bConsoleMode = ( IsConsole() || tf_build_menu_controller_mode.GetBool() );
if ( bConsoleMode != m_bInConsoleMode )
{
InvalidateLayout( true, true );
m_bInConsoleMode = bConsoleMode;
}
// set the %lastinv% dialog var to our binding
const char *key = engine->Key_LookupBinding( "lastinv" );
if ( !key )
{
key = "< not bound >";
}
SetDialogVariable( "lastinv", key );
// Set selection to the first available building that we can build
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalPlayer )
return;
int iDefaultSlot = 1;
// Find the first slot that represents a building that we haven't built
int iSlot;
for ( iSlot = 1; iSlot <= 4; iSlot++ )
{
int iBuilding = GetBuildingIDFromSlot( iSlot );
C_BaseObject *pObj = pLocalPlayer->GetObjectOfType( iBuilding );
if ( pObj == NULL )
{
iDefaultSlot = iSlot;
break;
}
}
m_iSelectedItem = -1; //force redo
SetSelectedItem( iDefaultSlot );
HideLowerPriorityHudElementsInGroup( "mid" );
}
else
{
UnhideLowerPriorityHudElementsInGroup( "mid" );
}
BaseClass::SetVisible( state );
}
示例5: OnTick
void CHudMenuEngyBuild::OnTick( void )
{
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalPlayer )
return;
int iAccount = pLocalPlayer->GetAmmoCount( TF_AMMO_METAL );
for ( int i=0;i<4; i++ )
{
int iRemappedObjectID = GetBuildingIDFromSlot( i + 1 );
// update this slot
C_BaseObject *pObj = NULL;
if ( pLocalPlayer )
{
pObj = pLocalPlayer->GetObjectOfType( iRemappedObjectID );
}
m_pAvailableObjects[i]->SetVisible( false );
m_pAlreadyBuiltObjects[i]->SetVisible( false );
m_pCantAffordObjects[i]->SetVisible( false );
// If the building is already built
if ( pObj != NULL && !pObj->IsPlacing() )
{
m_pAlreadyBuiltObjects[i]->SetVisible( true );
}
// See if we can afford it
else if ( iAccount < GetObjectInfo( iRemappedObjectID )->m_Cost )
{
m_pCantAffordObjects[i]->SetVisible( true );
}
else
{
// we can buy it
m_pAvailableObjects[i]->SetVisible( true );
}
}
}
示例6: UpdateHintLabels
void CHudMenuEngyBuild::UpdateHintLabels( void )
{
// hilight the action we can perform ( build or destroy or neither )
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( pLocalPlayer )
{
int iBuilding = GetBuildingIDFromSlot( m_iSelectedItem );
C_BaseObject *pObj = pLocalPlayer->GetObjectOfType( iBuilding );
bool bDestroyLabelBright = false;
bool bBuildLabelBright = false;
if ( pObj )
{
// hilight destroy, we have a building
bDestroyLabelBright = true;
}
else if ( pLocalPlayer->GetAmmoCount( TF_AMMO_METAL ) >= GetObjectInfo( iBuilding )->m_Cost ) // I can afford it
{
// hilight build, we can build this
bBuildLabelBright = true;
}
else
{
// dim both, do nothing
}
if ( m_pDestroyLabelBright && m_pDestroyLabelDim && m_pBuildLabelBright && m_pBuildLabelDim )
{
m_pDestroyLabelBright->SetVisible( bDestroyLabelBright );
m_pDestroyLabelDim->SetVisible( !bDestroyLabelBright );
m_pBuildLabelBright->SetVisible( bBuildLabelBright );
m_pBuildLabelDim->SetVisible( !bBuildLabelBright );
}
}
}
示例7: SendBuildMessage
void CHudMenuEngyBuild::SendBuildMessage( int iSlot )
{
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalPlayer )
return;
int iBuilding = GetBuildingIDFromSlot( iSlot );
C_BaseObject *pObj = pLocalPlayer->GetObjectOfType( iBuilding );
int iCost = GetObjectInfo( iBuilding )->m_Cost;
if ( pObj == NULL && pLocalPlayer->GetAmmoCount( TF_AMMO_METAL ) >= iCost )
{
char szCmd[128];
Q_snprintf( szCmd, sizeof(szCmd), "build %d", iBuilding );
engine->ClientCmd( szCmd );
}
else
{
pLocalPlayer->EmitSound( "Player.DenyWeaponSelection" );
}
}