Ejemplo n.º 1
0
	void CMap::createProjectile(const std::string entityName, const CLogicalPosition pos,const CEntity* father)
	{

		// [PT] Creamos un proyectil, flecha. Lo hago tal como crea los aliados Pablo

		std::ostringstream eName, eBase, eRing, eDegrees, eSense;
		eName << entityName; //bullet es un contador

		eBase << pos.getBase();
		eRing << (unsigned short) pos.getRing();
		eDegrees << (float)pos.getDegree();
		eSense << (unsigned short) pos.getSense();

		Map::CEntity bulletInfo(eName.str());

		bulletInfo.setType(entityName);


		//Atributos
		bulletInfo.setAttribute("base", eBase.str());
		bulletInfo.setAttribute("ring", eRing.str());
		bulletInfo.setAttribute("sense", eSense.str());
		bulletInfo.setAttribute("degrees", eDegrees.str());

		CEntity* newBullet = CEntityFactory::getSingletonPtr()->createMergedEntity(&bulletInfo, this, father);

		//activate the new entity
		//newBullet->getLogicalPosition()->setSense(eSense);
		newBullet->activate();

		bullet++;

		//newAlied->setPosition(newAlied->getPosition() + (rand()%50-25) * Vector3(1, 0, 1) );

	}
Ejemplo n.º 2
0
	//PT
	void CMap::createAlly(std::string entityName, const std::string& type, const unsigned short base, const unsigned short ring, const unsigned short degrees, const unsigned short sense)
	{

		// [PT] Creamos un nuevo aliado. Deberíamos tener la info del aliado
		// almacenada en aliedInfo así que solo habría que modificarle el
		// "name" (FRS a eso se le llama Archetype). Luego se crea la entidad del aliado con la factoría de 
		// entidades

		std::ostringstream eName, eBase, eRing, eDegrees, eSense;
		eName << entityName << _nAllies; //alied es un contador

		eBase << base;
		eRing << ring;
		eDegrees << degrees;
		eSense << sense;

		Map::CEntity aliedInfo(eName.str());

		aliedInfo.setType(type);


		//Atributos
		aliedInfo.setAttribute("base", eBase.str());
		aliedInfo.setAttribute("ring", eRing.str());
		aliedInfo.setAttribute("sense", eSense.str());
		aliedInfo.setAttribute("degrees", eDegrees.str());

		CEntity* newAlied = CEntityFactory::getSingletonPtr()->createEntity(aliedInfo, this);

		//activate the new entity
		newAlied->activate();

		++_nAllies;

		//newAlied->setPosition(newAlied->getPosition() + (rand()%50-25) * Vector3(1, 0, 1) );

	}
Ejemplo n.º 3
0
	void CScreamer::createExplotion() {
		Map::CEntity* screamerInfo = CEntityFactory::getSingletonPtr()->getInfo("Screamer");
		float height = screamerInfo->getFloatAttribute("heightShoot");
		
		// EntitiesHit sera el buffer que contendra la lista de entidades que ha colisionado
		// con el overlap
		vector<CEntity*> entitiesHit;

		// Hacemos una query de overlap con la geometria de una esfera en la posicion 
		// en la que se encuentra la granada con el radio que se indique de explosion
		Physics::SphereGeometry explotionGeom = Physics::CGeometryFactory::getSingletonPtr()->createSphere(_screamerExplotionRadius);
		Vector3 explotionPos = _entity->getPosition();
		explotionPos.y += height;
		Physics::CServer::getSingletonPtr()->overlapMultiple(explotionGeom, explotionPos, entitiesHit);

		int nbHits = entitiesHit.size();
		// Mandamos el mensaje de daño a cada una de las entidades que hayamos golpeado
		// Además aplicamos un desplazamiento al jugador 
		for(int i = 0; i < nbHits; ++i) {
			// Si la entidad golpeada es valida y es un player
			if( entitiesHit[i] != NULL && entitiesHit[i]->isPlayer() ) {
				// Emitimos el mensaje de instakill
				// @todo mandar un mensaje de instakill en vez de un mensaje de daño
				shared_ptr<CMessageDamaged> dmgMsg = make_shared<CMessageDamaged>();
				dmgMsg->setDamage(_screamerExplotionDamage);
				dmgMsg->setEnemy(_entity);
				entitiesHit[i]->emitMessage(dmgMsg);
			}
		}

		// Creamos las particulas de la explosion
		Map::CEntity* entityInfo = CEntityFactory::getSingletonPtr()->getInfo("ScreamerExplotion");
		CEntity* explotion = CEntityFactory::getSingletonPtr()->createEntity(entityInfo, _entity->getMap(), explotionPos, Quaternion::IDENTITY );
		explotion->activate();
		explotion->start();
	} // createExplotion