void CSwordSlashController::process(const std::shared_ptr<Logic::IMessage> &message)
	{
		if((message->getType().compare("TOUCHED") == 0))
		{
			Logic::CEntity *otherEntity = dynamic_cast<TOUCHED*>(message.get())->getEntidad();

			if(otherEntity)
			{
				if (otherEntity->getTag() == "enemy")
				{
					if(_damage>0)
					{
						std::shared_ptr<DAMAGED> m(new DAMAGED());
						m->setFloat(_damage);
						m->setString(_entity->getType());
						otherEntity->emitMessage(m);

						std::shared_ptr<PUSH> pushMessage(new PUSH());
						pushMessage->setDirection(_direction);
						pushMessage->setSpeed(0.5f);
						otherEntity->emitMessage(pushMessage, this);

						//BaseSubsystems::Log::Debug("ÑAPA: " + std::to_string(_damage));
					}

					Logic::CEntityFactory::getSingletonPtr()->createEntityByType("ChispaDanhoEnemy",
						otherEntity->getCenterPosition(), 
						_entity->getMap());
				}
			}
		}
	} // process
	void activateHealZone(unsigned int entityID)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::MActivateHealZone *m = new Logic::MActivateHealZone();
		entity->emitMessage(m);
	}
	void atacarJack(unsigned int entityID)
	{
		Logic::CEntity * jack = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::CEntity* * entidadesColision;
		int numColisiones = Physics::CServer::getSingletonPtr()->detectCollisions(jack->getPosition(), 40, entidadesColision);

		for(int i = 0; i < numColisiones; ++i)
		{
			if (!entidadesColision[i]->getTag().compare("enemy")) 
			{
				//Entidad enemiga que atacará a Jack
				Logic::CEntity * entidad = entidadesColision[i];

				std::stringstream script;
				script << "enemyEvent(\"AttackJack\", " << entidad->getEntityID() << ")";
				ScriptManager::CServer::getSingletonPtr()->executeScript(script.str().c_str());

				Logic::MAttackEntity *message = new Logic::MAttackEntity();
				message->setAttack(true);
				message->setEntity(jack);
				entidad->emitMessage(message);
			}
		}
	}
	void empujarCircle(unsigned int entityID)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::MPushEntities *m = new Logic::MPushEntities();

		entity->emitMessage(m);
	}
	void SendMinionCreated(Logic::CEntity* minionCreated, std::string leaderName)
	{
		Logic::CEntity* leader = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName(leaderName);

		std::shared_ptr<Logic::GET_LOGIC_ENTITY>m(new Logic::GET_LOGIC_ENTITY());
		m->setEntity(minionCreated);
		leader->emitMessage(m);
	}
	void shakeCamera(Logic::CEntity *entity, float max, float min)
	{
		Logic::CEntity* cam = entity->getMap()->getEntityByType("Camera");

		std::shared_ptr<Logic::SHAKE> m(new Logic::SHAKE());
		m->setMaxShake(max);
		m->setMinShake(min);
		cam->emitMessage(m);
	}
	void cancelCure(unsigned int entityID)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);
		
		Logic::MCureEntity *m = new Logic::MCureEntity();
		m->setCure(false);

		entity->emitMessage(m);
	}
	void detenerEnemigosContraEnemigos(unsigned int entityID)
	{
		//Mandamos un mensaje para que salga el icono de aturdido
		Logic::MAturdido *message = new Logic::MAturdido();
		message->setAturdido(false);
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);
		if (entity)
			entity->emitMessage(message);
	}
	void launchFlameThrower(unsigned int entityID, float point_x, float point_y, float point_z)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::MLanzarLlamas *m = new Logic::MLanzarLlamas();
		m->setPosition(Vector2(point_x, point_z));
		m->setOrdenLlamas(Logic::OrdenLlamas::lanzarLlamas);

		entity->emitMessage(m);
	}
Esempio n. 10
0
	void cancelFlameThrower(unsigned int entityID)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::MLanzarLlamas *m = new Logic::MLanzarLlamas();
		m->setPosition(Vector2(0, 0));
		m->setOrdenLlamas(Logic::OrdenLlamas::ocultarBLamas);

		entity->emitMessage(m);
	}
Esempio n. 11
0
	void launchPowerShoot(unsigned int entityID, float point_x, float point_y, float point_z)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::MDisparosPotentes *m = new Logic::MDisparosPotentes();
		m->setPosition(Vector2(point_x, point_z));
		m->setOrdenDisparos(Logic::OrdenDisparos::disparar);

		entity->emitMessage(m);
	}
Esempio n. 12
0
	void cancelPowerShoot(unsigned int entityID)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::MDisparosPotentes *m = new Logic::MDisparosPotentes();
		m->setPosition(Vector2(0, 0));
		m->setOrdenDisparos(Logic::OrdenDisparos::ocultarCono);

		entity->emitMessage(m);
	}
Esempio n. 13
0
	void launchGrenade(unsigned int entityID, float point_x, float point_y, float point_z)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::MLanzarGranada *m = new Logic::MLanzarGranada();
		//m->setPosition(Vector2(entity->getPosition().x, entity->getPosition().y));
		m->setPosition(Vector2(point_x, point_z));
		m->setOrdenGranada(Logic::OrdenGranada::lanzar);

		entity->emitMessage(m);
	}
