Esempio n. 1
0
void NinjaSpawner::SpawnNPC(const float posX,
							const float posY,
							bool playSoundEffect, 
							std::string animationFile, 
							Vector3 & dimensions, 
							Vector3 & collisionDimensions, 
							Vector2 & collisionBoxOffset)
{
	float randJumpSpeed = rand() % 4000;
	randJumpSpeed *= 0.001;
	randJumpSpeed += 20;
	float randMaxXVelocity = rand() % 3000;
	randMaxXVelocity *= 0.001;
	randMaxXVelocity += 10;

	int randZ = rand() % 20;

	NPC * npc = new NPC(posX, posY, 49 + (randZ * 0.1f));
	npc->m_animationFile = animationFile;
	npc->m_drawAtNativeDimensions = false;
	npc->m_dimensions = Vector3(dimensions.X, dimensions.Y, 0);
	npc->m_isAnimated = true;
	npc->SetMaxVelocityXYZ(randMaxXVelocity, 99999, 0);
	npc->SetCollisionDimensions(Vector3(collisionDimensions.X, collisionDimensions.Y, 0));
	npc->SetCollisionBoxOffset(Vector2(collisionBoxOffset.X, collisionBoxOffset.Y));   
	npc->SetPlayer(GameObjectManager::Instance()->GetPlayer());
	npc->SetResistanceXYZ(1.0, 1.4f, 0);
	npc->setAccelXRate(1.0);
	npc->SetMaterial(MaterialManager::Instance()->GetMaterial("demon1"));
	npc->SetMaxJumpSpeed(randJumpSpeed);
	npc->SetIsPlayerEnemy(true);

	GameObjectManager::Instance()->AddGameObject(npc);

	// show some effects when we spawn - smoke
	ParticleEmitterManager::Instance()->CreateRadialSpray(50,
														Vector3(npc->X(), npc->Bottom(), npc->Z() - 1.0f),
														Vector3(3200, 1200, 0),
														(rand() % 3) > 1 ? "Media\\smoke3.png" : "Media\\smoke4.png",
														4.5f,
														6.0f,
														0.5f,
														1.0f,
														100,
														200,
														0.5,
														false,
														0.5,
														1.0,
														800,
														true, 
														2.2,
														0.0f,
														0.5f,
														10,
														50);

	if (playSoundEffect)
	{
		AudioManager::Instance()->PlaySoundEffect("explosion\\explosion.wav");
	}
}