コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::InputRoundSpawn( inputdata_t &inputdata )
{
	// find the flag we're linked to
	if( !m_hPoint )
	{
		m_hPoint = dynamic_cast<CTeamControlPoint*>( gEntList.FindEntityByName(NULL, STRING(m_iszCapPointName) ) );

		if ( m_hPoint )
		{
			m_nOwningTeam = m_hPoint->GetOwner();

			for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
			{
				m_hPoint->SetCappersRequiredForTeam( i, m_TeamData[i].iNumRequiredToCap );

				ObjectiveResource()->SetCPRequiredCappers( m_hPoint->GetPointIndex(), i, m_TeamData[i].iNumRequiredToCap );
				ObjectiveResource()->SetTeamCanCap( m_hPoint->GetPointIndex(), i, m_TeamData[i].bCanCap );

				if ( CaptureModeScalesWithPlayers() )
				{
					ObjectiveResource()->SetCPCapTime( m_hPoint->GetPointIndex(), i, (m_flCapTime * 2) * m_TeamData[i].iNumRequiredToCap );
				}
				else
				{
					ObjectiveResource()->SetCPCapTime( m_hPoint->GetPointIndex(), i, m_flCapTime );
				}

				ObjectiveResource()->SetCPCapTimeScalesWithPlayers( m_hPoint->GetPointIndex(), CaptureModeScalesWithPlayers() );
			}
		}
	}
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: Create the icons we need to display the state of this map's control points
//-----------------------------------------------------------------------------
void CHudControlPointIcons::InitIcons( void )
{
	ShutdownIcons();

	CTFHudObjectiveStatus *pStatus = GET_HUDELEMENT( CTFHudObjectiveStatus );
	if ( pStatus )
	{
		CControlPointProgressBar *pProgressBar = pStatus->GetControlPointProgressBar();

		if ( pProgressBar )
		{
			m_iCurrentCP = -1;
			pProgressBar->SetupForPoint( NULL );
		}
	}

	// Create an icon for each visible control point in this miniround
	int iPoints = ObjectiveResource()->GetNumControlPoints();
	for ( int i = 0; i < iPoints; i++ )
	{
		if ( ObjectiveResource()->IsInMiniRound(i) && ObjectiveResource()->IsCPVisible(i) )
		{
			CControlPointIcon *pIcon = new CControlPointIcon( this, VarArgs( "ControlPointIcon%d", i ), i );
			m_Icons.AddToTail( vgui::SETUP_PANEL(pIcon) );
		}
	}

	InvalidateLayout();
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointIcon::UpdateImage( void )
{
	int iOwner = ObjectiveResource()->GetOwningTeam( m_iCPIndex );

	if ( m_pBaseImage )
	{
		int iOwnerIcon = ObjectiveResource()->GetCPCurrentOwnerIcon( m_iCPIndex, iOwner );
		const char *szMatName = GetMaterialNameFromIndex( iOwnerIcon );

		if ( IsPointLocked() )
		{
			m_pBaseImage->SetImage( VarArgs("..\\%s_locked", szMatName ) );
		}
		else
		{
			m_pBaseImage->SetImage( VarArgs("..\\%s", szMatName ) );
		}
	}

	if ( m_pOverlayImage )
	{
		int iOverlayIcon = ObjectiveResource()->GetOverlayForTeam( m_iCPIndex, iOwner );
		if ( iOverlayIcon )
		{
			const char *szMatName = GetMaterialNameFromIndex( iOverlayIcon );
			m_pOverlayImage->SetImage( VarArgs("..\\%s", szMatName ) );
			m_pOverlayImage->SetVisible( true );
		}
		else
		{
			m_pOverlayImage->SetVisible( false );
		}
	}

	// Whenever a successful cap occurs, flash the cap point
	if ( m_pCapPulseImage )
	{
		if ( m_iPrevCappers != 0 && iOwner == m_iPrevCappers )
		{
			m_iPrevCappers = 0;

			if ( ShouldDraw() )
			{
				m_pCapPulseImage->SetVisible( true );
				m_pCapPulseImage->StartPulse( gpGlobals->curtime, GetWide() );
			}
			m_pBaseImage->StartPulsing( FINISHCAPANIM_SWOOP_LENGTH, 0.5, false );
		}
		
	}
}
コード例 #4
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudControlPointIcons::Paint()
{
	if ( IsInFreezeCam() == true )
		return;

	if( !ObjectiveResource() )
		return;

	int num = ObjectiveResource()->GetNumControlPoints();
	if ( num <= 0 )
		return; // nothing to draw yet

	//DrawBackgroundBox( 0, 0, GetWide(), GetTall(), false );
	BaseClass::Paint();
}
コード例 #5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::UpdateCappingTeam( int iTeam )
{
	if ( m_hPoint )
	{
		ObjectiveResource()->SetCappingTeam( m_hPoint->GetPointIndex(), iTeam );
	}
}
コード例 #6
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::InputSetTeamCanCap( inputdata_t &inputdata )
{
	// Get the interaction name & target
	char parseString[255];
	Q_strncpy(parseString, inputdata.value.String(), sizeof(parseString));

	char *pszParam = strtok(parseString," ");
	if ( pszParam && pszParam[0] )
	{
		int iTeam = atoi( pszParam );
		pszParam = strtok(NULL," ");

		if ( pszParam && pszParam[0] )
		{
			bool bCanCap = (atoi(pszParam) != 0);

			if ( iTeam >= 0 && iTeam < GetNumberOfTeams() )
			{
				m_TeamData[iTeam].bCanCap = bCanCap;
				if ( m_hPoint )
				{
					ObjectiveResource()->SetTeamCanCap( m_hPoint->GetPointIndex(), iTeam, m_TeamData[iTeam].bCanCap );
				}
				return;
			}
		}
	}

	Warning("%s(%s) received SetTeamCanCap input with invalid format. Format should be: <team number> <can cap (0/1)>.\n", GetClassname(), GetDebugName() );
}
コード例 #7
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::UpdateTeamInZone( void )
{
	if ( m_hPoint )
	{
		ObjectiveResource()->SetTeamInZone( m_hPoint->GetPointIndex(), m_nTeamInZone );
	}
}
コード例 #8
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamRoundTimer::SetActiveTimer( CTeamRoundTimer *pNewlyActive )
{
	CBaseEntity *pChosenTimer = pNewlyActive;	

	// Ensure all other timers are off.
	CBaseEntity *pEntity = NULL;
	while ((pEntity = gEntList.FindEntityByClassname( pEntity, "team_round_timer" )) != NULL)
	{
		if ( pEntity == pNewlyActive )
			continue;

		CTeamRoundTimer *pTimer = assert_cast< CTeamRoundTimer* >( pEntity );
		if ( !pTimer->IsDisabled() && pTimer->ShowInHud() )
		{
			if ( pChosenTimer )
			{
				// Turn off all other hud timers
				pTimer->SetShowInHud( false );
			}
			else
			{
				// Found a timer. Use it.
				pChosenTimer = pTimer;
			}
		}
	}

	ObjectiveResource()->SetTimerInHUD( pChosenTimer );
}
コード例 #9
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudControlPointIcons::UpdateProgressBarFor( int iIndex )
{
	// If they tell us to update all progress bars, update only the one we're standing on
	if ( iIndex == -1 )
	{
		iIndex = m_iCurrentCP;
	}

	// Ignore requests to display progress bars for points we're not standing on
	if ( ( m_iCurrentCP != iIndex ) )
		return;

	// This can happen at level load
	CTFHudObjectiveStatus *pStatus = GET_HUDELEMENT( CTFHudObjectiveStatus );
	if ( pStatus && pStatus->GetControlPointProgressBar() )
	{
		CControlPointProgressBar *pProgressBar = pStatus->GetControlPointProgressBar();
		if ( !IsVisible() || iIndex < 0 || iIndex >= ObjectiveResource()->GetNumControlPoints() )
		{
			pProgressBar->SetupForPoint( NULL );
		}
		else
		{
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				if ( m_Icons[i]->GetCapIndex() == iIndex )
				{
					pProgressBar->SetupForPoint( m_Icons[i] );
					break;
				}
			}
		}
	}
}
コード例 #10
0
//-----------------------------------------------------------------------------
// Purpose: Used by Area caps to set the owner
//-----------------------------------------------------------------------------
void CTeamControlPoint::InputSetOwner( inputdata_t &input )
{
	int iCapTeam = input.value.Int();

	Assert( iCapTeam >= 0 && iCapTeam < GetNumberOfTeams() );

	Assert( input.pCaller );

	if ( GetOwner() == iCapTeam )
		return;

	if ( TeamplayGameRules()->PointsMayBeCaptured() )
	{
		// must be done before setting the owner
		HandleScoring( iCapTeam );

		if ( input.pCaller->IsPlayer() )
		{
			int iCappingPlayer = input.pCaller->entindex();
			InternalSetOwner( iCapTeam, true, 1, &iCappingPlayer );
		}
		else
		{
			InternalSetOwner( iCapTeam, false );
		}

		ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
	}
}
コード例 #11
0
//-----------------------------------------------------------------------------
// Purpose: Used by ControlMaster to this point to its default owner
//-----------------------------------------------------------------------------
void CTeamControlPoint::InputReset( inputdata_t &input )
{
	m_flLastContestedAt = -1;
	InternalSetOwner( m_iDefaultOwner, false );
	ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
	TeamplayRoundBasedRules()->RecalculateControlPointState();
}
コード例 #12
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::UpdateOwningTeam( void )
{
	if ( m_hPoint )
	{
		ObjectiveResource()->SetOwningTeam( m_hPoint->GetPointIndex(), m_nOwningTeam );
	}
}
コード例 #13
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::UpdateBlocked( void )
{
	if ( m_hPoint )
	{
		ObjectiveResource()->SetCapBlocked( m_hPoint->GetPointIndex(), m_bBlocked );
		m_hPoint->CaptureInterrupted( m_bBlocked );
	}
}
コード例 #14
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointProgressBar::SetupForPoint( CControlPointIcon *pIcon )
{
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return;

	m_pAttachedToIcon = pIcon;

	bool bInWinState = TeamplayRoundBasedRules() ? TeamplayRoundBasedRules()->RoundHasBeenWon() : false;

	if ( m_pAttachedToIcon && !bInWinState )
	{
		SetVisible( true );

		int iCP = m_pAttachedToIcon->GetCapIndex();
		int iCappingTeam = ObjectiveResource()->GetCappingTeam( iCP );
		int iOwnerTeam = ObjectiveResource()->GetOwningTeam( iCP );
		int iPlayerTeam = pPlayer->GetTeamNumber();
		bool bCapBlocked = ObjectiveResource()->CapIsBlocked( iCP );

		if ( !bCapBlocked && iCappingTeam != TEAM_UNASSIGNED && iCappingTeam != iOwnerTeam && iCappingTeam == iPlayerTeam )
		{
			m_pBar->SetBgImage( ObjectiveResource()->GetGameSpecificCPBarBG( iCP, iCappingTeam ) );
			m_pBar->SetFgImage( ObjectiveResource()->GetGameSpecificCPBarFG( iCP, iOwnerTeam ) );
			m_pBar->SetVisible( true );
			m_pBlocked->SetVisible( false );
			m_pBarText->SetVisible( false );
		}
		else
		{
			m_pBar->SetVisible( false );
			m_pBlocked->SetVisible( true );
			
			UpdateBarText();
		}

		InvalidateLayout();
	}
	else
	{
		SetVisible( false );
	}
}
コード例 #15
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::InternalSetLocked( bool bLocked )
{
	if ( !bLocked && m_bLocked )
	{
		// unlocked this point
		IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_unlocked" );
		if ( event )
		{
			event->SetInt( "cp", m_iPointIndex );
			event->SetString( "cpname", STRING( m_iszPrintName ) );
			event->SetInt( "team", m_iTeam );
			gameeventmanager->FireEvent( event );
		}
	}
	else if ( bLocked && !m_bLocked )
	{
		// locked this point
		IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_locked" );
		if ( event )
		{
			event->SetInt( "cp", m_iPointIndex );
			event->SetString( "cpname", STRING( m_iszPrintName ) );
			event->SetInt( "team", m_iTeam );
			gameeventmanager->FireEvent( event );
		}
	}

	m_bLocked = bLocked;

	if ( ObjectiveResource() && GetPointIndex() < ObjectiveResource()->GetNumControlPoints() )
	{
		ObjectiveResource()->SetCPLocked( GetPointIndex(), m_bLocked );
		ObjectiveResource()->SetCPUnlockTime( GetPointIndex(), 0.0f );
	}

	if ( !m_bLocked )
	{
		m_flUnlockTime = -1;
		m_OnUnlocked.FireOutput( this, this );
		SetContextThink( NULL, 0, CONTROL_POINT_UNLOCK_THINK );
	}
}
コード例 #16
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
float CTeamControlPoint::GetTeamCapPercentage( int iTeam )
{
	int iCappingTeam = ObjectiveResource()->GetCappingTeam( GetPointIndex() );
	if ( iCappingTeam == TEAM_UNASSIGNED )
	{
		// No-one's capping this point.
		if ( iTeam == m_iTeam )
			return 1.0;

		return 0.0;
	}

	float flCapPerc = ObjectiveResource()->GetCPCapPercentage( GetPointIndex() );
	if ( iTeam == iCappingTeam )
		return (1.0 - flCapPerc);
	if ( iTeam == m_iTeam )
		return flCapPerc;

	return 0.0;
}
コード例 #17
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::SetOwner( int iCapTeam, bool bMakeSound, int iNumCappers, int *pCappingPlayers )
{
	if ( TeamplayGameRules()->PointsMayBeCaptured() )
	{
		// must be done before setting the owner
		HandleScoring( iCapTeam );

		InternalSetOwner( iCapTeam, bMakeSound, iNumCappers, pCappingPlayers );
		ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
	}
}
コード例 #18
0
//-----------------------------------------------------------------------------
// Purpose: Lock cap points when neither team can cap them for map-specific reasons
//-----------------------------------------------------------------------------
bool CControlPointIcon::IsPointLocked( void )
{
	bool bAnyTeamCanCap = false;
	for ( int gameteam = FIRST_GAME_TEAM; gameteam < GetNumberOfTeams(); gameteam++ )
	{
		// Ignore teams that already own the point
		if ( ObjectiveResource()->GetOwningTeam(m_iCPIndex) != gameteam )
		{
			if ( (ObjectiveResource()->TeamCanCapPoint( m_iCPIndex, gameteam)) )
			{
				if ( TeamplayGameRules()->TeamMayCapturePoint( gameteam, m_iCPIndex ) )
				{
					bAnyTeamCanCap = true;
				}
			}
		}
	}

	return ( !bAnyTeamCanCap );
}
コード例 #19
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointProgressBar::Paint( void )
{
	if ( m_pAttachedToIcon )
	{
		int iCP = m_pAttachedToIcon->GetCapIndex();
		if ( m_pBar && m_pBar->IsVisible() )
		{						
			m_pBar->SetProgress( ObjectiveResource()->GetCPCapPercentage( iCP ) );
		}
	}

	BaseClass::Paint();
}
コード例 #20
0
//-----------------------------------------------------------------------------
// Purpose: Draw the team's base icon at either end of the icon panel
//-----------------------------------------------------------------------------
bool CHudControlPointIcons::PaintTeamBaseIcon( int index, float flXPos, float flYPos, float flIconSize )
{
	float uv1 = 0.0f;
	float uv2 = 1.0f;

	// Find out which team owns the far left
	for ( int i = 0; i < MAX_TEAMS; i++ )
	{
		if ( ObjectiveResource()->GetBaseControlPointForTeam(i) == index )
		{
			int iTeamBaseIcon = ObjectiveResource()->GetBaseIconForTeam(i);
			if ( iTeamBaseIcon )
			{
				// Draw the Team's Base texture
				const char *szMatName = GetMaterialNameFromIndex( iTeamBaseIcon );

				vgui::surface()->DrawSetTextureFile( m_iTeamBaseTextures[i], szMatName, true, false );

				Vector2D uv11( uv1, uv1 );
				Vector2D uv21( uv2, uv1 );
				Vector2D uv22( uv2, uv2 );
				Vector2D uv12( uv1, uv2 );

				vgui::Vertex_t vert[4];	
				vert[0].Init( Vector2D( flXPos,					flYPos              ), uv11 );
				vert[1].Init( Vector2D( flXPos + flIconSize,	flYPos              ), uv21 );
				vert[2].Init( Vector2D( flXPos + flIconSize,	flYPos + flIconSize ), uv22 );				
				vert[3].Init( Vector2D( flXPos,					flYPos + flIconSize ), uv12 );

				vgui::surface()->DrawSetColor( Color(255,255,255,255) );	
				vgui::surface()->DrawTexturedPolygon( 4, vert );

				return true;
			}
		}
	}

	return false;
}
コード例 #21
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::InputSetUnlockTime( inputdata_t &inputdata )
{
	// never lock/unlock the point if we're in waiting for players
	if ( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->IsInWaitingForPlayers() )
		return;

	int nTime = inputdata.value.Int();

	if ( nTime <= 0 )
	{
		InternalSetLocked( false );
		return;
	}

	m_flUnlockTime = gpGlobals->curtime + nTime;

	if ( ObjectiveResource() )
	{
		ObjectiveResource()->SetCPUnlockTime( GetPointIndex(), m_flUnlockTime );
	}

	SetContextThink( &CTeamControlPoint::UnlockThink, gpGlobals->curtime + 0.1, CONTROL_POINT_UNLOCK_THINK );
}
コード例 #22
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CTeamControlPoint::DrawDebugTextOverlays( void ) 
{
	int text_offset = BaseClass::DrawDebugTextOverlays();

	if (m_debugOverlays & OVERLAY_TEXT_BIT) 
	{
		char tempstr[1024];
		Q_snprintf(tempstr, sizeof(tempstr), "INDEX: (%d)", GetPointIndex() );
		EntityText(text_offset,tempstr,0);
		text_offset++;

		Q_snprintf( tempstr, sizeof(tempstr), "Red Previous Points: ");
		for ( int i = 0; i < MAX_PREVIOUS_POINTS; i++ )
		{
			if ( m_TeamData[2].iszPreviousPoint[i] != NULL_STRING )
			{
				Q_strncat( tempstr, STRING(m_TeamData[2].iszPreviousPoint[i]), 1024, COPY_ALL_CHARACTERS );
				Q_strncat( tempstr, ", ", 1024, COPY_ALL_CHARACTERS );
			}
		}
		EntityText(text_offset,tempstr,0);
		text_offset++;

		Q_snprintf( tempstr, sizeof(tempstr), "Blue Previous Points: " );
		for ( int i = 0; i < MAX_PREVIOUS_POINTS; i++ )
		{
			if ( m_TeamData[3].iszPreviousPoint[i] != NULL_STRING )
			{
				Q_strncat( tempstr, STRING(m_TeamData[3].iszPreviousPoint[i]), 1024, COPY_ALL_CHARACTERS );
				Q_strncat( tempstr, ", ", 1024, COPY_ALL_CHARACTERS );
			}
		}
		EntityText(text_offset,tempstr,0);
		text_offset++;

		for ( int i = 0; i < MAX_CONTROL_POINT_TEAMS; i++ )
		{
			if ( ObjectiveResource()->GetBaseControlPointForTeam(i) == GetPointIndex() )
			{
				Q_snprintf(tempstr, sizeof(tempstr), "Base Control Point for Team %d", i );
				EntityText(text_offset,tempstr,0);
				text_offset++;
			}
		}
	}

	return text_offset;
}
コード例 #23
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::UpdateNumPlayers( void )
{
	if( !m_hPoint )
		return;

	int index = m_hPoint->GetPointIndex();
	for ( int i = 0; i < m_TeamData.Count(); i++ )
	{
		if ( i >= FIRST_GAME_TEAM && i == m_nCapturingTeam )
		{
			m_OnNumCappersChanged.Set( m_TeamData[i].iNumTouching, this, this );
		}

		ObjectiveResource()->SetNumPlayers( index, i, m_TeamData[i].iNumTouching );
	}
}
コード例 #24
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::UpdateNumPlayers( bool bBlocked /*= false */ )
{
	if( !m_hPoint )
		return;

	int index = m_hPoint->GetPointIndex();
	for ( int i = 0; i < m_TeamData.Count(); i++ )
	{
		if ( i >= FIRST_GAME_TEAM && i == m_nCapturingTeam )
		{
			SetNumCappers( m_TeamData[i].iNumTouching, bBlocked );
		}

		ObjectiveResource()->SetNumPlayers( index, i, m_TeamData[i].iNumTouching );
	}
}
コード例 #25
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointIconPulseable::PaintBackground( void )
{
	if ( IsInFreezeCam() == true )
		return;

	if ( GetImage() )
	{
		SetAlpha(255);
		BaseClass::PaintBackground();
	}

	if ( m_flStartCapAnimStart && gpGlobals->curtime > m_flStartCapAnimStart )
	{
		float flElapsedTime = (gpGlobals->curtime - m_flStartCapAnimStart);

		// Pulse the white over the underlying color
		float flPulseSpeed = 20;
		if ( m_bAccelerateOverCapture )
		{
			float flCapPercentage = ObjectiveResource()->GetCPCapPercentage( m_iCPIndex );
			flPulseSpeed = RemapValClamped( flCapPercentage, 0, 1, 2, 5 );
		}

		float flPulseMod = fabs(sin( flElapsedTime * flPulseSpeed ));
		SetAlpha( 255 * flPulseMod );

		int wide, tall;
		GetSize( wide, tall );

		// Have to reset these - we're only referencing a material so the
		// size can be changed by CControlPointIconCapturePulse on a successful cap
		m_pPulseImage->SetPos( 0, 0 );
		m_pPulseImage->SetSize( wide, tall );

		m_pPulseImage->Paint();

		// Stop if we're only supposed to do this for a short time
		if ( m_flPulseTime && flElapsedTime >= m_flPulseTime )
		{
			StopPulsing();
		}
	}
}
コード例 #26
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::SetCapTimeRemaining( float flTime )
{
	m_fTimeRemaining = flTime;

	float flCapPercentage = 0;
	if ( m_nCapturingTeam )
	{
		flCapPercentage = m_fTimeRemaining / m_flCapTime;
		if ( CaptureModeScalesWithPlayers() )
		{
			flCapPercentage = m_fTimeRemaining / ((m_flCapTime * 2) * m_TeamData[m_nCapturingTeam].iNumRequiredToCap);
		}
	}

	ObjectiveResource()->SetCPCapPercentage( m_hPoint->GetPointIndex(), flCapPercentage );

	if ( m_hPoint )
	{
		m_hPoint->UpdateCapPercentage();
	}
}
コード例 #27
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointIconCapArrow::Paint( void )
{
	if ( !m_pArrowMaterial || !m_pAttachedToIcon )
		return;

	int x = 0;
	int y = 0;
	ipanel()->GetAbsPos(GetVPanel(), x,y );
	int iWidth = GetWide();
	int iHeight = GetTall();

	// Position the arrow based on the cap percentage
	float flXa = 0;
	float flXb = 1.0;
	float flYa = 0;
	float flYb = 1.0;

	int iCappingTeam = ObjectiveResource()->GetCappingTeam( m_pAttachedToIcon->GetCapIndex() );
	float flCapPercentage = ObjectiveResource()->GetCPCapPercentage( m_pAttachedToIcon->GetCapIndex() );

	// The image needs to be remapped to the width of the underlying box,
	// because we want the arrow head to move off the box at the exact time the cap ends.
	float flArrowHeadPixelWidth = 15.0;
	float flArrowBodyPixelWidth = 54.0;
	float flBoxSize = 33.0;

	// HACK: The arrow has an arrowhead portion that looks like this: >
	// We want to start with the arrow entering the image, but we want to keep
	// going until the arrow is fully off the edge. So we include extra width for it.
	float flImageSize = (flArrowHeadPixelWidth+flArrowBodyPixelWidth);
	float flMovementInTextureSpace = ( (flBoxSize+flArrowHeadPixelWidth) / flImageSize );
	float flArrowSizeInTextureSpace = ( flArrowHeadPixelWidth / flImageSize );

	// To help players spot the start & end of a cap, we indent a little on either side.
	float flIndent = 0.07;

	if ( m_pAttachedToIcon->ShouldSwipeUp() )
	{
		flYa = RemapVal( flCapPercentage, 0.0, 1.0, -flMovementInTextureSpace - flIndent, flArrowSizeInTextureSpace - flIndent );
		flYb = RemapVal( flCapPercentage, 0.0, 1.0, flIndent, flMovementInTextureSpace - flIndent );
	}
	else
	{
		flIndent = 0.1;

		float flStart = 1.0 - flIndent;
		float flEnd = 1.0 + flIndent;

		bool bSwipeLeftToRight = ( iCappingTeam % 2 ) ? false : true;
		if ( bSwipeLeftToRight )
		{
			flXa = RemapVal( flCapPercentage, 0.0, 1.0, flStart + flMovementInTextureSpace, flEnd - flArrowSizeInTextureSpace );
			flXb = RemapVal( flCapPercentage, 0.0, 1.0, flStart, 0.0 );
		}
		else
		{
			flXa = RemapVal( flCapPercentage, 0.0, 1.0, flStart, 0.0 );
			flXb = RemapVal( flCapPercentage, 0.0, 1.0, flStart + flMovementInTextureSpace, flEnd - flArrowSizeInTextureSpace );
		}
	}

	CMatRenderContextPtr pRenderContext( materials );
	pRenderContext->Bind( m_pArrowMaterial );
	IMesh* pMesh = pRenderContext->GetDynamicMesh( true );

	CMeshBuilder meshBuilder;
	meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );

	meshBuilder.Position3f( x, y, 0.0f );
	meshBuilder.TexCoord2f( 0, flXa, flYa );
	meshBuilder.TexCoord2f( 1, 0.0f, 0.0f );
	meshBuilder.Color4ub( 255, 255, 255, 255 );
	meshBuilder.AdvanceVertex();

	meshBuilder.Position3f( x + iWidth, y, 0.0f );
	meshBuilder.TexCoord2f( 0, flXb, flYa );
	meshBuilder.TexCoord2f( 1, 1.0f, 0.0f );
	meshBuilder.Color4ub( 255, 255, 255, 255 );
	meshBuilder.AdvanceVertex();

	meshBuilder.Position3f( x + iWidth, y + iHeight, 0.0f );
	meshBuilder.TexCoord2f( 0, flXb, flYb );
	meshBuilder.TexCoord2f( 1, 1.0f, 1.0f );
	meshBuilder.Color4ub( 255, 255, 255, 255 );
	meshBuilder.AdvanceVertex();

	meshBuilder.Position3f( x, y + iHeight, 0.0f );
	meshBuilder.TexCoord2f( 0, flXa, flYb );
	meshBuilder.TexCoord2f( 1, 0.0f, 1.0f );
	meshBuilder.Color4ub( 255, 255, 255, 255 );
	meshBuilder.AdvanceVertex();

	meshBuilder.End();
	pMesh->Draw();
}
コード例 #28
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudControlPointIcons::PerformLayout( void )
{
	BaseClass::PerformLayout();

	int iCapPointLines[MAX_CONTROL_POINTS][MAX_CONTROL_POINTS];
	memset( iCapPointLines, 0, sizeof(int) * MAX_CONTROL_POINTS * MAX_CONTROL_POINTS );
	bool bUseDefaultLines = true;
	if ( ObjectiveResource() )
	{
		// Allow the objective resource to override it
		const char *pszLayout = ObjectiveResource()->GetCapLayoutInHUD();
		if ( pszLayout && pszLayout[0] )
		{
			bUseDefaultLines = false;

			// Cap layout is a string with indexes of cap points seperated by ',' to denote
			// a new line. So "3,1 2" would create a pyramid, with cap point 3 on the 
			// first line, and caps 1 & 2 on the second line.
			int iLine = 0;
			int iCapIndex = 0;
			char szBuffer[MAX_CAPLAYOUT_LENGTH];
			Q_strncpy( szBuffer, pszLayout, MAX_CAPLAYOUT_LENGTH );
			char *pszChar = szBuffer;
			char *pszLastNumber = pszChar;
			while ( *pszChar )
			{
				pszChar++;

				if ( *pszChar == ' ' || *pszChar == ',' )
				{
					// Get the number
					char cOrg = *pszChar;
					*pszChar = '\0';

					int iCPIndex = atoi( pszLastNumber );
					int iIconIndex = -1;
					for (int i = 0; i < m_Icons.Count(); i++)
					{
						if ( m_Icons[i]->GetCapIndex() == iCPIndex )
						{
							iIconIndex = i;
							break;
						}
					}

					if ( iIconIndex != -1 )
					{
						iCapPointLines[iLine][iCapIndex] = iIconIndex+1;
						*pszChar = cOrg;
						if ( *pszChar == ',' )
						{
							iLine++;
							iCapIndex = 0;
						}
						else
						{
							iCapIndex++;
						}
					}

					// Walk past the ,/space
					pszChar++;
					pszLastNumber = pszChar;
				}
			}

			// Now get the trailing number
			int iCPIndex = atoi( pszLastNumber );
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				if ( m_Icons[i]->GetCapIndex() == iCPIndex )
				{
					iCapPointLines[iLine][iCapIndex] = i+1;
					break;
				}
			}
		}
	}
	
	if ( bUseDefaultLines )
	{
		// By default, put all the caps on a single line
		int iCPIndex = 0;
		for (int iIcon = 0; iIcon < m_Icons.Count(); iIcon++)
		{
			iCapPointLines[0][iCPIndex] = iIcon+1;
			iCPIndex++;
		}
	}

	int iTall = m_iIconGapHeight;
	int iTallest = m_iIconGapHeight;
	int iWidest = m_iIconGapWidth;
	int iTotalIconsPerLine[MAX_CONTROL_POINTS];
	int iLineWidth[MAX_CONTROL_POINTS];
	memset( iTotalIconsPerLine, 0, sizeof(int) * MAX_CONTROL_POINTS );
	memset( iLineWidth, 0, sizeof(int) * MAX_CONTROL_POINTS );
	int iTotalLines = 0;

	// Search through the lines and figure out our overall width & height
	for ( int iLine = 0; iLine < MAX_CONTROL_POINTS; iLine++ )
	{
		// If we've hit a line with nothing in it, we're done
		if ( !iCapPointLines[iLine][0] )
			break;

		iTotalLines++;

		iLineWidth[iLine] = m_iIconGapWidth;
		int iLineTall = 0;
		for ( int iPosition = 0; iPosition < MAX_CONTROL_POINTS; iPosition++ )
		{
			int iIconIndex = iCapPointLines[iLine][iPosition];
			if ( !iIconIndex )
				break;

			iIconIndex--;

			// Add the icon dimensions to our counts.
			if ( iIconIndex >= 0 && iIconIndex < m_Icons.Count() )
			{
				m_Icons[iIconIndex]->PerformLayout();
				iTotalIconsPerLine[iLine]++;

				iLineWidth[iLine] += m_Icons[iIconIndex]->GetWide() + m_iIconGapWidth;
				int iHeight = m_Icons[iIconIndex]->GetTall();
				if ( iHeight > iLineTall )
				{
					iLineTall = iHeight;
				}
			}
		}

		if ( iLineWidth[iLine] > iWidest )
		{
			iWidest = iLineWidth[iLine];
		}
		if ( iLineTall > iTallest )
		{
			iTallest = iLineTall;
		}
		iTall += iLineTall + m_iIconGapHeight;
	}

	// Setup the main panel
	SetBounds( (ScreenWidth() - iWidest) * 0.5, ScreenHeight() - iTall - m_nHeightOffset, iWidest, iTall );

	// Now that we know how wide we are, and how many icons are in each line, 
	// we can lay the icons out, centered in the lines.
	for ( int iLine = 0; iLine < MAX_CONTROL_POINTS; iLine++ )
	{
		if ( !iTotalIconsPerLine[iLine] )
			break;

		int iLineXPos = ((iWidest - iLineWidth[iLine]) * 0.5) + m_iIconGapWidth;
		int iLineYPos = (iLine * m_iIconGapHeight) + ( iLine * iTallest ) + m_iIconGapHeight;
		for ( int iPosition = 0; iPosition < MAX_CONTROL_POINTS; iPosition++ )
		{
			int iIconIndex = iCapPointLines[iLine][iPosition];
			if ( !iIconIndex )
				break;

			iIconIndex--;

			if ( iIconIndex >= 0 && iIconIndex < m_Icons.Count() )
			{
				m_Icons[iIconIndex]->SetPos( iLineXPos, iLineYPos );
				iLineXPos += m_Icons[iIconIndex]->GetWide() + m_iIconGapWidth;

				// If we have multiple lines, swipe up when capping
				m_Icons[iIconIndex]->SetSwipeUp( iTotalLines > 1 );

				// Set the progress extrusion dir:
				//		N if we're on the top line. Otherwise:
				//			NW if we're left of the center.
				//			NE if we're at or right of the center.
				int iDir = CP_DIR_N;
				if ( iLine > 0 )
				{
					if ( ((float)(iPosition+1) / (float)iTotalIconsPerLine[iLine]) > 0.5 )
					{
						iDir = CP_DIR_NE;
					}
					else
					{
						iDir = CP_DIR_NW;
					}
				}

				m_Icons[iIconIndex]->SetCapProgressDir( iDir );
			}
		}
	}
}
コード例 #29
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointIcon::PerformLayout( void )
{
	BaseClass::PerformLayout();

	int iBaseXPos, iBaseYPos;
	ipanel()->GetAbsPos(GetVPanel(), iBaseXPos, iBaseYPos );

	m_pBaseImage->SetBounds( 0, 0, GetWide(), GetTall() );

	if ( m_pCapImage->IsVisible() )
	{
		m_pCapImage->SetBounds( 0, 0, GetWide(), GetTall() );
	}

	if ( m_pCapHighlightImage->IsVisible() )
	{
		int iHeight = ScreenHeight() * 0.75;
		m_pCapHighlightImage->SetBounds( iBaseXPos + CAP_BOX_INDENT_X, iBaseYPos - iHeight, GetWide() - (CAP_BOX_INDENT_X*2), iHeight + GetTall() -CAP_BOX_INDENT_Y );
	}

	int iCappingTeam = ObjectiveResource()->GetCappingTeam( m_iCPIndex );
	int iPlayers = ObjectiveResource()->GetNumPlayersInArea( m_iCPIndex, iCappingTeam );
	if ( !m_pCapPlayerImage->IsVisible() && iPlayers )
	{
		m_pCapPlayerImage->SetVisible(true);
	}
	if ( m_pCapPlayerImage->IsVisible() )
	{
		if ( !iPlayers )
		{
			// We're a deteriorating point
			m_pCapPlayerImage->SetVisible( false );
			m_pCapNumPlayers->SetVisible( false );
		}
		else
		{
			int iXPos, iYPos;
			if ( iPlayers < 2 || !m_pCapNumPlayers )
			{
				iXPos = (GetWide() - m_pCapPlayerImage->GetWide()) * 0.5;
			}
			else
			{
				iXPos = (GetWide() - m_pCapPlayerImage->GetWide()) * 0.5 - XRES(4);
			}
			iYPos = (GetTall() - m_pCapPlayerImage->GetTall()) * 0.5;

			m_pCapPlayerImage->SetPos( iXPos, iYPos );

			if ( m_pCapNumPlayers )
			{
				m_pCapNumPlayers->SetVisible( (iPlayers>1) );
				SetDialogVariable( "numcappers", iPlayers );

				m_pCapNumPlayers->SetFgColor( Color(0,0,0,255) );
			}
		}
	}

	if ( m_pCapPulseImage )
	{
		int iSize = GetWide() * 3;
		int iXpos = iBaseXPos - ((iSize-GetWide()) * 0.5);
		int iYpos = iBaseYPos - ((iSize-GetTall()) * 0.5);
		m_pCapPulseImage->SetBounds( iXpos, iYpos, iSize, iSize );
	}
}
コード例 #30
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointIcon::UpdateCapImage( void )
{
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return;

	if ( m_pCapImage )
	{
		int iCappingTeam = ObjectiveResource()->GetCappingTeam( m_iCPIndex );
		int iOwningTeam = ObjectiveResource()->GetOwningTeam( m_iCPIndex );

		if ( iCappingTeam != TEAM_UNASSIGNED && iCappingTeam != iOwningTeam )
		{
			const char *pszCapSwipe = ObjectiveResource()->GetGameSpecificCPCappingSwipe( m_iCPIndex, iCappingTeam );
			if ( m_bSwipeUp )
			{
				m_pCapImage->SetImage( VarArgs("%s_up",pszCapSwipe)  );
			}
			else
			{
				m_pCapImage->SetImage( pszCapSwipe );
			}
			m_pCapImage->SetVisible( true );

			// Tell the cap highlight image to fire up if it's our point being capped
			if ( m_pCapHighlightImage && pPlayer->GetTeamNumber() != iCappingTeam && pPlayer->GetTeamNumber() > LAST_SHARED_TEAM )
			{
				if ( ShouldDraw() && GetParent() && GetParent()->IsVisible() )
				{
					m_pCapHighlightImage->SetVisible( true );
					m_pCapHighlightImage->StartSwoop();
				}
				m_pBaseImage->StartPulsing( STARTCAPANIM_ICON_SWITCH, 0, true );
			}
			else
			{
				m_pBaseImage->StartPulsing( 0, 0, true );
			}

			if ( m_pCapPlayerImage )
			{
				m_pCapPlayerImage->SetVisible( true );
			}

			m_iPrevCappers = iCappingTeam;
			InvalidateLayout( true );
		}
		else
		{
			m_pBaseImage->StopPulsing();
			m_pCapImage->SetVisible( false );
			if ( m_pCapHighlightImage )
			{
				m_pCapHighlightImage->SetVisible( false );
			}
			if ( m_pCapPlayerImage )
			{
				m_pCapPlayerImage->SetVisible( false );
			}
			if ( m_pCapNumPlayers )
			{
				m_pCapNumPlayers->SetVisible( false );
			}
		}
	}
}