本文整理汇总了C++中C_TFPlayer::GetItem方法的典型用法代码示例。如果您正苦于以下问题:C++ C_TFPlayer::GetItem方法的具体用法?C++ C_TFPlayer::GetItem怎么用?C++ C_TFPlayer::GetItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_TFPlayer
的用法示例。
在下文中一共展示了C_TFPlayer::GetItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTick
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFHudFlagObjectives::OnTick()
{
// iterate through the flags to set their position in our HUD
for ( int i = 0; i < g_Flags.Count(); i++ )
{
CCaptureFlag *pFlag = dynamic_cast< CCaptureFlag* >( ClientEntityList().GetEnt( g_Flags[i] ) );
if ( pFlag )
{
if (!pFlag->IsDisabled())
{
if (m_pRedFlag && pFlag->GetTeamNumber() == TF_TEAM_RED)
{
m_pRedFlag->SetEntity(pFlag);
}
else if (m_pBlueFlag && pFlag->GetTeamNumber() == TF_TEAM_BLUE)
{
m_pBlueFlag->SetEntity(pFlag);
}
else if (m_pGreenFlag && pFlag->GetTeamNumber() == TF_TEAM_GREEN)
{
m_pGreenFlag->SetEntity(pFlag);
}
else if (m_pYellowFlag && pFlag->GetTeamNumber() == TF_TEAM_YELLOW)
{
m_pYellowFlag->SetEntity(pFlag);
}
}
}
else
{
// this isn't a valid index for a flag
g_Flags.Remove( i );
}
}
// are we playing captures for rounds?
if ( tf_flag_caps_per_round.GetInt() > 0 )
{
C_TFTeam *pTeam = GetGlobalTFTeam( TF_TEAM_BLUE );
if ( pTeam )
{
SetDialogVariable( "bluescore", pTeam->GetFlagCaptures() );
}
pTeam = GetGlobalTFTeam( TF_TEAM_RED );
if ( pTeam )
{
SetDialogVariable( "redscore", pTeam->GetFlagCaptures() );
}
SetPlayingToLabelVisible( true );
SetDialogVariable( "rounds", tf_flag_caps_per_round.GetInt() );
}
else // we're just playing straight score
{
C_TFTeam *pTeam = GetGlobalTFTeam( TF_TEAM_BLUE );
if ( pTeam )
{
SetDialogVariable( "bluescore", pTeam->Get_Score() );
}
pTeam = GetGlobalTFTeam( TF_TEAM_RED );
if ( pTeam )
{
SetDialogVariable( "redscore", pTeam->Get_Score() );
}
SetPlayingToLabelVisible( false );
}
// check the local player to see if they're spectating, OBS_MODE_IN_EYE, and the target entity is carrying the flag
bool bSpecCarriedImage = false;
C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( pPlayer && ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) )
{
// does our target have the flag?
C_BaseEntity *pEnt = pPlayer->GetObserverTarget();
if ( pEnt && pEnt->IsPlayer() )
{
C_TFPlayer *pTarget = static_cast< C_TFPlayer* >( pEnt );
if ( pTarget->HasTheFlag() )
{
bSpecCarriedImage = true;
CCaptureFlag *pPlayerFlag = dynamic_cast<CCaptureFlag*>(pTarget->GetItem());
if (m_pSpecCarriedImage)
{
switch (pPlayerFlag->GetTeamNumber())
{
case TF_TEAM_RED:
m_pSpecCarriedImage->SetImage(("%s_red", STRING(pPlayerFlag->m_szHudIcon)));
break;
case TF_TEAM_BLUE:
m_pSpecCarriedImage->SetImage(("%s_blue", STRING(pPlayerFlag->m_szHudIcon)));
break;
//.........这里部分代码省略.........
示例2: UpdateStatus
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFHudFlagObjectives::UpdateStatus( void )
{
C_TFPlayer *pLocalPlayer = ToTFPlayer( C_BasePlayer::GetLocalPlayer() );
// are we carrying a flag?
CCaptureFlag *pPlayerFlag = NULL;
if ( pLocalPlayer && pLocalPlayer->HasItem() && ( pLocalPlayer->GetItem()->GetItemID() == TF_ITEM_CAPTURE_FLAG ) )
{
pPlayerFlag = dynamic_cast<CCaptureFlag*>( pLocalPlayer->GetItem() );
}
if ( pPlayerFlag )
{
m_bCarryingFlag = true;
// make sure the panels are on, set the initial alpha values,
// set the color of the flag we're carrying, and start the animations
if ( m_pCarriedImage && !m_bFlagAnimationPlayed )
{
m_bFlagAnimationPlayed = true;
// Set the correct flag image depending on the flag we're holding
switch (pPlayerFlag->GetTeamNumber())
{
case TF_TEAM_RED:
m_pCarriedImage->SetImage("../hud/objectives_flagpanel_carried_red");
break;
case TF_TEAM_BLUE:
m_pCarriedImage->SetImage("../hud/objectives_flagpanel_carried_blue");
break;
case TF_TEAM_GREEN:
m_pCarriedImage->SetImage("../hud/objectives_flagpanel_carried_green");
break;
case TF_TEAM_YELLOW:
m_pCarriedImage->SetImage("../hud/objectives_flagpanel_carried_yellow");
break;
}
if (m_pRedFlag && m_pRedFlag->IsVisible())
{
m_pRedFlag->SetVisible(false);
}
if ( m_pBlueFlag && m_pBlueFlag->IsVisible() )
{
m_pBlueFlag->SetVisible( false );
}
if (m_pGreenFlag && m_pGreenFlag->IsVisible())
{
m_pGreenFlag->SetVisible(false);
}
if (m_pYellowFlag && m_pYellowFlag->IsVisible())
{
m_pYellowFlag->SetVisible(false);
}
if ( !m_pCarriedImage->IsVisible() )
{
m_pCarriedImage->SetVisible( true );
}
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "FlagOutline" );
if ( m_pCapturePoint )
{
if ( !m_pCapturePoint->IsVisible() )
{
m_pCapturePoint->SetVisible( true );
}
if ( pLocalPlayer )
{
// go through all the capture zones and find ours
for ( int i = 0; i < g_CaptureZones.Count(); i++ )
{
C_BaseEntity *pZone = ClientEntityList().GetEnt( g_CaptureZones[i] );
if ( pZone )
{
if ( pZone->GetTeamNumber() == pLocalPlayer->GetTeamNumber() )
{
m_pCapturePoint->SetEntity( pZone );
}
}
}
}
}
}
}
else
{
// were we carrying the flag?
if ( m_bCarryingFlag )
{
m_bCarryingFlag = false;
//.........这里部分代码省略.........
示例3: Paint
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFArrowPanel::Paint()
{
if ( !m_hEntity.Get() )
return;
C_BaseEntity *pEnt = m_hEntity.Get();
IMaterial *pMaterial = m_NeutralMaterial;
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
// figure out what material we need to use
if ( pEnt->GetTeamNumber() == TF_TEAM_RED )
{
pMaterial = m_RedMaterial;
if ( pLocalPlayer && ( pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) )
{
// is our target a player?
C_BaseEntity *pTargetEnt = pLocalPlayer->GetObserverTarget();
if ( pTargetEnt && pTargetEnt->IsPlayer() )
{
// does our target have the flag and are they carrying the flag we're currently drawing?
C_TFPlayer *pTarget = static_cast< C_TFPlayer* >( pTargetEnt );
if ( pTarget->HasTheFlag() && ( pTarget->GetItem() == pEnt ) )
{
pMaterial = m_RedMaterialNoArrow;
}
}
}
}
else if ( pEnt->GetTeamNumber() == TF_TEAM_BLUE )
{
pMaterial = m_BlueMaterial;
if ( pLocalPlayer && ( pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) )
{
// is our target a player?
C_BaseEntity *pTargetEnt = pLocalPlayer->GetObserverTarget();
if ( pTargetEnt && pTargetEnt->IsPlayer() )
{
// does our target have the flag and are they carrying the flag we're currently drawing?
C_TFPlayer *pTarget = static_cast< C_TFPlayer* >( pTargetEnt );
if ( pTarget->HasTheFlag() && ( pTarget->GetItem() == pEnt ) )
{
pMaterial = m_BlueMaterialNoArrow;
}
}
}
}
else if (pEnt->GetTeamNumber() == TF_TEAM_GREEN)
{
pMaterial = m_GreenMaterial;
if (pLocalPlayer && (pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE))
{
// is our target a player?
C_BaseEntity *pTargetEnt = pLocalPlayer->GetObserverTarget();
if (pTargetEnt && pTargetEnt->IsPlayer())
{
// does our target have the flag and are they carrying the flag we're currently drawing?
C_TFPlayer *pTarget = static_cast< C_TFPlayer* >(pTargetEnt);
if (pTarget->HasTheFlag() && (pTarget->GetItem() == pEnt))
{
pMaterial = m_GreenMaterialNoArrow;
}
}
}
}
else if (pEnt->GetTeamNumber() == TF_TEAM_YELLOW)
{
pMaterial = m_YellowMaterial;
if (pLocalPlayer && (pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE))
{
// is our target a player?
C_BaseEntity *pTargetEnt = pLocalPlayer->GetObserverTarget();
if (pTargetEnt && pTargetEnt->IsPlayer())
{
// does our target have the flag and are they carrying the flag we're currently drawing?
C_TFPlayer *pTarget = static_cast< C_TFPlayer* >(pTargetEnt);
if (pTarget->HasTheFlag() && (pTarget->GetItem() == pEnt))
{
pMaterial = m_YellowMaterialNoArrow;
}
}
}
}
int x = 0;
int y = 0;
ipanel()->GetAbsPos( GetVPanel(), x, y );
int nWidth = GetWide();
int nHeight = GetTall();
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->MatrixMode( MATERIAL_MODEL );
pRenderContext->PushMatrix();
//.........这里部分代码省略.........