本文整理汇总了C++中PlayerObject::SetFire方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::SetFire方法的具体用法?C++ PlayerObject::SetFire怎么用?C++ PlayerObject::SetFire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::SetFire方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleNetworkMessage
void Game::HandleNetworkMessage( NetworkMessage* pMessage )
{
switch(pMessage->msgid)
{
case FPS::MSG_PLAYER_MOVE_UPDATE:
{
// Get a pointer to the game specific network message.
PlayerMoveUpdateMsg *msg = (PlayerMoveUpdateMsg *)pMessage;
// Get a pointer to the player in question.
PlayerObject *player = m_playerManager->GetPlayer( msg->PlayerID );
if(player == NULL)
break;
// If the player is disabled then chances are the local player has
// just joined the game, and is receiving messages about a player
// that it does not realise has already spawned. So just enable
// that player and start updating it.
if( player->GetEnabled() == false )
{
player->SetEnabled( true );
player->SetVisible( true );
}
// Update all the player's details.
player->SetTranslation( msg->translation.x, msg->translation.y, msg->translation.z );
player->SetDrive( msg->drive );
player->SetStrafe( msg->strafe );
player->SetFire( msg->fire );
}
break;
case FPS::MSG_PLAYER_LOOK_UPDATE:
{
// Get a pointer to the game specific network message.
PlayerLookUpdateMsg* msg = (PlayerLookUpdateMsg *)pMessage;;
// Update the player's rotation and view tilt.
if(m_playerManager->GetPlayer( msg->PlayerID ))
{
m_playerManager->GetPlayer( msg->PlayerID )->SetRotation( 0.0f, msg->rotationY, 0.0f );
m_playerManager->GetPlayer( msg->PlayerID )->SetViewTilt( msg->viewTilt );
}
}
break;
}
}
示例2: HandleNetworkMessage
//-----------------------------------------------------------------------------
// Handles the game specific network messages. Called by the network object.
//-----------------------------------------------------------------------------
void Game::HandleNetworkMessage( ReceivedMessage *msg )
{
// Process the received messaged based on its type.
switch( msg->msgid )
{
case MSGID_CREATE_PLAYER:
{
// Add the new player to the player manager and the scene.
PlayerObject *object = m_playerManager->AddPlayer( g_engine->GetNetwork()->GetPlayer( msg->dpnid ) );
g_engine->GetSceneManager()->AddObject( object );
// Check if the new player is the host player.
if( object->GetID() == g_engine->GetNetwork()->GetHostID() )
{
// Load the scene from the host player's selection.
g_engine->GetSceneManager()->LoadScene( ( (PlayerData*)g_engine->GetNetwork()->GetPlayer( msg->dpnid )->data )->map, "./Assets/Scenes/" );
// Allow the network to receive game specific messages.
g_engine->GetNetwork()->SetReceiveAllowed( true );
}
break;
}
case MSGID_DESTROY_PLAYER:
{
// Remove the player from the player manager and the scene.
SceneObject *object = m_playerManager->GetPlayer( msg->dpnid );
g_engine->GetSceneManager()->RemoveObject( &object );
m_playerManager->RemovePlayer( msg->dpnid );
break;
}
case MSGID_PLAYER_HEALTH:
{
// Get a pointer to the game specific network message.
PlayerHealthMsg *phm = (PlayerHealthMsg*)msg;
// Set the player's health.
m_playerManager->GetPlayer( phm->dpnid )->SetHealth( phm->health );
// Check if the player has been killed.
if( phm->health <= 0.0f )
m_playerManager->GetPlayer( phm->dpnid )->Kill();
break;
}
case MSGID_PLAYER_MOVE_UPDATE:
{
// Get a pointer to the game specific network message.
PlayerMoveUpdateMsg *pmum = (PlayerMoveUpdateMsg*)msg;
// Get a pointer to the player in question.
PlayerObject *player = m_playerManager->GetPlayer( pmum->dpnid );
// If the player is disabled then chances are the local player has
// just joined the game, and is receiving messages about a player
// that it does not realise has already spawned. So just enable
// that player and start updating it.
if( player->GetEnabled() == false )
{
player->SetEnabled( true );
player->SetVisible( true );
}
// Update all the player's details.
player->SetTranslation( pmum->translation.x, pmum->translation.y, pmum->translation.z );
player->SetDrive( pmum->drive );
player->SetStrafe( pmum->strafe );
player->SetFire( pmum->fire );
break;
}
case MSGID_PLAYER_LOOK_UPDATE:
{
// Get a pointer to the game specific network message.
PlayerLookUpdateMsg *plum = (PlayerLookUpdateMsg*)msg;
// Update the player's rotation and view tilt.
m_playerManager->GetPlayer( plum->dpnid )->SetRotation( 0.0f, plum->rotationY, 0.0f );
m_playerManager->GetPlayer( plum->dpnid )->SetViewTilt( plum->viewTilt );
break;
}
case MSGID_PLAYER_SCORE:
{
// Get a pointer to the game specific network message.
PlayerScoreMsg *psm = (PlayerScoreMsg*)msg;
// Update the player's score.
m_playerManager->GetPlayer( psm->dpnid )->SetFrags( psm->frags );
m_playerManager->GetPlayer( psm->dpnid )->SetDeaths( psm->deaths );
//.........这里部分代码省略.........