Esempio n. 14
0
	void startCure(unsigned int entityID, unsigned int entityIDTarget)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);
		Logic::CEntity *entityTarget = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityIDTarget);

		Logic::MCureEntity *m = new Logic::MCureEntity();
		m->setEntity(entityTarget);
		m->setCure(true);

		entity->emitMessage(m);
	}
Esempio n. 15
0
	void CCameraFeedbackNotifier::damaged(Vector3 vEnemyPosition) {
		std::shared_ptr<Logic::CMessageCameraOffset> m3 = std::make_shared<Logic::CMessageCameraOffset>();
		m3->setOffsetTimer(100.0f);//Timer								 
		Logic::CEntity * camera = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName("Camera");
		assert(camera != NULL && "Error: Esto no se puede hacer asi que sois unos lamers, ahora el servidor que hace?");
		camera->emitMessage(m3);

		_scene->setCompositorVisible(_effect, true);
		_effectIsActivated = true;
		_timestamp = 0;

		calculateEnemyPosition(vEnemyPosition);
	}// damaged
Esempio n. 16
0
	void activateBulletTime(unsigned int entityID)
	{
		Logic::CEntity *entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::MActivarTiempoBala *m = new Logic::MActivarTiempoBala();
		m->setTime(5.0f);
		unsigned int norah = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName("Norah")->getEntityID();
		unsigned int jack = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName("Jack")->getEntityID();
		unsigned int erick = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName("Erick")->getEntityID();
		m->addEntity(norah);
		m->addEntity(jack);
		m->addEntity(erick);

		unsigned int playerGod = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName("PlayerGod")->getEntityID();
		m->addEntity(playerGod);
		
		entity->emitMessage(m);
	}
Esempio n. 17
0
	void enemigosContraEnemigos(unsigned int entityID)
	{
		Logic::CEntity * norah = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		Logic::CEntity* * entidadesColision;
		int numColisiones = Physics::CServer::getSingletonPtr()->detectCollisions( norah->getPosition(),80,entidadesColision);

		//Iniciamos la tabla de los enemigos afectados
		std::stringstream script1;
		script1 << "enemigosConfundidos = {}";
		ScriptManager::CServer::getSingletonPtr()->executeScript(script1.str().c_str());


		for(int i = 0; i < numColisiones; ++i)
		{
			if ( !entidadesColision[i]->getTag().compare("enemy") ) {
				//Entidad enemiga que atacara a otros enemigos
				Logic::CEntity * entidad = entidadesColision[i];

				float distX = entidad->getPosition().x - norah->getPosition().x;
				float distZ = entidad->getPosition().z - norah->getPosition().z;
				float distance2 = distX * distX + distZ * distZ;

				//Solo entraran al estado los que esten a una distancia menor de 40
				if (distance2 < 40 * 40) {
					std::stringstream script2;
					script2 << "enemyEvent(\"AttackOtherEnemies\", " << entidad->getEntityID() << ")";
					ScriptManager::CServer::getSingletonPtr()->executeScript(script2.str().c_str());

					//Mandamos un mensaje para que salga el icono de aturdido
					Logic::MAturdido *message = new Logic::MAturdido();
					message->setAturdido(true);
					entidad->emitMessage(message);
				}

				//Atacaran hasta a los que esten a una distancia de 80

				//Añadimos el enemigo a la tabla de los enemigos afectados entre los que se pueden atacar
				std::stringstream script3;
				script3 << "enemigosConfundidos[" << i+1 << "] = " << entidad->getEntityID();
				ScriptManager::CServer::getSingletonPtr()->executeScript(script3.str().c_str());
			}
		}
	}
Esempio n. 18
0
	void activateMassHeal(unsigned int entityID, float heal)
	{
		Logic::CEntity *healer = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);

		/*Logic::CEntity *jackEntity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName("Jack");
		Logic::CEntity *erickEntity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName("Erick");
		Logic::CEntity *norahEntity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByName("Norah");

		Logic::MHealed *m_heal = new Logic::MHealed();
		m_heal->setHeal(heal);
		m_heal->setHealer(healer);*/

		Logic::CEntity *playerEntity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByTag("Player");
		while (playerEntity != NULL) {
			Logic::MHealed *m_heal = new Logic::MHealed();
			m_heal->setHeal(heal);
			m_heal->setHealer(healer);
			playerEntity->emitMessage(m_heal);

			playerEntity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByTag("Player", playerEntity);
		}
	}
	void sendCancelOpenChestMessage(Logic::CEntity &entity)
	{
		std::shared_ptr<Logic::CANCEL_OPEN> m (new Logic::CANCEL_OPEN());
		entity.emitMessage(m);
	}
	//Manda un mensaje de OPEN_CHEST desde LUA a la entidad indicada
	void sendOpenChestMessage(Logic::CEntity &entity)
	{
		std::shared_ptr<Logic::OPEN_CHEST> m (new Logic::OPEN_CHEST());
		entity.emitMessage(m);

	}