Beispiel #1
0
// Activates second player and deactives the active one
void Game::ActivateSecondPlayer()
{
    if (m_activePlayerId)
        m_activePlayerId = (m_player1->GetId() == m_activePlayerId) ? m_player2->GetId() : m_player1->GetId();
    else
        m_activePlayerId = (rand() % 2) ? m_player1->GetId() : m_player2->GetId();

    PlayableCard* currentCard = GetActivePlayer()->GetCurrentCard();
    if (!currentCard)
        return;

    // Stop defending if is in defend state
    currentCard->SetDefendState(false);

    Packet packet(SMSG_ACTIVE_PLAYER);
    packet.WriteBitStreamInOrder(currentCard->GetGuid(), { 7, 1, 2, 0, 3, 5, 4, 6 });
    packet.FlushBits();

    packet.WriteByteStreamInOrder(currentCard->GetGuid(), { 7, 5, 4, 2, 6 });
    packet << m_activePlayerId;
    packet.WriteByteStreamInOrder(currentCard->GetGuid(), { 1, 0, 3 });

    BroadcastPacket(packet);
}
void EngineStatePoolShowShot::SetActive(bool active)
{
  if (active)
  {
    GetEngine()->SetLetterbox(true);

    m_pLevel = LevelServer::Instance()->GetCurrentLevel();

    // The "take shot" animation expects the ball to be at the (x, z) origin.
    Orientation o = *(GetActivePlayer()->GetOrientation());
    Vec3f v = GetBall()->GetOrientation()->GetVertex();
    o.SetX(v.x);
    o.SetZ(v.z);

    GetActivePlayer()->SetOrientation(o); 

    if (IsOnlineGame() && 
        Engine::Instance()->GetGameState()->GetCurrentPlayerInfo()->m_isOnline) // TEST
    {
      // Player character was hidden, so unhide
      GetActivePlayer()->SetAlpha(1.0f); 
    }
    GetActivePlayer()->SetActionGo();

    Assert(GetCamera().GetPtr());    
   
    // For testing, allow user to cycle through all valid shots. 
    // Don't play on until key is pressed.
#ifdef SHOW_VALID_SHOTS
    SetMaxTime(99999.9f);
    // Debug print info on current shot
    m_validShotNum = -1;
    Blue(true);
#else
    // POOL - immediately play shot, as the use has already swing the cue.
    // But do wait if player is not user controlled, so we see the swing
    // animation.
    if (IsUserControlled())
    {
      SetMaxTime(0); 
    }
    else
    {
      SetMaxTime(GetEngine()->GetConfigFloat("golf_swing_time"));
      // Pull the camera back so we can see where the AI player is aiming.
      Camera* pCam = GetCamera().GetPtr();
      PoolCamera* pPoolCam = dynamic_cast<PoolCamera*>(pCam);
      if (pPoolCam)
      {
        pPoolCam->SetIsAiPlayer(true);
      }
      // If online player is taking shot we want the camera to be looking
      // at the player character, not behind her.
      if (IsOnlineGame())
      {
#ifdef _DEBUG
std::cout << "*** IS ONLINE, setting camera...\n";
#endif

        Orientation o = *(GetActivePlayer()->GetOrientation());
        Orientation o2 = *(GetBall()->GetOrientation());
        o2.SetYRot(o.GetYRot() + 180.0f); // look at from front
        GetBall()->SetOrientation(o2);
        GetCamera()->Reset();
      }
    }
#endif
    m_time = 0;
  }
  else
  {
    GetEngine()->SetLetterbox(false);
  }
}