예제 #1
0
파일: Spell.cpp 프로젝트: franaisa/Gloom
	bool ISpell::spawn(CEntity *entity, CMap *map, const Map::CEntity *entityInfo) {
		if( !IComponent::spawn(entity,map,entityInfo) ) return false;

		Map::CEntity *tempEntity = CEntityFactory::getSingletonPtr()->getInfo(_spellName);
		// Comprobamos que los atributos obligatorios existen
		assert( tempEntity->hasAttribute("ID") && "Debe tener id, mirar archivo spellType");

		// Leemos los atributos obligatorios de arma
		_spellID = (SpellType::Enum)tempEntity->getIntAttribute("ID");
		
		_duration = tempEntity->getFloatAttribute("Duration")*1000;

		return true;
	} // spawn+
예제 #2
0
파일: Screamer.cpp 프로젝트: franaisa/Gloom
	void CScreamer::secondarySkill() {
		_secondarySkillIsActive = true;

		Map::CEntity* screamerShieldInfo = CEntityFactory::getSingletonPtr()->getInfo("ScreamerShield");
		float screamerShieldRadius = screamerShieldInfo->getFloatAttribute("physic_radius");

		// Creamos una entidad ScreamerShield
		// Obtenemos la informacion asociada al arquetipo del escudo del screamer
		Vector3 shootPosition = _entity->getPosition() + ( (_entity->getOrientation() * Vector3::NEGATIVE_UNIT_Z ) * (_capsuleRadius + screamerShieldRadius) );
		shootPosition.y += _heightShoot;

		// Creamos la entidad y la activamos
		_screamerShield = CEntityFactory::getSingletonPtr()->createEntity( 
			screamerShieldInfo,
			Logic::CServer::getSingletonPtr()->getMap(),
			shootPosition,
			_entity->getOrientation()
		);
		
		// Activamos la entidad creada
		_screamerShield->activate();
		_screamerShield->start();

		// Enviamos el mensaje SET_OWNER para que el escudo se mueva
		// acorde a los movimientos del player
		shared_ptr<CMessageSetOwner> setOwnerMsg = make_shared<CMessageSetOwner>();
		setOwnerMsg->setOwner(_entity);
		_screamerShield->emitMessage(setOwnerMsg);

		// Sonido del escudo
		std::shared_ptr<CMessageAudio> audioMsg = std::make_shared<CMessageAudio>();
		
		audioMsg->setAudioName("character/screamerShield.wav");
		audioMsg->isLoopable(true);
		audioMsg->is3dSound(true);
			
		_screamerShield->emitMessage(audioMsg);

		// Enviamos un mensaje para indicar que se bloquee el disparo
		shared_ptr<CMessageBlockShoot> canShootMsg = make_shared<CMessageBlockShoot>();
		canShootMsg->canShoot(false);
		_entity->emitMessage(canShootMsg);

		// Mandamos al jugador que tiene la habilidad disponible
		std::shared_ptr<CMessageHud> hudMsg = std::make_shared<CMessageHud>();
		hudMsg->setType(CMessageHud::HudType::SECONDARY_ACTIVE);
		_entity->emitMessage(hudMsg);
	} // secondarySkill
예제 #3
0
	bool CSoulReaperAmmo::spawn(CEntity* entity, CMap *map, const Map::CEntity *entityInfo) {
		Map::CEntity* weapon = CEntityFactory::getSingletonPtr()->getInfo(_weaponName);

		if( !IWeaponAmmo::spawn(entity, map, weapon) ) return false;

		// Nos aseguramos de tener todos los atributos que necesitamos
		assert( weapon->hasAttribute("PrimaryFireCooldown") );

		// Cooldown del disparo principal
		_defaultPrimaryFireCooldown = _primaryFireCooldown = weapon->getFloatAttribute("PrimaryFireCooldown") * 1000;

		_friend[_friends] = _entity->getComponent<Logic::CSoulReaper>("CSoulReaper");
		if(_friend[_friends])
			++_friends;
		_friend[_friends] = _entity->getComponent<Logic::CSoulReaperFeedback>("CSoulReaperFeedback");
		if(_friend[_friends])
			++_friends;
		if(_friends == 0)
			assert("\nTiene que tenes alguno de los dos componentes");

		return true;
	}
예제 #4
0
파일: Screamer.cpp 프로젝트: franaisa/Gloom
	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
예제 #5
0
	bool CCoolDownServer::spawn(CEntity* entity, CMap *map, const Map::CEntity *entityInfo) {
		if(!ISpell::spawn(entity,map,entityInfo)) return false;

		Map::CEntity *tempEntity = CEntityFactory::getSingletonPtr()->getInfo(_spellName);

		// Nos aseguramos de tener todos los atributos que necesitamos
		assert( tempEntity->hasAttribute("PercentageCooldown") );

		_percentage = tempEntity->getFloatAttribute("PercentageCooldown");


		_weaponryAmmo.resize(WeaponType::eSIZE);
		// Rellenamos el vector con los punteros a los componentes correspondientes
		_weaponryAmmo[WeaponType::eSOUL_REAPER] = _entity->getComponent<Logic::CSoulReaperAmmo>("CSoulReaperAmmo");
		_weaponryAmmo[WeaponType::eSNIPER]= _entity->getComponent<Logic::CSniperAmmo>("CSniperAmmo");
		_weaponryAmmo[WeaponType::eSHOTGUN]= _entity->getComponent<Logic::CShotGunAmmo>("CShotGunAmmo");
		_weaponryAmmo[WeaponType::eMINIGUN]= _entity->getComponent<Logic::CMiniGunAmmo>("CMiniGunAmmo");
		_weaponryAmmo[WeaponType::eIRON_HELL_GOAT]= _entity->getComponent<Logic::CIronHellGoatAmmo>("CIronHellGoatAmmo");

		_weaponryShoot.push_back( _entity->getComponent<Logic::CIronHellGoat>("CIronHellGoat"));
		_weaponryShoot.push_back( _entity->getComponent<Logic::CMiniGun>("CMiniGun"));

		return true;
	} // spawn
