本文整理汇总了C++中C_BaseObject::GetTeamNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ C_BaseObject::GetTeamNumber方法的具体用法?C++ C_BaseObject::GetTeamNumber怎么用?C++ C_BaseObject::GetTeamNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_BaseObject
的用法示例。
在下文中一共展示了C_BaseObject::GetTeamNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 ) )
//.........这里部分代码省略.........
示例2: FireGameEvent
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFFreezePanel::FireGameEvent( IGameEvent * event )
{
const char *pEventName = event->GetName();
if ( Q_strcmp( "player_death", pEventName ) == 0 )
{
// see if the local player died
int iPlayerIndexVictim = engine->GetPlayerForUserID( event->GetInt( "userid" ) );
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( pLocalPlayer && iPlayerIndexVictim == pLocalPlayer->entindex() )
{
// the local player is dead, see if this is a new nemesis or a revenge
if ( event->GetInt( "dominated" ) > 0 )
{
m_iShowNemesisPanel = SHOW_NEW_NEMESIS;
}
else if ( event->GetInt( "revenge" ) > 0 )
{
m_iShowNemesisPanel = SHOW_REVENGE;
}
else
{
m_iShowNemesisPanel = SHOW_NO_NEMESIS;
}
}
}
else if ( Q_strcmp( "hide_freezepanel", pEventName ) == 0 )
{
Hide();
}
else if ( Q_strcmp( "freezecam_started", pEventName ) == 0 )
{
ShowCalloutsIn( 1.0 );
ShowSnapshotPanelIn( 1.25 );
}
else if ( Q_strcmp( "teamplay_win_panel", pEventName ) == 0 )
{
Hide();
}
else if ( Q_strcmp( "show_freezepanel", pEventName ) == 0 )
{
C_TF_PlayerResource *tf_PR = dynamic_cast<C_TF_PlayerResource *>(g_PR);
if ( !tf_PR )
{
m_pNemesisSubPanel->SetDialogVariable( "nemesisname", NULL );
return;
}
Show();
ShowSnapshotPanel( false );
m_bHoldingAfterScreenshot = false;
if ( m_iBasePanelOriginalX > -1 && m_iBasePanelOriginalY > -1 )
{
m_pBasePanel->SetPos( m_iBasePanelOriginalX, m_iBasePanelOriginalY );
}
// Get the entity who killed us
m_iKillerIndex = event->GetInt( "killer" );
C_BaseEntity *pKiller = ClientEntityList().GetBaseEntity( m_iKillerIndex );
int xp,yp;
GetPos( xp, yp );
if ( TFGameRules()->RoundHasBeenWon() )
{
SetPos( xp, m_iYBase - YRES(50) );
}
else
{
SetPos( xp, m_iYBase );
}
if ( pKiller )
{
CTFPlayer *pPlayer = ToTFPlayer ( pKiller );
int iMaxBuffedHealth = 0;
if ( pPlayer )
{
iMaxBuffedHealth = pPlayer->m_Shared.GetMaxBuffedHealth();
}
int iKillerHealth = pKiller->GetHealth();
if ( !pKiller->IsAlive() )
{
iKillerHealth = 0;
}
m_pKillerHealth->SetHealth( iKillerHealth, pKiller->GetMaxHealth(), iMaxBuffedHealth );
if ( pKiller->IsPlayer() )
{
C_TFPlayer *pVictim = C_TFPlayer::GetLocalTFPlayer();
CTFPlayer *pTFKiller = ToTFPlayer( pKiller );
// Set the BG according to the team they're on
m_pFreezePanelBG->SetBGImage( pTFKiller->GetTeamNumber() );
//.........这里部分代码省略.........
示例3: HighlightBuildPoints
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_BaseObject::HighlightBuildPoints( int flags )
{
C_TFPlayer *pLocal = C_TFPlayer::GetLocalTFPlayer();
if ( !pLocal )
return;
if ( !GetNumBuildPoints() || !InLocalTeam() )
return;
C_TFWeaponBuilder *pBuilderWpn = dynamic_cast< C_TFWeaponBuilder * >( pLocal->GetActiveWeaponForSelection() );
if ( !pBuilderWpn )
return;
if ( !pBuilderWpn->IsPlacingObject() )
return;
C_BaseObject *pPlacementObj = pBuilderWpn->GetPlacementModel();
if ( !pPlacementObj || pPlacementObj == this )
return;
// Near enough?
if ( (GetAbsOrigin() - pLocal->GetAbsOrigin()).LengthSqr() < MAX_VISIBLE_BUILDPOINT_DISTANCE )
{
bool bRestoreModel = false;
Vector vecPrevAbsOrigin = pPlacementObj->GetAbsOrigin();
QAngle vecPrevAbsAngles = pPlacementObj->GetAbsAngles();
Vector orgColor;
render->GetColorModulation( orgColor.Base() );
float orgBlend = render->GetBlend();
bool bSameTeam = ( pPlacementObj->GetTeamNumber() == GetTeamNumber() );
if ( pPlacementObj->IsHostileUpgrade() && bSameTeam )
{
// Don't hilight hostile upgrades on friendly objects
return;
}
else if ( !bSameTeam )
{
// Don't hilight upgrades on enemy objects
return;
}
// Any empty buildpoints?
for ( int i = 0; i < GetNumBuildPoints(); i++ )
{
// Can this object build on this point?
if ( CanBuildObjectOnBuildPoint( i, pPlacementObj->GetType() ) )
{
Vector vecBPOrigin;
QAngle vecBPAngles;
if ( GetBuildPoint(i, vecBPOrigin, vecBPAngles) )
{
pPlacementObj->InvalidateBoneCaches();
Vector color( 0, 255, 0 );
render->SetColorModulation( color.Base() );
float frac = fmod( gpGlobals->curtime, 3 );
frac *= 2 * M_PI;
frac = cos( frac );
render->SetBlend( (175 + (int)( frac * 75.0f )) / 255.0 );
// FIXME: This truly sucks! The bone cache should use
// render location for this computation instead of directly accessing AbsAngles
// Necessary for bone cache computations to work
pPlacementObj->SetAbsOrigin( vecBPOrigin );
pPlacementObj->SetAbsAngles( vecBPAngles );
modelrender->DrawModel(
flags,
pPlacementObj,
pPlacementObj->GetModelInstance(),
pPlacementObj->index,
pPlacementObj->GetModel(),
vecBPOrigin,
vecBPAngles,
pPlacementObj->m_nSkin,
pPlacementObj->m_nBody,
pPlacementObj->m_nHitboxSet
);
bRestoreModel = true;
}
}
}
if ( bRestoreModel )
{
pPlacementObj->SetAbsOrigin(vecPrevAbsOrigin);
pPlacementObj->SetAbsAngles(vecPrevAbsAngles);
pPlacementObj->InvalidateBoneCaches();
render->SetColorModulation( orgColor.Base() );
render->SetBlend( orgBlend );
}
}
}