Ejemplo n.º 1
0
   void DistanceSensorActor::OnEnteredWorld()
   {
      BaseClass::OnEnteredWorld();
      if (GetAttachToActor() != NULL)
      {
         if (GetParent() != NULL)
         {
            Emancipate();
         }
         else if (GetSceneParent() != NULL)
         {
            GetSceneParent()->RemoveDrawable(this);
         }

         GetAttachToActor()->AddChild(this);
      }

      if (IsRemote())
      {
         GetGameActorProxy().RegisterForMessages(dtGame::MessageType::TICK_REMOTE, dtGame::GameActorProxy::TICK_REMOTE_INVOKABLE);
      }
      else
      {
         GetGameActorProxy().RegisterForMessages(dtGame::MessageType::TICK_LOCAL, dtGame::GameActorProxy::TICK_LOCAL_INVOKABLE);
      }
   }
Ejemplo n.º 2
0
void KillableTargetActor::SetCurrentHealth(int currentHealth)
{
   currentHealth = dtUtil::Max(currentHealth, 0);
   if (currentHealth == 0 && mCurrentHealth > currentHealth && mCurrentHealth != 0)
   {
      mLargeExplosion->SetEnabled(true);
      SwitchVisitor switchVisitor("Destroyed");
      GetOSGNode()->accept(switchVisitor);

      mCurrentShaderName = "Normal";
      ApplyMyShader();
   }
   else if (currentHealth != 0 && mCurrentHealth > currentHealth)
   {
      mSmallExplosion->SetEnabled(true);
   }
   else if (currentHealth > 0 && mCurrentHealth == 0)
   {
      SwitchVisitor switchVisitor("Good");
      GetOSGNode()->accept(switchVisitor);
   }
   mCurrentHealth = currentHealth;

   GetGameActorProxy().NotifyFullActorUpdate();
}
Ejemplo n.º 3
0
void KillableTargetActor::OnEnteredWorld()
{
   // Initialize private state
   dtActors::GameMeshActor::OnEnteredWorld();

   // small explosion
   mSmallExplosion = new dtCore::ParticleSystem();
   mSmallExplosion->LoadFile("Particles/explosion_small.osg",true);
   GetGameActorProxy().GetGameManager()->GetScene().AddDrawable(mSmallExplosion.get());
   //AddChild(mSmallExplosion.get());

   // large explosion
   mLargeExplosion = new dtCore::ParticleSystem();
   mLargeExplosion->LoadFile("Particles/explosion_large.osg",true);
   GetGameActorProxy().GetGameManager()->GetScene().AddDrawable(mLargeExplosion.get());
   //AddChild(mLargeExplosion.get());

   GetTransform(mOriginalPosition);
   ResetState();
}
Ejemplo n.º 4
0
void MineActor::SetupFloaterComponent()
{
#ifdef BUILD_WITH_DTOCEAN
   //find any OceanActors;
   dtOcean::OceanActorProxy* oceanActorProxy(NULL);
   GetGameActorProxy().GetGameManager()->FindActorByType(*OceanActorRegistry::OCEAN_ACTOR_TYPE, oceanActorProxy);
   dtOcean::OceanActor* oceanActor(NULL);
   oceanActorProxy->GetActor(oceanActor);
   assert(oceanActor != NULL);

   // Create a new floater component with the ocean
   mpFloaterComponent = new SimpleFloaterActorComponent(*oceanActor);
   AddComponent(*mpFloaterComponent);
#endif
}
Ejemplo n.º 5
0
   void TaskActorGameEvent::HandleGameEvent(const dtGame::Message &msg)
   {
      const dtGame::GameEventMessage &eventMsg = static_cast<const dtGame::GameEventMessage&>(msg);

      if(eventMsg.GetGameEvent() == NULL)
      {
         LOG_WARNING("HandleGameEvent: Game event message contained a NULL game event.");
         return;
      }

      if( ! mGameEvent.valid() && ! mGameEventFail.valid() )
      {
         LOG_WARNING("HandleGameEvent: Game event task actor has NULL game events.  Perhaps it was "
                    " assigned to the task before being added to the event manager.");
         return;
      }

      // Determine which event has been received.
      const dtCore::UniqueId& eventId = eventMsg.GetGameEvent()->GetUniqueId();
      bool isFailEvent = false;
      if( mGameEvent.valid() && eventId == mGameEvent->GetUniqueId() )
      {
         // DO NOTHING.
      }
      else if( mGameEventFail.valid() && eventId == mGameEventFail->GetUniqueId() )
      {
         isFailEvent = true;
      }
      else
      {
         // Not an event to act upon.
         return;
      }

      //If we got here we have a game event we were looking for.  So, all we need to do
      //is track the number of times we got the event, and if it reaches the min occurances
      //attempt to mark ourselves complete.
      TaskActorProxy &proxy = static_cast<TaskActorProxy&>(GetGameActorProxy());
      if(!IsComplete() && !IsFailed())
      {
         if(proxy.RequestScoreChange(proxy,proxy))
         {
            if( isFailEvent ) // Fail event
            {
               SetFailed( true );
            }
            else // Complete Event
            {
               mNumTimesEventFired++;
               float newScore = (float)mNumTimesEventFired / (float)mMinOccurances;
               if (newScore >= GetPassingScore())
                  SetComplete(true);

               SetScore(newScore);
            }

            // Notify the system that the task state has changed.
            proxy.NotifyScoreChanged(proxy);
            proxy.NotifyFullActorUpdate();
         }
      }
   }