예제 #6
0
	bool CHudWeapons::spawn(CEntity *entity, CMap *map, const Map::CEntity *entityInfo) {
		if(!IComponent::spawn(entity,map,entityInfo))
			return false;
		
		_scene = _entity->getMap()->getScene();
			
		_graphicsEntities = new TGraphicsWeapon[WeaponType::eSIZE];
		
		// Por ahora leo a mano cada una de las armas que tiene el usuario
	
		for(int i = WeaponType::eSOUL_REAPER; i < WeaponType::eSIZE; ++i){
				
			WeaponType::Enum current = (WeaponType::Enum)i;
			std::string strWeapon = WeaponType::toString(current);

			Map::CEntity* weapon = CEntityFactory::getSingletonPtr()->getInfo(strWeapon);
				
			//_graphicsEntities[i]._graphicsEntity = createGraphicsEntity(weapon, entityInfo->getStringAttribute(weapon+"Model"));
			_graphicsEntities[current].defaultYaw = _graphicsEntities[current].defaultPitch = _graphicsEntities[current].defaultRoll = 0;
			if(weapon->hasAttribute("ModelYaw"))
				_graphicsEntities[current].defaultYaw = weapon->getFloatAttribute("ModelYaw");
			if(weapon->hasAttribute("ModelPitch"))
				_graphicsEntities[current].defaultPitch = weapon->getFloatAttribute("ModelPitch");
			if(weapon->hasAttribute("ModelRoll"))
				_graphicsEntities[current].defaultRoll = weapon->getFloatAttribute("ModelRoll");
				
			//Esto puede petar si no esta, pero creo q es obligatorio
			if(!weapon->hasAttribute("Offset"))
				assert("seguro que no tiene offset?");

			_graphicsEntities[current].offset = weapon->getVector3Attribute("Offset");
				
			/*
			// Ahora voy a crear los overlays por cada arma en 3D

			Graphics::CServer *server = Graphics::CServer::getSingletonPtr();

			_overlayWeapon3D[current] = server->createOverlay( "_overlay3D"+strWeapon, _scene );
			std::string modelWeapon = weapon->getStringAttribute("Model");	
			
			_graphicsEntities[current].graphicsEntity = _overlayWeapon3D[current]->add3D(strWeapon, modelWeapon,_graphicsEntities[current].offset);
			assert(_graphicsEntities[current].graphicsEntity != 0 && "error al cargar la entidad grafica");
			//_weaponsEntities[current] = _overlayWeapon3D[current]->add3D(currentOnText, modelWeapon, &offsetPositionWeapon);

			_graphicsEntities[current].graphicsEntity->setOrientation(Math::setQuaternion(_graphicsEntities[current].defaultYaw, _graphicsEntities[current].defaultPitch, _graphicsEntities[current].defaultRoll));
	

			_overlayWeapon3D[current]->setVisible(false);
			_overlayWeapon3D[current]->setZBuffer(15);
			/*/

			std::string modelWeapon = weapon->getStringAttribute("Model");	
			_graphicsEntities[current].graphicsEntity = _scene->getCamera()->addEntityChild(strWeapon, modelWeapon, _graphicsEntities[current].offset);
			// Este render queue se usa para simular los overlays. Poner en esta cola solo lo que queramos
			// que se renderice como un overlay!!
			_graphicsEntities[current].graphicsEntity->setRenderQueue(95);
			// Esta mascara se utiliza para excluir el elemento del efecto de motion blur
			_graphicsEntities[current].graphicsEntity->setVisibilityMask(1 << 0);

			_graphicsEntities[current].graphicsEntity->setOrientation(Math::setQuaternion(_graphicsEntities[current].defaultYaw, _graphicsEntities[current].defaultPitch, _graphicsEntities[current].defaultRoll));
			_graphicsEntities[current].graphicsEntity->setVisible(false);
			/* */
			
		}

		//_overlayWeapon3D[WeaponType::eSOUL_REAPER]->setVisible(true);
		_graphicsEntities[WeaponType::eSOUL_REAPER].graphicsEntity->setVisible(true);

		if(!_graphicsEntities)
			return false;
		
		// Usamos un pequeño truco para calcular a la velocidad a la que tiene que incrementar
		// el ruido de carga
		// Primero obtenemos el tiempo máximo de carga del Iron Hell Goat
		Map::CEntity* info = CEntityFactory::getSingletonPtr()->getInfo("ironHellGoat");
		assert( info->hasAttribute("PrimaryFireLoadTime") );

		// Una vez conocido el tiempo de carga, como sabemos que vamos a utilizar fixed ticks
		// de 16 msecs, calculamos cuantos ticks van a pasar (aproximadamente) hasta que se
		// tiene el arma cargada.
		unsigned int nbTicks = (info->getIntAttribute("PrimaryFireLoadTime") * 1000) / 16;

		// Calculamos el incremento de la velocidad distribuyendola uniformemente entre los
		// ticks de carga
		_unstableLoadAnim.speedInc = (_unstableLoadAnim.maxVerticalSpeed - _unstableLoadAnim.initVerticalSpeed) /  (float)nbTicks;
		_unstableLoadAnim.noiseInc = (_unstableLoadAnim.maxNoiseSpeed - _unstableLoadAnim.initNoiseSpeed) / (float)nbTicks;

		return true;

	} // spawn