Esempio n. 1
0
/**
*  @brief
*    Called when a scene node was found
*/
void SNProjectile::OnSceneNode(SceneQuery &cQuery, SceneNode &cSceneNode)
{
	// Is this projectile still active?
	if (IsActive()) {
		// Is this a bomb?
		if (cSceneNode.IsInstanceOf("SNBomb")) {
			// Is the bomb still alive?
			if (!cSceneNode.GetAttribute("Killed")->GetBool()) {
				// Jap, kill the bomb right now
				cSceneNode.SetAttribute("Killed", "1");

				// Destroy this projectile
				Delete();

				// Done, do NOT continue the query!
				cQuery.Stop();
			}

		// Is this the UFO? (can not be killed :)
		} else if (cSceneNode.IsInstanceOf("SNUFO")) {
			// Jap, destroy this projectile
			Delete();

			// Done, do NOT continue the query!
			cQuery.Stop();
		}
	}
}
/**
*  @brief
*    Updates the text of the time scale text node
*/
void Application61::UpdateTimeScaleTextNode()
{
	// Get the scene
	SceneContainer *pSceneContainer = GetScene();
	if (pSceneContainer) {
		// Get the scene info text container
		SceneContainer *pInfoTextContainer = static_cast<SceneContainer*>(pSceneContainer->GetByName("Parent.InfoText"));
		if (pInfoTextContainer) {
			// Get the time scale text scene node
			SceneNode *pInfoTextNode = pInfoTextContainer->GetByName("TimeScale");
			if (pInfoTextNode)
				pInfoTextNode->SetAttribute("Text", PLT("1/2/0=Decrease/increase/reset timescale (current: ") + Timing::GetInstance()->GetTimeScaleFactor() + ')');
		}
	}
}
Esempio n. 3
0
/**
*  @brief
*    Called when a scene node was found
*/
void SNGun::OnSceneNode(SceneQuery &cQuery, SceneNode &cSceneNode)
{
	// Is this gun still active?
	if (IsActive()) {
		// Is this a bomb?
		if (cSceneNode.IsInstanceOf("SNBomb")) {
			// Is the bomb still alive?
			if (!cSceneNode.GetAttribute("Killed")->GetBool()) {
				// Jap, kill the bomb right now
				cSceneNode.SetAttribute("Killed", "1");

				// Destroy this gun
				Delete();

				// Done, do NOT continue the query!
				cQuery.Stop();
			}
		}
	}
}
//[-------------------------------------------------------]
//[ Private virtual PLCore::AbstractFrontend functions    ]
//[-------------------------------------------------------]
void Application60::OnUpdate()
{
	// One important word at the beginning: DON'T COPYCAT THIS!
	// The following is 'just' a simple demonstration how the scene graph 'can' be used. It's
	// definitely not good to update your scene nodes in the way you can see within this function.
	// Its quite to intricate, inflexible and not performant. Use for example a scene node modifier
	// added to your scene node (in this case 'the white light') for this job!

	// Call base implementation
	EngineApplication::OnUpdate();

	// Get the scene container with our 'concrete scene'
	SceneContainer *pSceneContainer = GetScene();
	if (pSceneContainer) {
		// Get the scene node with the name 'Light' (our 'white light')
		SceneNode *pLightSceneNode = pSceneContainer->GetByName("Light");
		if (pLightSceneNode) {
			// This variable is used for the light animation. Its just static you keep the implementation
			// for a good sample overview completely within this function.
			static float fLightTimer = 0.0f;

			// Get a new fancy light position
			const Vector3 vPosition(Math::Sin(fLightTimer), Math::Sin(fLightTimer)/2+2, -(Math::Cos(fLightTimer)+5));

			// We set the current light position using the RTTI class interface. This is quite comfortable and
			// universal because you haven't to care about the concrete class type - just set the variable values.
			pLightSceneNode->SetAttribute("Position", Var<Vector3>(vPosition));	// More efficient
			// Another way by using strings:
			// pLightSceneNode->SetAttribute("Position", vPosition.ToString());	// More generic
			// For highly performance critical situations it's recommend to avoid using these RTTI
			// functions to set your variables and use the concrete provided class interfaces instead.

			// Update the light timer by using the time difference between the last and the current frame
			fLightTimer += Timing::GetInstance()->GetTimeDifference();
		}
	}
}