Exemplo n.º 1
0
void TerrySpawner::HandleNodeCollision(StringHash eventType, VariantMap& eventData)
{
	using namespace NodeCollision;

	RigidBody* rb = static_cast<RigidBody*>(eventData[P_BODY].GetPtr());

	Node* noed = rb->GetNode();

	if (!noed->GetVar("canAttack").GetBool())
	{
		return;
	}

	if (noed->GetComponent<Blind>())
	{
		return;
	}

	noed->SetVar("canAttack", false);

	SharedPtr<Node> otherNode = SharedPtr<Node>(static_cast<Node*>(eventData[P_OTHERNODE].GetPtr()));

	if (!otherNode->HasComponent<Health>())
	{
		return;
	}

	bool enemy = false;

	if (otherNode->GetVar("npcType").GetInt() == 0)//hero
	{
		enemy = true;
	}

	if (enemy || noed->HasComponent<Enchanted>())
	{
		int healthMod = noed->GetVar("attack").GetInt();

		if (otherNode->HasComponent<Armor>())
		{
			healthMod = noed->GetVar("attack").GetInt() - otherNode->GetComponent<Armor>()->armor_;

			if (healthMod < 0)
			{
				healthMod = 0;
			}
		}

		otherNode->GetComponent<Health>()->ModifyHealth(healthMod, -1, false);

		if (otherNode->GetComponent<Health>()->health_ <= 0)
		{
			if (!enemy && noed->HasComponent<Enchanted>())
			{
				otherNode->GetComponent<Health>()->ModifyHealth(100, 0, false);
				otherNode->GetScene()->GetComponent<TerrySpawner>()->RespawnTerry(otherNode);
			}
			else if (otherNode->GetName() != "tent")
			{
				if (!otherNode->HasComponent<Dead>())
				{
					otherNode->AddComponent(new Dead(context_, main_, -1.0f), 0, LOCAL);
				}
			}
			else
			{
				SpriteSheetPlayer* ssp = main_->mySceneNode_->GetComponent<SpriteSheetPlayer>();
				for (int x = 0; x < ssp->sprites_.Size(); x++)
				{
					if (!ssp->sprites_[x]->noed_->HasComponent<Dead>())
					{
						ssp->sprites_[x]->noed_->AddComponent(new Dead(context_, main_, -1.0f), 0, LOCAL);

						Node* particleStartNode_ = ssp->sprites_[x]->noed_->GetScene()->CreateChild(0,LOCAL);
						particleStartNode_->SetPosition(ssp->sprites_[x]->noed_->GetPosition());

						particleStartNode_->AddComponent(new TimedRemove(context_, main_, 2.0f), 0, LOCAL);

						particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
						particleStartNode_->GetComponent<SoundSource3D>()->SetGain(0.1f);
						particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/319071__mishicu__v8.ogg"));

					}
				}
			}

			return;
		}

		/*if (!noed->HasComponent<Stunned>())
		{
			noed->AddComponent(new Stunned(context_, main_, 2.0f), 0, LOCAL);
		}*/
	}
}
Exemplo n.º 2
0
void DotsNetCrits::AttachLogicComponents(SharedPtr<Node> sceneNode)
{
	sceneNode->AddComponent(new ModelPlayer(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new TopDownCamera(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new ThirdPersonCamera(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Speed(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Gravity(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new MoveByTouch(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new RotateTo(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Silence(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Teleport(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Sprint(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Snare(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Blind(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Melee(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Health(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Mute(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Armor(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Shield(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new DPSHeal(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new BlindingFlash(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Crit(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new DOT(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new DOTHeal(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new AOE(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new AOEHeal(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Cloak(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Cleanse(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new Knockback(context_, main_), 0, LOCAL);

	sceneNode->AddComponent(new SoundPlayer(context_, main_), 0, LOCAL);
}
Exemplo n.º 3
0
void TerrySpawner::HandleNodeCollisionStart(StringHash eventType, VariantMap& eventData)
{
	using namespace NodeCollisionStart;

	SharedPtr<Node> otherNode = SharedPtr<Node>(static_cast<Node*>(eventData[P_OTHERNODE].GetPtr()));
	RigidBody* rb = static_cast<RigidBody*>(eventData[P_BODY].GetPtr());

	Node* noed = rb->GetNode();

	if (otherNode->GetName() == "safetyNet")
	{
		RespawnTerry(noed);
		return;
	}

	if (!otherNode->HasComponent<Health>())
	{
		return;
	}

	if (otherNode->GetVar("npcType").GetInt() == 0)//hero
	{
		MoveByTouch* mbt = noed->GetComponent<MoveByTouch>();
		mbt->MoveTo(otherNode->GetWorldPosition(),
				mbt->moveToSpeed_,mbt->speedRamp_,mbt->gravity_,mbt->gravityRamp_,false,true,true);

		int collisionCount = noed->GetVar("collisionCount").GetInt();
		collisionCount++;
		noed->SetVar("collisionCount", collisionCount);

		if (collisionCount == 1)
		{
			VariantMap vm;
			vm[AnimateSceneNode::P_NODE] = noed;

			if (noed->GetVar("sex").GetBool())
			{
				vm[AnimateSceneNode::P_ANIMATION] = "attackF";
			}
			else
			{
				vm[AnimateSceneNode::P_ANIMATION] = "attackM";
			}

			vm[AnimateSceneNode::P_LOOP] = false;
			vm[AnimateSceneNode::P_LAYER] = 0;
			SendEvent(E_ANIMATESCENENODE, vm);
		}

		if (noed->GetComponent<Blind>() || noed->GetComponent<Stunned>())
		{
			return;
		}

		int healthMod = noed->GetVar("attack").GetInt();

		if (otherNode->HasComponent<Armor>())
		{
			healthMod = noed->GetVar("attack").GetInt() - otherNode->GetComponent<Armor>()->armor_;

			if (healthMod < 0)
			{
				healthMod = 0;
			}
		}

		otherNode->GetComponent<Health>()->ModifyHealth(healthMod, -1, false);

		if (otherNode->GetComponent<Health>()->health_ <= 0)
		{
			if (otherNode->GetName() != "tent")
			{
				if (!otherNode->HasComponent<Dead>())
				{
					otherNode->AddComponent(new Dead(context_, main_, -1.0f), 0, LOCAL);
				}
			}
			else
			{
				SpriteSheetPlayer* ssp = main_->mySceneNode_->GetComponent<SpriteSheetPlayer>();
				for (int x = 0; x < ssp->sprites_.Size(); x++)
				{
					if (!ssp->sprites_[x]->noed_->HasComponent<Dead>())
					{
						ssp->sprites_[x]->noed_->AddComponent(new Dead(context_, main_, -1.0f), 0, LOCAL);

						Node* particleStartNode_ = ssp->sprites_[x]->noed_->GetScene()->CreateChild(0,LOCAL);
						particleStartNode_->SetPosition(ssp->sprites_[x]->noed_->GetPosition());

						particleStartNode_->AddComponent(new TimedRemove(context_, main_, 2.0f), 0, LOCAL);

						particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
						particleStartNode_->GetComponent<SoundSource3D>()->SetGain(0.1f);
						particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/319071__mishicu__v8.ogg"));

					}
				}
			}

			//otherNode->GetComponent<Health>()->ModifyHealth(100, 0, false);
			//otherNode->GetScene()->GetComponent<TerrySpawner>()->RespawnTerry(otherNode);
			return;
		}

		/*if (!noed->HasComponent<Stunned>())
		{
			noed->AddComponent(new Stunned(context_, main_, 2.0f), 0, LOCAL);
		}*/
	}
}
Exemplo n.º 4
0
void WizardSkill0::HandleNodeCollisionStart(StringHash eventType, VariantMap& eventData)
{
	using namespace NodeCollisionStart;

	SharedPtr<Node> otherNode = SharedPtr<Node>(static_cast<Node*>(eventData[P_OTHERNODE].GetPtr()));
	RigidBody* otherRB = static_cast<RigidBody*>(eventData[P_OTHERBODY].GetPtr());

	RigidBody* rb = static_cast<RigidBody*>(eventData[P_BODY].GetPtr());
	Node* noed = rb->GetNode();

	if (!otherNode->HasComponent<Health>())
	{
		/*Node* particleStartNode_ = noed->GetScene()->CreateChild(0,LOCAL);
		ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
		emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/dustCloud.xml"));
		emitterStartFX_->SetViewMask(1);
		particleStartNode_->SetPosition(noed->GetPosition() + (Vector3::UP));
		emitterStartFX_->SetEmitting(true);

		particleStartNode_->AddComponent(new TimedRemove(context_, main_, 2.0f), 0, LOCAL);*/

		/*Node* lightNode = noed->GetScene()->CreateChild(0,LOCAL);
		lightNode->SetPosition(noed->GetPosition() + (Vector3::UP));
		Light* light = lightNode->CreateComponent<Light>(LOCAL);
		light->SetBrightness(2.0f);
		light->SetPerVertex(true);
		light->SetRange(5.0f);
		lightNode->AddComponent(new TimedRemove(context_, main_, 0.1f), 0, LOCAL);*/

		//noed->Remove();
		return;
	}

	if (otherNode->GetVar("npcType").GetInt() == 1)//terry
	{
		otherNode->GetComponent<Health>()->ModifyHealth(50, -1, false);

		if (otherNode->GetComponent<Health>()->health_ <= 0)
		{
			otherNode->GetComponent<Health>()->ModifyHealth(100, 0, false);
			otherNode->GetScene()->GetComponent<TerrySpawner>()->RespawnTerry(otherNode);
		}

		Vector3 victoria = otherNode->GetPosition();
		Vector3 dir = (victoria - noed->GetPosition()).Normalized();
		dir.y_ = 1.0f;
		dir *= 10.0f;

		otherNode->AddComponent(new Stunned(context_, main_, 4.0f), 0, LOCAL);

		otherRB->ApplyImpulse(dir);

		/*Node* particleStartNode_ = noed->GetScene()->CreateChild(0,LOCAL);
		ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
		emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/dustCloud.xml"));
		emitterStartFX_->SetViewMask(1);
		particleStartNode_->SetPosition(noed->GetPosition() + (Vector3::UP));
		emitterStartFX_->SetEmitting(true);

		particleStartNode_->AddComponent(new TimedRemove(context_, main_, 2.0f), 0, LOCAL);*/

		/*Node* lightNode = noed->GetScene()->CreateChild(0,LOCAL);
		lightNode->SetPosition(noed->GetPosition() + (Vector3::UP));
		Light* light = lightNode->CreateComponent<Light>(LOCAL);
		light->SetBrightness(2.0f);
		light->SetPerVertex(true);
		light->SetRange(5.0f);
		lightNode->AddComponent(new TimedRemove(context_, main_, 0.1f), 0, LOCAL);*/

		//noed->Remove();
	}
}