Exemple #1
0
void HelloGUI::HandleControlClicked(StringHash eventType, VariantMap& eventData)
{
    // Get the Text control acting as the Window's title
    Text* windowTitle = static_cast<Text*>(window_->GetChild("WindowTitle", true));

    // Get control that was clicked
    UIElement* clicked = static_cast<UIElement*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());

    String name = "...?";
    if (clicked)
    {
        // Get the name of the control that was clicked
        name = clicked->GetName();
    }

    // Update the Window's title text
    windowTitle->SetText("Hello " + name + "!");
}
Exemple #2
0
void GameMain::HandleControlClicked(StringHash eventType, VariantMap& eventData)
{
	// Get control that was clicked
	UIElement* clicked = static_cast<UIElement*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());

	String name = "...?";
	if (clicked)
	{
		// Get the name of the control that was clicked
		name = clicked->GetName();
		if (name == "New Game") 
		{
			
		}
		else if (name == "Exit") 
		{
			engine_->Exit();
		}
	}
}
Exemple #3
0
void RogueSkill4::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
	UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());

	String name = ele->GetName();

	if (name == "rogue")
	{
		skillSprite_->SetTexture(main_->cache_->
				GetResource<Texture2D>("Textures/terriesHud/icons/rogue/W_Throw05.png"));
		skillSprite_->SetOpacity(1.0f);
	}

	if (name == "skill4")
	{
		if (node_->HasComponent<Dead>())
		{
			return;
		}

		if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "rogue")
		{
			if (enabled_)
			{
				//node_->RemoveComponent<Stunned>();
				enabled_ = false;
				return;
			}

			if (!touchSubscribed_)
			{
				touchSubscribed_ = true;
				VariantMap vm;
				SendEvent(E_TOUCHSUBSCRIBE, vm);
			}

			SubscribeToEvent(E_TOUCHEND, HANDLER(RogueSkill4, HandleTouchEnd));
		}
	}
}
void WizardSkill0::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
	UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());

	String name = ele->GetName();

	if (name == "wizard")
	{
		skillSprite_->SetTexture(main_->cache_->
				GetResource<Texture2D>("Textures/terriesHud/icons/wizard/S_Fire05.png"));

		skillSprite_->SetOpacity(1.0f);
	}

	if (name == "skill0")
	{
		if (node_->HasComponent<Dead>())
		{
			return;
		}

		if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "wizard")
		{
			if (touchSubscribed_ || cooling_)
			{
				return;
			}

			if (!touchSubscribed_)
			{
				touchSubscribed_ = true;
				VariantMap vm;
				SendEvent(E_TOUCHSUBSCRIBE, vm);
			}

			SubscribeToEvent(E_TOUCHEND, HANDLER(WizardSkill0, HandleTouchEnd));
		}
	}
}
void RangerSkill4::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
    UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());

    String name = ele->GetName();

    if (name == "ranger")
    {
        skillSprite_->SetTexture(main_->cache_->
                                 GetResource<Texture2D>("Textures/terriesHud/icons/ranger/I_SnailShell.png"));
        skillSprite_->SetOpacity(1.0f);
    }

    if (name == "skill4")
    {
        if (node_->HasComponent<Dead>())
        {
            return;
        }

        if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "ranger")
        {
            Node* snail = snail_->Clone(LOCAL);

            snail->AddComponent(new Health(context_, main_), 0, LOCAL);
            snail->GetComponent<Health>()->killOn0_ = true;
            snail->GetComponent<Health>()->health_ = 1000;

            snail->SetEnabled(true);

            snail->SetPosition(node_->GetPosition() + (Vector3::BACK * 0.75) + (Vector3::UP * 0.25f));

            VariantMap vm;
            vm[AnimateSceneNode::P_NODE] = node_;

            if (node_->GetVar("sex").GetBool())
            {
                vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
            }
            else
            {
                vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
            }

            vm[AnimateSceneNode::P_LOOP] = false;

            vm[AnimateSceneNode::P_LAYER] = 0;

            SendEvent(E_ANIMATESCENENODE, vm);

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

            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/265385__b-lamerichs__sound-effects-01-03-2015-8-pops-2.ogg"));

        }
    }
}
void WarriorSkill1::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
	UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());

	String name = ele->GetName();

	if (name == "warrior")
	{
		skillSprite_->SetTexture(main_->cache_->
				GetResource<Texture2D>("Textures/terriesHud/icons/warrior/S_Buff14.png"));
		skillSprite_->SetOpacity(1.0f);
	}

	if (name == "skill1")
	{
		if (node_->HasComponent<Dead>())
		{
			return;
		}

		if (cooling_){return;}

		if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "warrior")
		{
			node_->GetComponent<Armor>()->ModifyArmor(1, -1, false);
			int attack = node_->GetVar("attack").GetInt();
			node_->SetVar("attack", attack + 50);
			float attackInterval = node_->GetVar("attackInterval").GetFloat();
			node_->SetVar("attackInterval", attackInterval * 0.5f);

			elapsedTime_ = 0.0f;
			durationElapsedTime_ = 0.0f;
			processing_ = true;
			cooling_ = true;

			VariantMap vm;
			vm[AnimateSceneNode::P_NODE] = node_;

			if (node_->GetVar("sex").GetBool())
			{
				vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
			}
			else
			{
				vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
			}

			vm[AnimateSceneNode::P_LOOP] = false;
			vm[AnimateSceneNode::P_LAYER] = 0;

			SendEvent(E_ANIMATESCENENODE, vm);

			Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
			ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
			emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/terriesFury.xml"));
			emitterStartFX_->SetViewMask(1);
			emitterStartFX_->SetEmitting(true);

			node_->AddChild(particleStartNode_);
			particleStartNode_->SetWorldPosition(node_->GetWorldPosition());
			particleStartNode_->SetScale(0.5f);

			particleNode_ = particleStartNode_;

			particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
			particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/93828__cgeffex__alien-voice8.ogg"));

		}
	}
}
void RangerSkill5::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
    UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());

    String name = ele->GetName();

    if (name == "ranger")
    {
        skillSprite_->SetTexture(main_->cache_->
                                 GetResource<Texture2D>("Textures/terriesHud/icons/ranger/S_Sword03.png"));
        skillSprite_->SetOpacity(1.0f);
    }

    if (name == "skill5")
    {
        if (node_->HasComponent<Dead>())
        {
            return;
        }

        if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "ranger")
        {
            if (enabled_)
            {
                enabled_ = false;
                node_->GetComponent<Armor>()->ModifyArmor(1, -1, false);
                node_->GetComponent<Speed>()->speed_ -= 3.0f;

                node_->RemoveChild(particleNode_);
                return;
            }

            enabled_ = true;

            if (node_->GetComponent<RangerSkill1>()->enabled_)
            {
                node_->GetComponent<RangerSkill1>()->enabled_ = false;
            }

            if (node_->GetComponent<RangerSkill0>()->enabled_)
            {
                node_->GetComponent<RangerSkill0>()->enabled_ = false;
                node_->RemoveComponent<Stunned>();
            }

            node_->GetComponent<Armor>()->ModifyArmor(1, 1, false);
            node_->GetComponent<Speed>()->speed_ += 3.0f;

            Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
            ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
            emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/terriesWhirlwind.xml"));
            emitterStartFX_->SetViewMask(1);
            emitterStartFX_->SetEmitting(true);

            node_->AddChild(particleStartNode_);
            particleStartNode_->SetWorldPosition(node_->GetWorldPosition());
            particleStartNode_->SetScale(0.5f);

            particleNode_ = particleStartNode_;

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

            VariantMap vm;
            vm[AnimateSceneNode::P_NODE] = node_;

            if (node_->GetVar("sex").GetBool())
            {
                vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
            }
            else
            {
                vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
            }

            vm[AnimateSceneNode::P_LOOP] = false;
            vm[AnimateSceneNode::P_LAYER] = 0;

            SendEvent(E_ANIMATESCENENODE, vm);
        }
    }
}
Exemple #8
0
void RogueSkill5::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
	UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());

	String name = ele->GetName();

	if (name == "rogue")
	{
		skillSprite_->SetTexture(main_->cache_->
				GetResource<Texture2D>("Textures/terriesHud/icons/rogue/S_Dagger02.png"));
		skillSprite_->SetOpacity(1.0f);
	}

	if (name == "skill5")
	{
		//if (cooling_){return;}
		if (node_->HasComponent<Dead>())
		{
			return;
		}

		if (node_->GetComponent<RogueSkill0>()->enabled_)
		{
			return;
		}

		if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "rogue")
		{
			if (!enabled_)
			{
				enabled_ = true;

				node_->GetComponent<Armor>()->ModifyArmor(10, -1, false);
				int attack = node_->GetVar("attack").GetInt();
				node_->SetVar("attack", attack + 100);

				Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
				ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
				emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/terriesCrit.xml"));
				emitterStartFX_->SetViewMask(1);
				emitterStartFX_->SetEmitting(true);

				node_->AddChild(particleStartNode_);
				particleStartNode_->SetWorldPosition(node_->GetWorldPosition());
				particleStartNode_->SetScale(0.5f);

				particleNode_ = particleStartNode_;

				particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
				particleStartNode_->GetComponent<SoundSource3D>()->SetGain(0.25f);
				particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/170636__korgchops__8-bit-snare.ogg"));

			}
			else
			{
				enabled_ = false;

				node_->GetComponent<Armor>()->ModifyArmor(10, 1, false);
				int attack = node_->GetVar("attack").GetInt();
				node_->SetVar("attack", attack - 100);

				node_->RemoveChild(particleNode_);
			}

			VariantMap vm;
			vm[AnimateSceneNode::P_NODE] = node_;

			if (node_->GetVar("sex").GetBool())
			{
				vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
			}
			else
			{
				vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
			}

			vm[AnimateSceneNode::P_LOOP] = false;
			vm[AnimateSceneNode::P_LAYER] = 0;

			SendEvent(E_ANIMATESCENENODE, vm);
		}
	}
}
void GameMenu::HandleButtonRelease(StringHash eventType, VariantMap& eventData)
{
	using namespace Released;

	UIElement* ele = static_cast<UIElement*>(eventData[Released::P_ELEMENT].GetPtr());

	network_->Disconnect();

	if (ele->GetName() == "host")
	{
		VariantMap vm;
		vm[GameMenuDisplay::P_STATE] = false;
		SendEvent(E_GAMEMENUDISPLAY, vm);

		if (main_->myRootNode_->HasComponent<Client>())
		{
			main_->myRootNode_->RemoveComponent(
					main_->myRootNode_->GetComponent<Client>());
		}

		if (main_->myRootNode_->HasComponent<Server>())
		{
			main_->myRootNode_->RemoveComponent(
					main_->myRootNode_->GetComponent<Server>());
		}

		main_->myRootNode_->AddComponent(new Server(context_, main_), 0, LOCAL);
	}
	else if (ele->GetName() == "list")
	{
		QueryMasterServer();
	}
	else if (ele->GetName() == "join")
	{
		VariantMap vm;
		vm[GameMenuDisplay::P_STATE] = false;
		SendEvent(E_GAMEMENUDISPLAY, vm);

		if (main_->myRootNode_->HasComponent<Server>())
		{
			main_->myRootNode_->RemoveComponent(
					main_->myRootNode_->GetComponent<Server>());
		}

		if (!main_->myRootNode_->HasComponent<Client>())
		{
			main_->myRootNode_->AddComponent(new Client(context_, main_), 0, LOCAL);
		}

		int index = ((ListView*)serverName_)->GetSelection();

		if (index < 0)
		{
			network_->Connect(ipAddress_, 9002, 0);
			return;
		}

		UIElement* item = ((ListView*)address_)->GetItem(index);
		String address = ((Text*)item)->GetText();

		network_->Connect(address, 9002, 0);
	}
	else if (ele->GetName() == "mainMenuButt")
	{
		VariantMap vm;
		vm[GameMenuDisplay::P_STATE] = true;
		SendEvent(E_GAMEMENUDISPLAY, vm);
	}
}
Exemple #10
0
void RogueSkill0::HandleHudButt(StringHash eventType, VariantMap& eventData)
{
	UIElement* ele = static_cast<UIElement*>(eventData[HudButt::P_BUTT].GetPtr());

	String name = ele->GetName();

	if (name == "rogue")
	{
		skillSprite_->SetTexture(main_->cache_->
				GetResource<Texture2D>("Textures/terriesHud/icons/rogue/S_Shadow16.png"));
		skillSprite_->SetOpacity(1.0f);
	}

	if (name == "skill0")
	{
		//if (cooling_){return;}
		if (node_->HasComponent<Dead>())
		{
			return;
		}

		if (main_->mySceneNode_->GetComponent<SpriteSheetPlayer>()->focusedSprite_ == "rogue")
		{
			Node* particleStartNode_ = node_->GetScene()->CreateChild(0,LOCAL);
			ParticleEmitter* emitterStartFX_ = particleStartNode_->CreateComponent<ParticleEmitter>(LOCAL);
			emitterStartFX_->SetEffect(main_->cache_->GetResource<ParticleEffect>("Particle/terriesInvisibility.xml"));
			emitterStartFX_->SetViewMask(1);
			emitterStartFX_->SetEmitting(true);

			node_->AddChild(particleStartNode_);
			particleStartNode_->SetWorldPosition(node_->GetWorldPosition());
			particleStartNode_->SetScale(0.5f);

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

			particleStartNode_->AddComponent(new SoundSource3D(context_), 0, LOCAL);
			particleStartNode_->GetComponent<SoundSource3D>()->Play(main_->cache_->GetResource<Sound>("Sounds/160756__cosmicembers__fast-swing-air-woosh.ogg"));

			if (!enabled_)
			{
				node_->GetComponent<StaticSprite2D>()->GetCustomMaterial()->SetShaderParameter(
						"MatDiffColor",Color(0.3f, 0.3f, 0.3f, 0.5f));
				node_->GetComponent<Armor>()->ModifyArmor(1, 1, false);
				node_->GetComponent<RigidBody>()->SetCollisionLayerAndMask(4,249);
				enabled_ = true;

				if (node_->GetComponent<RogueSkill2>()->enabled_)
				{
					node_->GetComponent<RogueSkill2>()->enabled_ = false;
				}

				if (node_->GetComponent<RogueSkill5>()->enabled_)
				{
					node_->GetComponent<RogueSkill5>()->enabled_ = false;
				}
			}
			else
			{
				node_->GetComponent<StaticSprite2D>()->GetCustomMaterial()->SetShaderParameter(
						"MatDiffColor",Color(0.3f, 0.3f, 0.3f, 1.0f));
				node_->GetComponent<Armor>()->ModifyArmor(1, -1, false);
				node_->GetComponent<RigidBody>()->SetCollisionLayerAndMask(2,-1);
				enabled_ = false;
			}

			//Variant v = node_->GetComponent<StaticSprite2D>()->GetCustomMaterial()->GetShaderParameter("MatDiffColor");
			//Color c = v.GetColor();LOGERRORF("%s",c.ToString().CString());
			//c.a_ = 0.5f;
			//node_->GetComponent<StaticSprite2D>()->GetCustomMaterial()->SetShaderParameter(
					//"MatDiffColor",Color(0.3f, 0.3f, 0.3f, 0.5f));

			/*elapsedTime_ = 0.0f;
			durationElapsedTime_ = 0.0f;
			processing_ = true;
			cooling_ = true;*/

			VariantMap vm;
			vm[AnimateSceneNode::P_NODE] = node_;

			if (node_->GetVar("sex").GetBool())
			{
				vm[AnimateSceneNode::P_ANIMATION] = "gestureF";
			}
			else
			{
				vm[AnimateSceneNode::P_ANIMATION] = "gestureM";
			}

			vm[AnimateSceneNode::P_LOOP] = false;
			vm[AnimateSceneNode::P_LAYER] = 0;

			SendEvent(E_ANIMATESCENENODE, vm);
		}
	}
}