Exemplo n.º 1
0
	bool IWeaponFeedback::spawn(CEntity *entity, CMap *map, const Map::CEntity *entityInfo) {
		if( !IComponent::spawn(entity,map,entityInfo) ) return false;

		
		
		Map::CEntity *tempEntity = CEntityFactory::getSingletonPtr()->getInfo(_weaponName);
		_weaponSound = tempEntity->getStringAttribute("Audio");

		/*
		if(tempEntity->hasAttribute("PrimaryFireParticle"))
			_primaryFireParticle = tempEntity->getStringAttribute("PrimaryFireParticle");
		else
			_primaryFireParticle = "fogonazo";

		if(tempEntity->hasAttribute("SecondaryFireParticle"))
			_secondaryFireParticle = tempEntity->getStringAttribute("SecondaryFireParticle");
		else
			_secondaryFireParticle = "fogonazo";
		*/
		if(tempEntity->hasAttribute("ParticlePosition"))
			_particlePosition = tempEntity->getVector3Attribute("ParticlePosition");
		else
			_particlePosition = Vector3(0, 0, 0);


		_hudWeapon = _entity->getComponent<CHudWeapons>("CHudWeapons");
		assert(_hudWeapon != NULL && "Error: El cliente necesita tener un componente de grafico del arma");

		assert( entityInfo->hasAttribute("heightShoot") );
		_heightShoot = entityInfo->getFloatAttribute("heightShoot");

		return true;
	}
Exemplo n.º 2
0
	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+
Exemplo n.º 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;
	}
Exemplo n.º 4
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
Exemplo n.º 5
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