예제 #1
0
   void MessagePacket::FillMessage(dtGame::Message& message) const
   {
      // The Destination and Source MachineInfo are set by the NetworkComponent!
      message.SetSendingActorId(mSendingActor);
      message.SetAboutActorId(mAboutActor);

      message.FromString(mMessageParameters);
   }
예제 #2
0
 MessagePacket::MessagePacket(const dtGame::Message& message)
    : GNE::Packet(MessagePacket::ID)
    , mDestination("")
    , mSource(message.GetSource().GetUniqueId())
    , mSendingActor(message.GetSendingActorId())
    , mAboutActor(message.GetAboutActorId())
 {
    BuildFromMessage(message);
 }
예제 #3
0
void TestAARHUD::ProcessMessage(const dtGame::Message& message)
{
   if (message.GetMessageType() == dtGame::MessageType::TICK_LOCAL)
   {
      TickHUD();
   }
   else if (message.GetMessageType() == dtGame::MessageType::INFO_MAP_LOADED)
   {
      GetGameManager()->GetScene().AddDrawable(GetGUIDrawable());
   }
}
예제 #4
0
void KillableTargetActor::ProcessMessage(const dtGame::Message& message)
{
   // HANDLE GAME EVENT MESSAGE - "TankFired"
   if (message.GetMessageType() == dtGame::MessageType::INFO_GAME_EVENT)
   {
      const dtGame::GameEventMessage& eventMsg =
         static_cast<const dtGame::GameEventMessage&>(message);

      // Note, we are using strings which aren't constants.  In a real application, these
      // event names should be stored in some sort of shared place and should be constants...
      if (eventMsg.GetGameEvent() != 0 && eventMsg.GetGameEvent()->GetName() == "TankFired")
      {
         if (mIsTargeted && mCurrentHealth > 0)
         {
            SetCurrentHealth(GetCurrentHealth() - 25);
         }
      }
      // test our shaders
      else if (eventMsg.GetGameEvent() != 0 && eventMsg.GetGameEvent()->GetName() == "TestShaders")
      {
         // Note, this behavior is now done in the InputComponent.cpp using the new Shader method.
         //dtCore::ShaderManager::GetInstance().Clear();
         //dtCore::ShaderManager::GetInstance().LoadShaderDefinitions("Shaders/TutorialShaderDefs.xml", false);
         //ApplyMyShader();
      }
      // reset me!
      else if (eventMsg.GetGameEvent() != 0 && eventMsg.GetGameEvent()->GetName() == "ResetStuff")
      {
         SetTransform(mOriginalPosition);
         ResetState();
      }
   }
   // HANDLE TARGET CHANGED MESSAGE
   else if (message.GetMessageType() == TutorialMessageType::TANK_TARGET_CHANGED)
   {
      const TargetChangedMessage& targetChanged = static_cast<const TargetChangedMessage&>(message);
      mIsTargeted = (targetChanged.GetNewTargetUniqueId() ==  GetUniqueId());

      if (mIsTargeted && mCurrentHealth > 0)
      {
         // Ahhhh! Get that gun outta my face!
         mCurrentShaderName = "Green";
      }
      else
      {
         //mCurrentShaderName = "Green";
         mCurrentShaderName = "Normal";
      }

      ApplyMyShader();
   }

}
예제 #5
0
void OceanActor::ProcessMessage(const dtGame::Message& msg)
{
   if (msg.GetMessageType() == dtGame::MessageType::INFO_MAP_LOADED)
   {
      OnMapLoaded();
   }
}
예제 #6
0
   void MessagePacket::BuildFromMessage(const dtGame::Message& message)
   {
      // Get the Id from the message
      mMessageId = message.GetMessageType().GetId();

      // If the message has a destination, encapsulate
      if (message.GetDestination() != NULL)
      {
         mDestination = message.GetDestination()->GetUniqueId();
      }

      // encapsulate source
      mSource = message.GetSource().GetUniqueId();

      // encapsulate actor Id's
      mSendingActor = message.GetSendingActorId();
      mAboutActor = message.GetAboutActorId();

      // Get the MessageParameters from the message
      message.ToString(mMessageParameters);
   }
예제 #7
0
void FireActor::PlayFireSound(const dtGame::Message& msg)
{
   // Check to see if the actor is the door to the fire room
   dtGame::GameActorProxy* proxy = GetGameActorProxy().GetGameManager()->FindGameActorById(msg.GetAboutActorId());
   if (proxy == NULL)
   {
      return;
   }

   HatchActor* ha = dynamic_cast<HatchActor*>(proxy->GetActor());
   if (ha == NULL)
   {
      return;
   }

   // Hatch item was activated/deactivated, play/stop the sound
   ha->IsActivated() ? mItemUseSnd->Play() : mItemUseSnd->Stop();
}