本文整理汇总了C++中CObjectManager::NewPlayerNPC方法的典型用法代码示例。如果您正苦于以下问题:C++ CObjectManager::NewPlayerNPC方法的具体用法?C++ CObjectManager::NewPlayerNPC怎么用?C++ CObjectManager::NewPlayerNPC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CObjectManager
的用法示例。
在下文中一共展示了CObjectManager::NewPlayerNPC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
uint GCNewPet_MoveHandler::Execute( GCNewPet_Move* pPacket, Player* pPlayer )
{
//当前流程是主流程
if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
{
CObjectManager* pObjectManager = CObjectManager::GetMe();
//检查位置是否合法
if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ)))
{
TDThrow("ERROR POSITION @ GCNewMonster_MoveHandler");
}
if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getTargetPos().m_fX, pPacket->getTargetPos().m_fZ)))
{
TDThrow("ERROR POSITION @ GCNewMonster_MoveHandler target");
}
//创建玩家
CObject_PlayerNPC* pNPC = (CObject_PlayerNPC*)pObjectManager->FindServerObject( (INT)pPacket->getObjID() );
fVector3 fvGame;
CGameProcedure::s_pGfxSystem->Axis_Trans(
CRenderSystem::AX_PLAN, fVector3(pPacket->getWorldPos().m_fX, 0.0f, pPacket->getWorldPos().m_fZ),
CRenderSystem::AX_GAME, fvGame);
if ( pNPC == NULL )
{
pNPC = pObjectManager->NewPlayerNPC( (INT)pPacket->getObjID() );
SObjectInit initPlayerNPC;
initPlayerNPC.m_fvPos = fvGame;
initPlayerNPC.m_fvRot = fVector3( 0.f, 0.f, 0.f );
pNPC->Initial( &initPlayerNPC );
}
else
{
fVector2 mapPos(fvGame.x, fvGame.z);
pNPC->SetMapPosition(mapPos);
pNPC->Enable( OSF_VISIABLE );
pNPC->Disalbe( OSF_OUT_VISUAL_FIELD );
}
pNPC->SetNpcType(NPC_TYPE_PET);
pNPC->GetCharacterData()->Set_MoveSpeed(pPacket->getMoveSpeed());
// move to command
{
WORLD_POS posTarget;
posTarget.m_fX = pPacket->getTargetPos().m_fX;
posTarget.m_fZ = pPacket->getTargetPos().m_fZ;
SCommand_Object cmdTemp;
cmdTemp.m_wID = OC_MOVE;
cmdTemp.m_auParam[0] = 0;
cmdTemp.m_anParam[1] = pPacket->getHandleID();
cmdTemp.m_anParam[2] = 1;
cmdTemp.m_apParam[3] = &posTarget;
pNPC->PushCommand(&cmdTemp );
}
//放入Ask队列
CObjectManager::GetMe()->GetLoadQueue()->TryAddLoadTask(pNPC->GetID(), CObject_Character::CT_MONSTER);
// tempcode{
// 此版不做服务器繁忙客户端延后发消息的处理
// CGCharAskBaseAttrib msgAskBaseAttrib;
// msgAskBaseAttrib.setTargetID( (INT)pPacket->getObjID() );
// CNetManager::GetMe()->SendPacket( &msgAskBaseAttrib );
// }
//同步渲染层
char szTemp[MAX_PATH];
_snprintf(szTemp, MAX_PATH, "GCNewPet_Move(%.1f,%.1f)",
pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ);
pNPC->PushDebugString(szTemp);
pNPC->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
}
return PACKET_EXE_CONTINUE ;
}
示例2: mapPos
uint GCNewMonsterHandler :: Execute( GCNewMonster* pPacket, Player* pPlayer )
{
//__ENTER_FUNCTION
// 当前流程是主流程
if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
{
CObjectManager* pObjectManager = CObjectManager::GetMe();
// 检查位置是否合法
if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ)))
{
KLThrow("ERROR POSITION @ GCNewMonsterHandler");
}
// 创建Npc
CObject_PlayerNPC* pNPC = (CObject_PlayerNPC*)pObjectManager->FindServerObject( (INT)pPacket->getObjID() );
fVector3 fvGame;
CGameProcedure::s_pGfxSystem->Axis_Trans
( tGfxSystem::AX_PLAN, fVector3(pPacket->getWorldPos().m_fX, 0.0f, pPacket->getWorldPos().m_fZ), tGfxSystem::AX_GAME, fvGame );
// 设置位置和方向
// 朝向
FLOAT fFaceDir = pPacket->getDir();
// 不存在, 创建新的
if( pNPC == NULL )
{
pNPC = pObjectManager->NewPlayerNPC( (INT)pPacket->getObjID() );
SObjectInit initPlayerNPC;
initPlayerNPC.m_fvPos = fvGame;
initPlayerNPC.m_fvRot = fVector3( 0.f, fFaceDir, 0.f );
pNPC->Initial( &initPlayerNPC );
// 20100514 AddCodeBegin 将该行放到此处,如果NPC是新进场景的,才请求详细属性
// 放入Ask队列
CObjectManager::GetMe()->GetLoadQueue()->TryAddLoadTask( pNPC->GetID() );
// 20100514 AddCodeEnd
}
else
{
fVector2 mapPos(fvGame.x, fvGame.z);
pNPC->SetMapPosition(mapPos);
pNPC->SetFaceDir( fFaceDir );
pNPC->Enable( OSF_VISIABLE );
pNPC->Disalbe( OSF_OUT_VISUAL_FIELD );
}
// 标识为怪
pNPC->SetNpcType( NPC_TYPE_MONSTER );
// 设置移动速度
pNPC->GetCharacterData()->Set_MoveSpeed( pPacket->getMoveSpeed() );
// 设置坐骑
pNPC->GetCharacterData()->Set_MountID( pPacket->getHorseID() );
// 设置武器装备
pNPC->GetCharacterData()->Set_MonstWeapon( pPacket->getWeaponID() );
SCommand_Object cmdTemp;
cmdTemp.m_wID = OC_IDLE;
cmdTemp.m_afParam[0] = fvGame.x;
cmdTemp.m_afParam[1] = fvGame.z;
cmdTemp.m_abParam[2] = FALSE;
pNPC->PushCommand( &cmdTemp );
// 20100514 DeleteCodeBegin
// 放入Ask队列
//CObjectManager::GetMe()->GetLoadQueue()->TryAddLoadTask( pNPC->GetID() );
// 20100514 DeleteCodeEnd
// 同步渲染层
char szTemp[MAX_PATH];
_snprintf(szTemp, MAX_PATH, "GCNewMonster(%.1f,%.1f)", pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ);
pNPC->PushDebugString(szTemp);
pNPC->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
// 20100415 AddCodeBegin
// 自动寻路的NPC数据到达后向服务器发请求打开NPC对话框
if ( CObjectManager::GetMe()->GetMySelf()->GetIsAutoNPCPath()->m_isAutoPath == TRUE &&
CObjectManager::GetMe()->GetMySelf()->GetIsAutoNPCPath()->m_strAutoNPCName == pNPC->GetCharacterData()->Get_Name() &&
CGameProcedure::s_pWorldManager->GetActiveSceneID() == CObjectManager::GetMe()->GetMySelf()->GetIsAutoNPCPath()->m_nSceneID )
{
CObject_Character* pCharObj = NULL;
STRING strName = CObjectManager::GetMe()->GetMySelf()->GetIsAutoNPCPath()->m_strAutoNPCName;
pCharObj = CObjectManager::GetMe()->FindCharacterByName( strName );
if ( pCharObj != NULL )
{
int i = pCharObj->GetServerID();
CGameProcedure::s_pGameInterface->Player_Speak( i );
//.........这里部分代码省略.........