void HealSkillComponent::fireSkill(void)
{
	if(this->_target != nullptr)
	{
		GameEntity* healingbolt = new GameEntity(this->_game, D3DXVECTOR3(5, 5, 5));
		healingbolt->SetType(Projectile);
		healingbolt->setPosition(this->_entity->getPosition());
		healingbolt->setDirection(D3DXVECTOR3(this->_entity->getDirection().x, 0, this->_entity->getDirection().z));
		healingbolt->setVelocity(5);
		ScaledBoxGraphicsComponent* graphics = new ScaledBoxGraphicsComponent(this->_game, healingbolt, D3DCOLOR_RGBA(0,255,0,150));
		RadiusBasedCollisionComponent* collision = new RadiusBasedCollisionComponent(this->_game, healingbolt, 10, this->_group, Heal);
		AIControllerComponent* aiController = new AIControllerComponent(this->_game, healingbolt);
		LinearPathfindingComponent* pathfinding = new LinearPathfindingComponent(this->_game, healingbolt, aiController);

		pathfinding->FollowEntity(this->_target);
		collision->SetTarget(this->_target);

		healingbolt->AddComponent(aiController);
		healingbolt->AddComponent(pathfinding);
		healingbolt->AddComponent(collision);
		healingbolt->AddGraphicsComponent(graphics);

		healingbolt->Initialize();
		this->_children.push_back(healingbolt);
	}
}
void FireboltSkillComponent::fireSkill(void)
{
	if(this->_children.size() < 4)
	{
		GameEntity* firebolt = new GameEntity(this->_game, D3DXVECTOR3(5, 5, 5));
		firebolt->SetType(Projectile);
		firebolt->setPosition(this->_entity->getPosition());
		firebolt->setDirection(D3DXVECTOR3(this->_entity->getDirection().x, 0, this->_entity->getDirection().z));
		firebolt->setVelocity(5);
		ScaledBoxGraphicsComponent* graphics = new ScaledBoxGraphicsComponent(this->_game, firebolt, D3DCOLOR_RGBA(255,100,0,150));
		RadiusBasedCollisionComponent* collision = new RadiusBasedCollisionComponent(this->_game, firebolt, 10, this->_group, MinusLife);
		PointLightComponent* light = new PointLightComponent(this->_game, firebolt, D3DXCOLOR(1.0f, 0.1f, 0.0f, 1.0f), 50);

		firebolt->AddComponent(collision);
		firebolt->AddComponent(light);
		firebolt->AddGraphicsComponent(graphics);
		firebolt->Initialize();
		this->_children.push_back(firebolt);
	}
	else
	{
		this->_children[this->_indexBuffer%this->_children.size()]->setPosition(this->_entity->getPosition());
		this->_children[this->_indexBuffer%this->_children.size()]->setDirection(D3DXVECTOR3(this->_entity->getDirection().x, 0, this->_entity->getDirection().z));
		this->_children[this->_indexBuffer%this->_children.size()]->Enable();
		this->_indexBuffer++;
	}
	
}
Example #3
0
GameEntitiesContainer EntityFactory::AddKey(D3DXVECTOR3 position, int keyNumber, GameEntitiesContainer gc, PlayerComponent *player)
{
	D3DXVECTOR3 newPos = D3DXVECTOR3(position.x * 20, position.y * 20, position.z * 20);
	GameEntity *keyEntity = new GameEntity(this->_game);
	KeyPartComponent *keyPartComponent = new KeyPartComponent(this->_game, keyEntity, player, keyNumber, newPos);
	KeyGraphicsComponent *kg = new KeyGraphicsComponent(20,20,player, keyPartComponent, this->_game , keyEntity);
	
	keyEntity->setPosition(newPos);	
	keyEntity->AddComponent(keyPartComponent);
	keyEntity->AddGraphicsComponent(kg);

	gc.Entities.push_back(keyEntity);
	return gc;
}
Example #4
0
GameEntity* EntityFactory::CreateAIEntity(
	GameEntitiesContainer* container, 
	D3DXVECTOR3 position, 
	D3DXVECTOR3 size,
	float speed,
	D3DCOLOR color, 
	long framesToWait, 
	Behaviour behaviour,
	AIEntitiesInteractionContainer entitiesContainer,
	AStarPathfindingGraph* graph,
	GameEntity* entityToFollow, 
	PlayerComponent *player)
{
	GameEntity* entity = new GameEntity(this->_game);
	entity->setPosition(position);
	entity->setSize(size);
	entity->setSpeed(speed);
	PhysicsComponent* physics = new PhysicsComponent(this->_game, entity);
	AIControllerComponent* aiController = new AIControllerComponent(this->_game, entity);
	AStarPathfindingComponent* pathfinding = new AStarPathfindingComponent(this->_game, entity, aiController, framesToWait, graph);
	ScaledBoxGraphicsComponent* graphics = new ScaledBoxGraphicsComponent(this->_game, entity, color);
	RadiusBasedCollisionComponent* collision = new RadiusBasedCollisionComponent(this->_game, entity, 20, Enemies, MinusLife);
	EntityHealthDisplayComponent* healthDisplay = new EntityHealthDisplayComponent(this->_game, entity, player->getEntity());

	BehaviourComponent* behaviourComponent = new BehaviourComponent(this->_game, entity, behaviour, entitiesContainer, pathfinding, player);


	entity->AddComponent(physics);
	entity->AddComponent(aiController);
	entity->AddComponent(physics);
	entity->AddComponent(aiController);
	entity->AddComponent(collision);
	entity->AddDrawableComponent(pathfinding);
	entity->AddComponent(behaviourComponent);
	entity->AddGraphicsComponent(graphics);
	entity->AddGraphicsComponent(healthDisplay);

	if(entityToFollow != nullptr)
	{
		pathfinding->FollowEntity(entityToFollow);
	}
	
	container->Entities.push_back(entity);

	return entity;
}
Example #5
0
GameEntitiesContainer EntityFactory::AddTrapDoor( int numRows, int numCols,GameEntitiesContainer container, D3DXVECTOR3 position, PlayerComponent* player)
{
	D3DXVECTOR3 newPos = D3DXVECTOR3(position.x * 20, position.y * 20, position.z * 20);
	GameEntity *trapEntity = new GameEntity(this->_game);
	trapEntity->setPosition(newPos);
	TrapDoorComponent* trapDoor = new TrapDoorComponent(this->_game, trapEntity);
	GameMap1GraphicsComponent* graphics6 = new GameMap1GraphicsComponent(numRows, numCols, this->_game, trapEntity);

	trapEntity->AddGraphicsComponent(graphics6);

	TrapDoorGraphicsComponent *trapDoorGraphics = new TrapDoorGraphicsComponent(numRows, numCols, trapDoor, this->_game, trapEntity);

	TrapDoorCollisionComponent *trapDoorCollisions = new TrapDoorCollisionComponent(this->_game, trapEntity, player, trapDoor);

	trapEntity->AddComponent(trapDoor);
	trapEntity->AddGraphicsComponent(trapDoorGraphics);
	trapEntity->AddCollisionComponent(trapDoorCollisions);

	container.Floors.push_back(trapEntity);
	container.Entities.push_back(trapEntity);
	
	return container;
}