void EnemyController::CheckPlayerHit(void)
{
	for (int ship = 0; ship < 6; ship++)
	{
		if (p_Ship[ship]->m_Active)
		{
			if (p_Ship[ship]->CheckPlayerHit() || p_Ship[ship]->CheckUFOHit())
			{
				SpawnExplosion(p_Ship[ship]->m_Position, 1);
				p_Ship[ship]->Deactivate();
			}

			if (p_Ship[ship]->CheckPlayerHit())
				p_Player->GotPoints(200);
		}

	}


	for (int pair = 0; pair < 3; pair++)
	{
		if (p_Pair[pair]->m_Active)
		{
			if (p_Pair[pair]->CheckPlayerHit() || p_Pair[pair]->CheckUFOHit())
			{
				SpawnExplosion(p_Pair[pair]->m_Position, 2);
				SpawnShips(pair);
				p_Pair[pair]->Deactivate();
			}

			if (p_Pair[pair]->CheckPlayerHit())
				p_Player->GotPoints(100);
		}
	}

	if (p_Pod->m_Active)
	{
		if (p_Pod->CheckPlayerHit() || p_Pod->CheckUFOHit())
		{
			SpawnExplosion(p_Pod->m_Position, 3);
			SpawnPairs();
			p_Pod->Deactivate();
		}

		if (p_Pod->CheckPlayerHit())
			p_Player->GotPoints(50);
	}
}
Esempio n. 2
0
//destroys the asteroid, spawning new ones if necessary
void AsteroidHit(LIST * a, int fromplayershot)
{
   if(a)
   {
      PlaySoundIndex(SND_EXP_ASTEROID);

      SpawnExplosion(NewListNode(&g_explosion_list, sizeof(EXPLOSION)), &(((ASTEROID *)a->d)->pos), (int)(((ASTEROID *)a->d)->scale) * 8);

      if(((ASTEROID *)a->d)->scale > 1.0f)
      {
         if(fromplayershot)
            Score(((ASTEROID *)a->d)->scale > 2.0f ? 20 : 50, &(((ASTEROID *)a->d)->pos));

         SpawnAsteroid(NewListNode(&g_asteroid_list, sizeof(ASTEROID)), &(((ASTEROID *)a->d)->pos), ((ASTEROID *)a->d)->scale * 0.5f);
         SpawnAsteroid(NewListNode(&g_asteroid_list, sizeof(ASTEROID)), &(((ASTEROID *)a->d)->pos), ((ASTEROID *)a->d)->scale * 0.5f);
      }
      else if(fromplayershot)
         Score(100, &(((ASTEROID *)a->d)->pos));

      RemoveNode(a, &g_asteroid_list);

      if(!g_asteroid_list && g_ships)
         g_time_to_reset = RESET_TIME;
   }
}
Esempio n. 3
0
//destroys the powerup without getting it
void PowerupHit(LIST * p, int fromplayershot)
{
   if(p)
   {
      PlaySoundIndex(SND_EXP_OTHER);

      SpawnExplosion(NewListNode(&g_explosion_list, sizeof(EXPLOSION)), &(((POWERUP *)p->d)->pos), NUM_EXPLOSION_PARTICLES / 2);

      if(fromplayershot)
         Score(666, &(((POWERUP *)p->d)->pos));

      RemoveNode(p, &g_powerup_list);
   }
}
Esempio n. 4
0
//destroys the alien ship
void AlienHit(LIST * a, int fromplayershot)
{
   if(a)
   {
      PlaySoundIndex(SND_EXP_OTHER);

      SpawnExplosion(NewListNode(&g_explosion_list, sizeof(EXPLOSION)), &(((ALIEN *)a->d)->pos), (((ALIEN *)a->d)->scale == 2.0f ? NUM_EXPLOSION_PARTICLES / 2 : NUM_EXPLOSION_PARTICLES));

      if(fromplayershot)
         Score((((ALIEN *)a->d)->scale == 2.0f ? 500 : 200), &(((ALIEN *)a->d)->pos));

      RemoveNode(a, &g_alien_list);
   }
}
Esempio n. 5
0
//destroys the player, respawns it
void PlayerHit(void)
{
   if(g_player.powerups & PL_POW_SHIELD)
   {
      g_player.powerups &= (~PL_POW_SHIELD);
      g_player.wait_time = PLAYER_SPAWN_WAIT;
   }
   else
   {
      PlaySoundIndex(SND_EXP_SHIP);

      SpawnExplosion(NewListNode(&g_explosion_list, sizeof(EXPLOSION)), &g_player.pos, NUM_EXPLOSION_PARTICLES);

      ResetPlayer(&g_player);
      if(g_ships && !(--g_ships))
         g_hisct_delay = HISCT_DELAY;
   }
}
Esempio n. 6
0
void CGargantua::DeathEffect( void )
{
	int i;
	UTIL_MakeVectors(GetAbsAngles());
	Vector deathPos = GetAbsOrigin() + gpGlobals->v_forward * 100;

	// Create a spiral of streaks
	CSpiral::Create( deathPos, (pev->absmax.z - pev->absmin.z) * 0.6, 125, 1.5 );

	Vector position = GetAbsOrigin();
	position.z += 32;
	for ( i = 0; i < 7; i+=2 )
	{
		SpawnExplosion( position, 70, (i * 0.3), 60 + (i*20) );
		position.z += 15;
	}

	CBaseEntity *pSmoker = CBaseEntity::Create( "env_smoker", GetAbsOrigin(), g_vecZero, NULL );
	pSmoker->pev->health = 1;	// 1 smoke balls
	pSmoker->pev->scale = 46;	// 4.6X normal size
	pSmoker->pev->dmg = 0;		// 0 radial distribution
	pSmoker->pev->nextthink = gpGlobals->time + 2.5;	// Start in 2.5 seconds
}
Esempio n. 7
0
void 
Game::Process(float deltaTime)
{
	// Count total simulation time elapsed:
	m_elapsedSeconds += deltaTime;

	// Frame Counter:
	if (m_elapsedSeconds > 1)
	{
		m_elapsedSeconds -= 1;
		m_FPS = m_frameCount;
		m_frameCount = 0;
	}

	// Update the game world simulation:

	// Process each enemy in the container.
	std::vector<Enemy*>::iterator enemyIterator;
	for (enemyIterator = m_EnemyVector.begin();
	enemyIterator != m_EnemyVector.end();
		++enemyIterator)
	{
		
		(*enemyIterator)->Process(deltaTime);
	}

	// Process each bullet in the container.
	std::vector<Bullet*>::iterator bulletIterator;
	for (bulletIterator = m_BulletVector.begin();
	bulletIterator != m_BulletVector.end();
		++bulletIterator)
	{
		(*bulletIterator)->Process(deltaTime);
	}
	//process all platforms
	std::vector<Platform*>::iterator platIterator;
	for (platIterator = m_PlatVector.begin();
	platIterator != m_PlatVector.end();
		++platIterator)
	{
		(*platIterator)->Process(deltaTime);
	}
	//process explosions
	std::vector<Explosion*>::iterator ExplosionIterator;
	for (ExplosionIterator = Explosions.begin();
	ExplosionIterator != Explosions.end();
		++ExplosionIterator)
	{
		(*ExplosionIterator)->Process(deltaTime);
		(*ExplosionIterator)->GetSprite()->Process(deltaTime);
	}

	// Update the player object
	m_pPlayer->Process(deltaTime);



	// Check for bullet vs alien enemy collisions...
	// For each bullet
	for (bulletIterator = m_BulletVector.begin();
	bulletIterator != m_BulletVector.end();
		++bulletIterator)
	{
		// For each alien enemy
		for (enemyIterator = m_EnemyVector.begin();
		enemyIterator != m_EnemyVector.end();
			++enemyIterator)
		{
			// Check collision between two entities.	
			if ((*bulletIterator)->IsCollidingWith(*(*enemyIterator)) == true)
			{
				// If collided, destory both and spawn explosion.
				SpawnExplosion((*enemyIterator)->GetPositionX(), (*enemyIterator)->GetPositionY());
				(*bulletIterator)->SetDead(true);
				(*enemyIterator)->SetDead(true);

			}
		}
	}


	//check for bullet vs platform
	for (bulletIterator = m_BulletVector.begin();
	bulletIterator != m_BulletVector.end();
		++bulletIterator)
	{
		// For each alien enemy
		for (platIterator = m_PlatVector.begin();
		platIterator != m_PlatVector.end();
			++platIterator)
		{
			// Check collision between two entities.	
			if ((*bulletIterator)->IsCollidingWith(*(*platIterator)) == true)
			{
				// If collided, destory both and spawn explosion.
				(*bulletIterator)->SetDead(true);

			}
		}
	}
	//enemy vs plat
	for (platIterator = m_PlatVector.begin(); platIterator != m_PlatVector.end(); ++platIterator)
	{
		// For each plat
		for (enemyIterator = m_EnemyVector.begin(); enemyIterator != m_EnemyVector.end(); ++enemyIterator)
		{
			// Check collision between two entities.	
			if ((*platIterator)->IsCollidingWith(*(*enemyIterator)) == true)
			{
				// If collided, set on top
				(*enemyIterator)->SetPositionY((*platIterator)->GetPositionY() - tileSize);
				if ((*platIterator)->GetPositionX() < 200)
				{
					(*enemyIterator)->SetHorizontalVelocity(3.0f);
				}

			}
		}
	}




	//player vs enemy
	for (enemyIterator = m_EnemyVector.begin(); enemyIterator != m_EnemyVector.end(); ++enemyIterator)
	{
		if ((*enemyIterator)->IsCollidingWith(*m_pPlayer))
		{
			SpawnExplosion(m_pPlayer->GetPositionX(), m_pPlayer->GetPositionY());
			m_pPlayer->SetPositionX(tileSize);
			m_pPlayer->SetPositionY(tileSize);
		}
	}

	//player vs plat
	for (platIterator = m_PlatVector.begin(); platIterator != m_PlatVector.end(); ++platIterator)
	{
		if ((*platIterator)->IsCollidingWith(*m_pPlayer))
		{
			float platPos = (*platIterator)->GetPositionY();
			float platxPos = (*platIterator)->GetPositionX();
			//right collision
			if (m_pPlayer->GetPositionY() > (*platIterator)->GetPositionY())
			{
				m_pPlayer->SetPositionY(platPos + tileSize);
				if (m_pPlayer->GetPositionX() < (*platIterator)->GetPositionX())
				{
					//m_pPlayer->SetPositionX(platxPos + tileSize);

					m_pPlayer->SetVerticalVelocity(2.0f);
				}
				else if (m_pPlayer->GetPositionX() > (*platIterator)->GetPositionX())
				{
					m_pPlayer->SetVerticalVelocity(2.0f);
				}
			}
			else
			{
				m_pPlayer->SetPositionY(platPos - tileSize);
				if (m_pPlayer->GetPositionX() < (*platIterator)->GetPositionX())
				{

					m_pPlayer->SetVerticalVelocity(2.0f);
				}
				else if (m_pPlayer->GetPositionX() > (*platIterator)->GetPositionX())
				{
					m_pPlayer->SetVerticalVelocity(2.0f);
				}
			}
		}
	}






	// Remove any dead bullets from the container...
	bulletIterator = m_BulletVector.begin();
	while(bulletIterator != m_BulletVector.end())
	{
		if((*bulletIterator)->IsDead() == true)
		{

			bulletIterator = m_BulletVector.erase(bulletIterator);

		}
		else
		{
			++bulletIterator;
		}
	}

	// Remove any dead enemy aliens from the container...
	enemyIterator = m_EnemyVector.begin();
	while(enemyIterator != m_EnemyVector.end())
	{
		if((*enemyIterator)->IsDead() == true)
		{

			enemyIterator = m_EnemyVector.erase(enemyIterator);

		}
		else
		{
			++enemyIterator;
		}
	}
	//remove explosions
	std::vector<Explosion*>::iterator explosionIterator;
	for (explosionIterator = Explosions.begin(); explosionIterator != Explosions.end();) 
	{
		Explosion* explode = *explosionIterator;

		if (explode->IsDead()) 
		{
			delete explode;
			explosionIterator = Explosions.erase(explosionIterator);
		}
		else 
		{
			explosionIterator++;
		}

	}
	
}