本文整理汇总了C++中C_TFPlayer::IsPlayerClass方法的典型用法代码示例。如果您正苦于以下问题:C++ C_TFPlayer::IsPlayerClass方法的具体用法?C++ C_TFPlayer::IsPlayerClass怎么用?C++ C_TFPlayer::IsPlayerClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_TFPlayer
的用法示例。
在下文中一共展示了C_TFPlayer::IsPlayerClass方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShouldDraw
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudDemomanChargeMeter::ShouldDraw( void )
{
C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pPlayer || !pPlayer->IsPlayerClass( TF_CLASS_DEMOMAN ) || !pPlayer->IsAlive() )
{
return false;
}
CTFWeaponBase *pWpn = pPlayer->GetActiveTFWeapon();
if ( !pWpn )
{
return false;
}
int iWeaponID = pWpn->GetWeaponID();
if ( iWeaponID != TF_WEAPON_PIPEBOMBLAUNCHER )
{
return false;
}
return CHudElement::ShouldDraw();
}
示例2: DisplayHintTo
//-----------------------------------------------------------------------------
// Purpose: Player has waved his crosshair over this entity. Display appropriate hints.
//-----------------------------------------------------------------------------
void C_BaseObject::DisplayHintTo( C_BasePlayer *pPlayer )
{
bool bHintPlayed = false;
C_TFPlayer *pTFPlayer = ToTFPlayer(pPlayer);
if ( InSameTeam( pPlayer ) )
{
// We're looking at a friendly object.
if ( HasSapper() )
{
bHintPlayed = pPlayer->HintMessage( HINT_OBJECT_HAS_SAPPER, true, true );
}
if ( pTFPlayer->IsPlayerClass( TF_CLASS_ENGINEER ) )
{
// I'm an engineer.
// If I'm looking at a constructing object, let me know I can help build it (but not
// if I built it myself, since I've already got that hint from the wrench).
if ( !bHintPlayed && IsBuilding() && GetBuilder() != pTFPlayer )
{
bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_USE_WRENCH_ONOTHER, false, true );
}
// If it's damaged, I can repair it
if ( !bHintPlayed && !IsBuilding() && GetHealth() < GetMaxHealth() )
{
bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_REPAIR_OBJECT, false, true );
}
}
}
}
示例3: GetTargetIDString
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_AI_BaseNPC::GetTargetIDString( wchar_t *sIDString, int iMaxLenInBytes )
{
sIDString[0] = '\0';
C_TFPlayer *pLocalTFPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalTFPlayer )
return;
if ( InSameTeam( pLocalTFPlayer ) || pLocalTFPlayer->IsPlayerClass( TF_CLASS_SPY ) || pLocalTFPlayer->GetTeamNumber() == TEAM_SPECTATOR )
{
const char *pszClassname = GetClassname();
wchar_t *wszNPCName;
wszNPCName = g_pVGuiLocalize->Find( pszClassname );
if ( !wszNPCName )
{
wchar_t wszNPCNameBuf[MAX_PLAYER_NAME_LENGTH];
g_pVGuiLocalize->ConvertANSIToUnicode( pszClassname, wszNPCNameBuf, sizeof(wszNPCNameBuf) );
wszNPCName = wszNPCNameBuf;
}
const char *printFormatString = NULL;
if ( pLocalTFPlayer->GetTeamNumber() == TEAM_SPECTATOR || InSameTeam( pLocalTFPlayer ) )
{
printFormatString = "#TF_playerid_sameteam";
}
else if ( pLocalTFPlayer->IsPlayerClass( TF_CLASS_SPY ) )
{
// Spy can see enemy's health.
printFormatString = "#TF_playerid_diffteam";
}
wchar_t *wszPrepend = L"";
if ( printFormatString )
{
g_pVGuiLocalize->ConstructString( sIDString, iMaxLenInBytes, g_pVGuiLocalize->Find(printFormatString), 3, wszPrepend, wszNPCName );
}
}
}
示例4: ShouldDraw
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudBuildingStatusContainer_Engineer::ShouldDraw( void )
{
// Don't draw in freezecam
C_TFPlayer *pPlayer = CTFPlayer::GetLocalTFPlayer();
if ( !pPlayer || !pPlayer->IsPlayerClass( TF_CLASS_ENGINEER ) || pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM )
{
return false;
}
if ( pPlayer->GetTeamNumber() <= TEAM_SPECTATOR )
{
return false;
}
return CHudElement::ShouldDraw();
}
示例5: ShouldDraw
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudMedicChargeMeter::ShouldDraw( void )
{
C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pPlayer || !pPlayer->IsPlayerClass( TF_CLASS_MEDIC ) || !pPlayer->IsAlive() )
{
return false;
}
CTFWeaponBase *pWpn = pPlayer->GetActiveTFWeapon();
if ( !pWpn )
{
return false;
}
if ( pWpn->GetWeaponID() != TF_WEAPON_MEDIGUN )
{
return false;
}
return CHudElement::ShouldDraw();
}
示例6: UpdateID
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTargetID::UpdateID( void )
{
wchar_t sIDString[ MAX_ID_STRING ] = L"";
wchar_t sDataString[ MAX_ID_STRING ] = L"";
C_TFPlayer *pLocalTFPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalTFPlayer )
return;
// Get our target's ent index
Assert( m_iTargetEntIndex );
// Is this an entindex sent by the server?
if ( m_iTargetEntIndex )
{
C_BaseEntity *pEnt = cl_entitylist->GetEnt( m_iTargetEntIndex );
if ( !pEnt )
return;
bool bShowHealth = false;
float flHealth = 0;
float flMaxHealth = 1;
int iMaxBuffedHealth = 0;
int iColorNum = TEAM_UNASSIGNED;
// Some entities we always want to check, cause the text may change
// even while we're looking at it
// Is it a player?
if ( IsPlayerIndex( m_iTargetEntIndex ) )
{
const char *printFormatString = NULL;
wchar_t wszPlayerName[ MAX_PLAYER_NAME_LENGTH ];
bool bDisguisedTarget = false;
bool bDisguisedEnemy = false;
C_TFPlayer *pPlayer = static_cast<C_TFPlayer*>( pEnt );
if ( !pPlayer )
return;
C_TFPlayer *pDisguiseTarget = NULL;
g_pVGuiLocalize->ConvertANSIToUnicode( pPlayer->GetPlayerName(), wszPlayerName, sizeof(wszPlayerName) );
// determine if the target is a disguised spy (either friendly or enemy)
if ( pPlayer->m_Shared.InCond( TF_COND_DISGUISED ) && // they're disguised
//!pPlayer->m_Shared.InCond( TF_COND_DISGUISING ) && // they're not in the process of disguising
!pPlayer->m_Shared.InCond( TF_COND_STEALTHED ) ) // they're not cloaked
{
bDisguisedTarget = true;
pDisguiseTarget = ToTFPlayer( pPlayer->m_Shared.GetDisguiseTarget() );
}
iColorNum = pPlayer->GetTeamNumber();
if ( bDisguisedTarget )
{
// is the target a disguised enemy spy?
if ( pPlayer->IsEnemyPlayer() )
{
if ( pDisguiseTarget )
{
bDisguisedEnemy = true;
// change the player name
g_pVGuiLocalize->ConvertANSIToUnicode( pDisguiseTarget->GetPlayerName(), wszPlayerName, sizeof(wszPlayerName) );
// Show their disguise team color.
iColorNum = pPlayer->m_Shared.GetDisguiseTeam();
}
}
else
{
// The target is a disguised friendly spy. They appear to the player with no disguise. Add the disguise
// team & class to the target ID element.
bool bDisguisedAsEnemy = ( pPlayer->m_Shared.GetDisguiseTeam() != pPlayer->GetTeamNumber() );
const wchar_t *wszAlignment = g_pVGuiLocalize->Find( bDisguisedAsEnemy ? "#TF_enemy" : "#TF_friendly" );
int classindex = pPlayer->m_Shared.GetDisguiseClass();
const wchar_t *wszClassName = g_pVGuiLocalize->Find( g_aPlayerClassNames[classindex] );
// build a string with disguise information
g_pVGuiLocalize->ConstructString( sDataString, sizeof(sDataString), g_pVGuiLocalize->Find( "#TF_playerid_friendlyspy_disguise" ),
2, wszAlignment, wszClassName );
}
}
if ( pPlayer->IsPlayerClass( TF_CLASS_MEDIC ) )
{
wchar_t wszChargeLevel[ 10 ];
_snwprintf( wszChargeLevel, ARRAYSIZE(wszChargeLevel) - 1, L"%.0f", pPlayer->MedicGetChargeLevel() * 100 );
wszChargeLevel[ ARRAYSIZE(wszChargeLevel)-1 ] = '\0';
g_pVGuiLocalize->ConstructString( sDataString, sizeof(sDataString), g_pVGuiLocalize->Find( "#TF_playerid_mediccharge" ), 1, wszChargeLevel );
}
if (pLocalTFPlayer->GetTeamNumber() == TEAM_SPECTATOR || pPlayer->InSameTeam(pLocalTFPlayer) || (bDisguisedEnemy && pPlayer->m_Shared.GetDisguiseTeam() == pLocalTFPlayer->GetTeamNumber()))
{
printFormatString = "#TF_playerid_sameteam";
bShowHealth = true;
}
else if ( pLocalTFPlayer->IsPlayerClass( TF_CLASS_SPY ) && !pPlayer->m_Shared.InCond( TF_COND_STEALTHED ) )
//.........这里部分代码省略.........
示例7: ShouldDraw
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTargetID::ShouldDraw( void )
{
if ( !CHudElement::ShouldDraw() )
return false;
C_TFPlayer *pLocalTFPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalTFPlayer )
return false;
// Get our target's ent index
m_iTargetEntIndex = CalculateTargetIndex(pLocalTFPlayer);
if ( !m_iTargetEntIndex )
{
// Check to see if we should clear our ID
if ( m_flLastChangeTime && ( gpGlobals->curtime > m_flLastChangeTime ) )
{
m_flLastChangeTime = 0;
m_iLastEntIndex = 0;
}
else
{
// Keep re-using the old one
m_iTargetEntIndex = m_iLastEntIndex;
}
}
else
{
m_flLastChangeTime = gpGlobals->curtime;
}
bool bReturn = false;
if ( m_iTargetEntIndex )
{
C_BaseEntity *pEnt = cl_entitylist->GetEnt( m_iTargetEntIndex );
if ( pEnt )
{
if ( IsPlayerIndex( m_iTargetEntIndex ) )
{
C_TFPlayer *pPlayer = static_cast<C_TFPlayer*>( pEnt );
bool bDisguisedEnemy = false;
if ( pPlayer->m_Shared.InCond( TF_COND_DISGUISED ) && // they're disguised
!pPlayer->m_Shared.InCond( TF_COND_DISGUISING ) && // they're not in the process of disguising
!pPlayer->m_Shared.InCond( TF_COND_STEALTHED ) ) // they're not cloaked
{
bDisguisedEnemy = (ToTFPlayer( pPlayer->m_Shared.GetDisguiseTarget() ) != NULL);
}
bReturn = (pLocalTFPlayer->GetTeamNumber() == TEAM_SPECTATOR ||
pLocalTFPlayer->InSameTeam(pEnt) ||
(bDisguisedEnemy && pPlayer->m_Shared.GetDisguiseTeam() == pLocalTFPlayer->GetTeamNumber()) ||
(pLocalTFPlayer->IsPlayerClass( TF_CLASS_SPY ) && !pPlayer->m_Shared.InCond( TF_COND_STEALTHED )) );
}
else if ( pEnt->IsBaseObject() && (pLocalTFPlayer->InSameTeam( pEnt ) || pLocalTFPlayer->IsPlayerClass( TF_CLASS_SPY ) || pLocalTFPlayer->GetTeamNumber() == TEAM_SPECTATOR) )
{
bReturn = true;
}
else if ( pEnt->IsNPC() )
{
bReturn = ( pLocalTFPlayer->GetTeamNumber() == TEAM_SPECTATOR || pLocalTFPlayer->InSameTeam( pEnt ) || pLocalTFPlayer->IsPlayerClass( TF_CLASS_SPY ) );
}
}
}
if ( bReturn )
{
if ( !IsVisible() || (m_iTargetEntIndex != m_iLastEntIndex) )
{
m_iLastEntIndex = m_iTargetEntIndex;
m_bLayoutOnUpdate = true;
}
UpdateID();
}
return bReturn;
}
示例8: GetTargetIDString
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_BaseObject::GetTargetIDString( wchar_t *sIDString, int iMaxLenInBytes )
{
sIDString[0] = '\0';
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocalPlayer )
return;
if ( InSameTeam( pLocalPlayer ) || pLocalPlayer->IsPlayerClass( TF_CLASS_SPY ) || pLocalPlayer->GetTeamNumber() == TEAM_SPECTATOR )
{
wchar_t wszBuilderName[ MAX_PLAYER_NAME_LENGTH ];
const char *pszStatusName = GetStatusName();
wchar_t *wszObjectName = g_pVGuiLocalize->Find( pszStatusName );
if ( !wszObjectName )
{
wszObjectName = L"";
}
C_BasePlayer *pBuilder = GetOwner();
if ( pBuilder )
{
g_pVGuiLocalize->ConvertANSIToUnicode( pBuilder->GetPlayerName(), wszBuilderName, sizeof(wszBuilderName) );
}
else
{
wszBuilderName[0] = '\0';
}
// building or live, show health
const char *printFormatString;
if ( GetObjectInfo(GetType())->m_AltModes.Count() > 0 )
{
printFormatString = "#TF_playerid_object_mode";
pszStatusName = GetObjectInfo( GetType() )->m_AltModes.Element( m_iObjectMode * 3 + 1 );
wchar_t *wszObjectModeName = g_pVGuiLocalize->Find( pszStatusName );
if ( !wszObjectModeName )
{
wszObjectModeName = L"";
}
g_pVGuiLocalize->ConstructString( sIDString, iMaxLenInBytes, g_pVGuiLocalize->Find(printFormatString),
4,
wszObjectName,
wszBuilderName,
wszObjectModeName);
}
else
{
if ( m_bMiniBuilding )
printFormatString = "#TF_playerid_object_mini";
else
printFormatString = "#TF_playerid_object";
g_pVGuiLocalize->ConstructString( sIDString, iMaxLenInBytes, g_pVGuiLocalize->Find( printFormatString ),
3,
wszObjectName,
wszBuilderName );
}
}
}