示例#1
0
	void Game::CheckCollision()
	{
		for (std::list< Asteroids::Asteroid* >::iterator asteroid = m_asteroids.begin(); asteroid != m_asteroids.end(); ++asteroid)
		{
			if ((*asteroid)->CouldCollide() && m_player->CouldCollide())
			{
				if (m_player->DetectCollision((*asteroid)))
				{
					CreateDebris((*asteroid));
				}

				for (std::list< Asteroids::Bullet* >::iterator bullet = m_bullets.begin(); bullet != m_bullets.end(); ++bullet)
				{
					if ((*bullet)->CouldCollide() && (*asteroid)->CouldCollide())
					{
						if ((*asteroid)->DetectCollision((*bullet)))
						{
							UpdateScore(10);
							CreateDebris((*asteroid));
						}
					}
				}
			}
		}
	}
示例#2
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : position - 
//			force - 
// Output : virtual void
//-----------------------------------------------------------------------------
void C_BaseExplosionEffect::Create( const Vector &position, float force, float scale, int flags )
{
	m_vecOrigin = position;
	m_fFlags	= flags;

	//Find the force of the explosion
	GetForceDirection( m_vecOrigin, force, &m_vecDirection, &m_flForce );

#if __EXPLOSION_DEBUG
	debugoverlay->AddBoxOverlay( m_vecOrigin, -Vector(32,32,32), Vector(32,32,32), vec3_angle, 255, 0, 0, 64, 5.0f );
	debugoverlay->AddLineOverlay( m_vecOrigin, m_vecOrigin+(m_vecDirection*force*m_flForce), 0, 0, 255, false, 3 );
#endif

	PlaySound();

	if ( scale != 0 )
	{
		// UNDONE: Make core size parametric to scale or remove scale?
		CreateCore();
	}

	CreateDebris();
	//FIXME: CreateDynamicLight();
	CreateMisc();
}
示例#3
0
void SpaceSim::CreateWorld()
{
	////CreatePlayer();
	for(int p = 0 ; p <15; p++)
	{
		//CreateAsteroid();

	}
	for(int p = 0 ; p < 10; p++)
	{
		CreateDebris();
	}

	spaceship = CreateSpaceship(300,-450);
};
示例#4
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : position - 
//			force - 
// Output : virtual void
//-----------------------------------------------------------------------------
void C_BaseExplosionEffect::Create( const Vector &position, float force, float scale, int flags )
{
	m_vecOrigin = position;
	m_fFlags	= flags;

	//if explosion is an ice explosion skip all the other stuff and draw a particle system
	if ( m_fFlags & TE_EXPLFLAG_ICE )
	{
		QAngle	vecAngles;
		//DispatchParticleEffect( "freeze_explosion", m_vecOrigin , vecAngles );
		PlaySound();
		return;
	}

	if ( m_fFlags & TE_EXPLFLAG_SCALEPARTICLES )
	{
		m_flScale = scale;
	}
	else
	{
		m_flScale = 1.0f;
	}

	//Find the force of the explosion
	GetForceDirection( m_vecOrigin, force, &m_vecDirection, &m_flForce );

#if __EXPLOSION_DEBUG
	debugoverlay->AddBoxOverlay( m_vecOrigin, -Vector(32,32,32), Vector(32,32,32), vec3_angle, 255, 0, 0, 64, 5.0f );
	debugoverlay->AddLineOverlay( m_vecOrigin, m_vecOrigin+(m_vecDirection*force*m_flForce), 0, 0, 255, false, 3 );
#endif

	PlaySound();

	if ( scale != 0 )
	{
		// UNDONE: Make core size parametric to scale or remove scale?
		CreateCore();
	}

	CreateDebris();
	CreateDynamicLight();
	CreateMisc();
}
示例#5
0
uint32 CDestructibleModel::ObjectMessageFn(LPBASECLASS pObject, HOBJECT hSender, ILTMessage_Read *pMsg)
{
	uint32 dwRet = CDestructible::ObjectMessageFn(pObject, hSender, pMsg);

	pMsg->SeekTo(0);
	uint32 messageID = pMsg->Readuint32();
	switch(messageID)
	{
		case MID_DAMAGE:
		{
			if (IsDead() && !m_bCreatedDebris)
			{
                ILTServer* pServerDE = BaseClass::GetServerDE();
				if (!pServerDE) break;

				SpawnItem();
				CreateDebris();
				CreateWorldModelDebris();

				if (m_bCreateExplosion)
				{
					DoExplosion();
				}

				RegisterDestroyedStimulus();

				m_bCreatedDebris = LTTRUE;

				if (m_bRemoveOnDeath)
				{
					pServerDE->RemoveObject(m_hObject);
				}
			}
		}
		break;

		case MID_TRIGGER:
		{
			const char* szMsg = (const char*)pMsg->Readuint32();

			// ConParse does not destroy szMsg, so this is safe
			ConParse parse;
			parse.Init((char*)szMsg);

			while (g_pCommonLT->Parse(&parse) == LT_OK)
			{
				if (parse.m_nArgs > 0 && parse.m_Args[0])
				{
					if (!IsDead())
					{
						if (_stricmp(parse.m_Args[0], "FIRE") == 0)
						{
							char* pTargetName = parse.m_nArgs > 1 ? parse.m_Args[1] : LTNULL;
							DoExplosion(pTargetName);
						}
						else if (_stricmp(parse.m_Args[0], "HIDDEN") == 0)
						{
							// Game Base will take care of the solid and visible flags for us...

							if (parse.m_nArgs > 1 && parse.m_Args[1])
							{
								if ((_stricmp(parse.m_Args[1], "1") == 0) ||
									(_stricmp(parse.m_Args[1], "TRUE") == 0))
								{
									m_bSaveCanDamage = GetCanDamage();
									m_bSaveNeverDestroy = GetNeverDestroy();

									SetCanDamage(LTFALSE);
									SetNeverDestroy(LTTRUE);
								}
								else
								{
									if ((_stricmp(parse.m_Args[1], "0") == 0) ||
										(_stricmp(parse.m_Args[1], "FALSE") == 0))
									{
										SetCanDamage(m_bSaveCanDamage);
										SetNeverDestroy(m_bSaveNeverDestroy);
									}
								}
							}
						}

					}
				}
			}
		}
		break;

		default : break;
	}

	return dwRet;
}
示例#6
0
uint32 CDestructibleModel::ObjectMessageFn(LPBASECLASS pObject, HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead)
{
	uint32 dwRet = CDestructible::ObjectMessageFn(pObject, hSender, messageID, hRead);

	switch(messageID)
	{
		case MID_DAMAGE:
		{
			if (IsDead() && !m_bCreatedDebris)
			{
                ILTServer* pServerDE = BaseClass::GetServerDE();
				if (!pServerDE) break;

				SpawnItem();
				CreateDebris();
				CreateWorldModelDebris();

				if (m_bCreateExplosion)
				{
					DoExplosion();
				}

				m_bCreatedDebris = LTTRUE;

				if (m_bRemoveOnDeath)
				{
					pServerDE->RemoveObject(m_hObject);
				}
			}
		}
		break;

		case MID_TRIGGER:
		{
			const char* szMsg = (const char*)g_pLTServer->ReadFromMessageDWord(hRead);

			// ConParse does not destroy szMsg, so this is safe
			ConParse parse;
			parse.Init((char*)szMsg);

			while (g_pLTServer->Common()->Parse(&parse) == LT_OK)
			{
				if (parse.m_nArgs > 0 && parse.m_Args[0])
				{
					if (!IsDead())
					{
						if (_stricmp(parse.m_Args[0], "FIRE") == 0)
						{
							char* pTargetName = parse.m_nArgs > 1 ? parse.m_Args[1] : LTNULL;
							DoExplosion(pTargetName);
						}
						else if (_stricmp(parse.m_Args[0], "HIDDEN") == 0)
						{
							uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);

							if (parse.m_nArgs > 1 && parse.m_Args[1])
							{
								if ((_stricmp(parse.m_Args[1], "1") == 0) ||
									(_stricmp(parse.m_Args[1], "TRUE") == 0))
								{
									dwFlags = 0;

									m_bSaveCanDamage = GetCanDamage();
									m_bSaveNeverDestroy = GetNeverDestroy();

									SetCanDamage(LTFALSE);
									SetNeverDestroy(LTTRUE);
								}
								else
								{
									if ((_stricmp(parse.m_Args[1], "0") == 0) ||
										(_stricmp(parse.m_Args[1], "FALSE") == 0))
									{
										dwFlags = m_dwOriginalFlags;
										dwFlags |= FLAG_VISIBLE;

										SetCanDamage(m_bSaveCanDamage);
										SetNeverDestroy(m_bSaveNeverDestroy);
									}
								}

								g_pLTServer->SetObjectFlags(m_hObject, dwFlags);
							}
						}
					}
				}
			}
		}
		break;

		default : break;
	}

	return dwRet;
}
示例#7
0
LTBOOL CParticleExplosionFX::CreateObject(ILTClient *pClientDE)
{
    LTBOOL bRet = CBaseParticleSystemFX::CreateObject(pClientDE);
    if (!bRet) return bRet;

    // Initialize the emmitters velocity ranges based on our rotation...

    LTVector vVelMin, vVelMax, vTemp, vU, vR, vF;
    VEC_SET(vVelMin, 1.0f, 1.0f, 1.0f);
    VEC_SET(vVelMax, 1.0f, 1.0f, 1.0f);

    m_pClientDE->Common()->GetRotationVectors(m_rSurfaceRot, vU, vR, vF);

    if (vF.y <= -0.95f || vF.y >= 0.95f)
    {
        vF.y = vF.y > 0.0f ? 1.0f : -1.0f;
        VEC_SET(vR, 1.0f, 0.0f, 0.0f);
        VEC_SET(vU, 0.0f, 0.0f, 1.0f);
    }
    else if (vF.x <= -0.95f || vF.x >= 0.95f)
    {
        vF.x = vF.x > 0.0f ? 1.0f : -1.0f;
        VEC_SET(vR, 0.0f, 1.0f, 0.0f);
        VEC_SET(vU, 0.0f, 0.0f, 1.0f);
    }
    else if (vF.z <= -0.95f || vF.z >= 0.95f)
    {
        vF.z = vF.z > 0.0f ? 1.0f : -1.0f;
        VEC_SET(vR, 1.0f, 0.0f, 0.0f);
        VEC_SET(vU, 0.0f, 1.0f, 0.0f);
    }

    VEC_MULSCALAR(vVelMin, vF, m_vMinVel.y);
    VEC_MULSCALAR(vVelMax, vF, m_vMaxVel.y);

    VEC_MULSCALAR(vTemp, vR, m_vMinVel.x);
    VEC_ADD(vVelMin, vVelMin, vTemp);

    VEC_MULSCALAR(vTemp, vR, m_vMaxVel.x);
    VEC_ADD(vVelMax, vVelMax, vTemp);

    VEC_MULSCALAR(vTemp, vU, m_vMinVel.z);
    VEC_ADD(vVelMin, vVelMin, vTemp);

    VEC_MULSCALAR(vTemp, vU, m_vMaxVel.z);
    VEC_ADD(vVelMax, vVelMax, vTemp);


    // Initialize our emmitters...

    LTVector vStartVel;
    for (int i=0; i < m_nNumEmmitters; i++)
    {
        if (m_bCreateDebris)
        {
            m_hDebris[i] = CreateDebris();
        }

        m_ActiveEmmitters[i] = LTTRUE;
        m_BounceCount[i] = 2;

        VEC_SET(vStartVel, GetRandom(vVelMin.x, vVelMax.x),
                GetRandom(vVelMin.y, vVelMax.y),
                GetRandom(vVelMin.z, vVelMax.z));

        InitMovingObject(&(m_Emmitters[i]), &m_vPos, &vStartVel);
        m_Emmitters[i].m_PhysicsFlags |= m_nEmmitterFlags;
    }

    return bRet;
}