本文整理汇总了C++中NFDataList::AddObject方法的典型用法代码示例。如果您正苦于以下问题:C++ NFDataList::AddObject方法的具体用法?C++ NFDataList::AddObject怎么用?C++ NFDataList::AddObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NFDataList
的用法示例。
在下文中一共展示了NFDataList::AddObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnAckSearchOpponentProcess
void NFCGamePVPModule::OnAckSearchOpponentProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen)
{
CLIENT_MSG_PROCESS(nMsgID, msg, nLen, NFMsg::AckSearchOppnent);
if (!m_pKernelModule->ExistObject(nPlayerID))
{
return;
}
m_pKernelModule->SetPropertyObject(nPlayerID, NFrame::Player::OpponentFighting(), NFGUID());
m_pKernelModule->SetPropertyInt(nPlayerID, NFrame::Player::FightingStar(), 0);
m_pKernelModule->SetPropertyInt(nPlayerID, NFrame::Player::PVPType(), NFMsg::EPVPType::PVP_INDIVIDUAL);
m_pSceneProcessModule->RequestEnterScene(nPlayerID, xMsg.scene_id(), 0, NFDataList());
int nNoWSceneID = m_pKernelModule->GetPropertyInt(nPlayerID, NFrame::Player::SceneID());
int nGroupID = m_pKernelModule->GetPropertyInt(nPlayerID, NFrame::Player::GroupID());
if (nNoWSceneID != xMsg.scene_id())
{
return;
}
//process opponent data
ProcessOpponentData(nPlayerID, xMsg);
m_pGameServerNet_ServerModule->SendMsgToGate(NFMsg::EGMI_ACK_SEARCH_OPPNENT, std::string(msg, nLen), nPlayerID);
for (int i = 0; i < xMsg.title().building_size(); ++i)
{
const NFMsg::TileBuilding& xTileBuilding = xMsg.title().building().Get(i);
NFGUID xBuildingID = NFINetModule::PBToNF(xTileBuilding.guid());
NFVector3 vPos;
vPos.SetX(xTileBuilding.x());
vPos.SetY(xTileBuilding.y());
std::string strCnfID = xTileBuilding.configid();
NFDataList xDataArg;
xDataArg.AddString(NFrame::NPC::Position());
xDataArg.AddVector3(vPos);
xDataArg.AddString(NFrame::NPC::MasterID());
xDataArg.AddObject(NFINetModule::PBToNF(xMsg.opponent()));
xDataArg.AddString(NFrame::NPC::AIOwnerID());
xDataArg.AddObject(nPlayerID);
xDataArg.AddString(NFrame::NPC::NPCType());
xDataArg.AddInt(NFMsg::ENPCType::ENPCTYPE_TURRET);
m_pKernelModule->CreateObject(xBuildingID, nNoWSceneID, nGroupID, NFrame::NPC::ThisName(), strCnfID, xDataArg);
}
}
示例2: OnChatProcess
//--------------------------------------------收消息-------------------------------------------------------------
void NFCChatLogic::OnChatProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
NFGUID nPlayerID;
NFMsg::ReqAckPlayerChat xMsg;
if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID))
{
return;
}
NFDataList var;
var.AddObject(NFINetModule::PBToNF(xMsg.chat_id()));
var.AddInt(xMsg.chat_type());
var.AddString(xMsg.chat_name());
var.AddString(xMsg.chat_info());
var.AddInt(xMsg.container_data_size());
for (size_t i = 0; i < xMsg.container_data_size(); i++)
{
var.AddInt(xMsg.container_data(i).containertype());
var.AddString(xMsg.container_data(i).data_info());
}
switch (xMsg.chat_type())
{
case NFMsg::ReqAckPlayerChat_EGameChatType::ReqAckPlayerChat_EGameChatType_EGCT_WORLD:
{
DoEvent(E_ChatEvent_ChatWorld, var);
}
break;
case NFMsg::ReqAckPlayerChat_EGameChatType::ReqAckPlayerChat_EGameChatType_EGCT_GUILD:
{
DoEvent(E_ChatEvent_ChatGuild, var);
}
break;
case NFMsg::ReqAckPlayerChat_EGameChatType::ReqAckPlayerChat_EGameChatType_EGCT_PRIVATE:
{
DoEvent(E_ChatEvent_ChatPrivate, var);
}
break;
case NFMsg::ReqAckPlayerChat_EGameChatType::ReqAckPlayerChat_EGameChatType_EGCT_TEAM:
{
DoEvent(E_ChatEvent_ChatTeam, var);
}
break;
default:
break;;
}
}
示例3: OnObjectMove
// 移动
void NFCPlayerLogic::OnObjectMove(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
NFGUID nPlayerID;
NFMsg::ReqAckPlayerMove xMsg;
if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID))
{
return;
}
float fMove = g_pKernelModule->GetPropertyInt(NFINetModule::PBToNF(xMsg.mover()), "MOVE_SPEED")/10000.0f;
NFDataList var;
var.AddObject(NFINetModule::PBToNF(xMsg.mover()));
var.AddFloat(fMove);
const NFMsg::Vector3 &pos = xMsg.target_pos(0);
var.AddVector3(NFVector3(pos.x(), pos.y(), pos.z()));
DoEvent(E_PlayerEvent_PlayerMove, var);
}
示例4: OnClienEnterGameProcess
void NFCCreateRoleModule::OnClienEnterGameProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen)
{
NFGUID nClientID;
NFMsg::ReqEnterGameServer xMsg;
if (!m_pNetModule->ReceivePB( nMsgID, msg, nLen, xMsg, nClientID))
{
return;
}
NFGUID nRoleID = NFINetModule::PBToNF(xMsg.id());
if (m_pKernelModule->GetObject(nRoleID))
{
//it should be rebind with proxy's netobject
m_pKernelModule->DestroyObject(nRoleID);
}
//////////////////////////////////////////////////////////////////////////
NF_SHARE_PTR<NFIGameServerNet_ServerModule::GateBaseInfo> pGateInfo = m_pGameServerNet_ServerModule->GetPlayerGateInfo(nRoleID);
if (nullptr != pGateInfo)
{
m_pGameServerNet_ServerModule->RemovePlayerGateInfo(nRoleID);
}
NF_SHARE_PTR<NFIGameServerNet_ServerModule::GateServerInfo> pGateServerinfo = m_pGameServerNet_ServerModule->GetGateServerInfoBySockIndex(nSockIndex);
if (nullptr == pGateServerinfo)
{
return;
}
int nGateID = -1;
if (pGateServerinfo->xServerData.pData)
{
nGateID = pGateServerinfo->xServerData.pData->server_id();
}
if (nGateID < 0)
{
return;
}
if (!m_pGameServerNet_ServerModule->AddPlayerGateInfo(nRoleID, nClientID, nGateID))
{
return;
}
if (m_pPlayerRedisModule->LoadPlayerData(nRoleID))
{
int nHomeSceneID = m_pPlayerRedisModule->GetPlayerHomeSceneID(nRoleID);
if (nHomeSceneID <= 0)
{
nHomeSceneID = m_pPVPModule->RandomTileScene();
}
NFDataList var;
var.AddString(NFrame::Player::Name());
var.AddString(xMsg.name());
var.AddString(NFrame::Player::GateID());
var.AddInt(nGateID);
var.AddString(NFrame::Player::GameID());
var.AddInt(pPluginManager->GetAppID());
var.AddString(NFrame::Player::HomeSceneID());
var.AddInt(nHomeSceneID);
var.AddString(NFrame::Player::SceneID());
var.AddInt(nHomeSceneID);
var.AddString(NFrame::Player::ViewOppnent());
var.AddObject(nRoleID);
NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->CreateObject(nRoleID, nHomeSceneID, 0, NFrame::Player::ThisName(), "", var);
if (nullptr == pObject)
{
//mRoleBaseData
//mRoleFDData
return;
}
//get data first then create player
m_pSceneProcessModule->RequestEnterScene(pObject->Self(), nHomeSceneID, -1, 0, NFDataList());
}
}
示例5: UseItem
bool NFCItemModule::UseItem(const NFGUID & self, const std::string & strItemID, const NFGUID & xTargetID)
{
int nCount = 1;
if (!m_pElementModule->ExistElement(strItemID) || !m_pKernelModule->GetObject(xTargetID))
{
return false;
}
if (!ConsumeDataItemProperty(self, strItemID))
{
return false;
}
if (!m_pPackModule->DeleteItem(self, strItemID, nCount))
{
return false;
}
NFMsg::EItemType eItemType = (NFMsg::EItemType)m_pElementModule->GetPropertyInt(strItemID, NFrame::Item::ItemType());
NF_SHARE_PTR<NFIItemConsumeProcessModule> pConsumeProcessModule = m_pItemConsumeManagerModule->GetConsumeModule(eItemType);
if (!pConsumeProcessModule)
{
return false;
}
switch (eItemType)
{
case NFMsg::EItemType::EIT_CARD:
case NFMsg::EItemType::EIT_EQUIP:
case NFMsg::EItemType::EIT_GEM:
case NFMsg::EItemType::EIT_TOKEN:
{
if (pConsumeProcessModule->ConsumeLegal(self, strItemID, NFDataList()) == 0)
{
pConsumeProcessModule->ConsumeProcess(self, strItemID, NFDataList());
}
}
break;
case NFMsg::EItemType::EIT_ITEM:
{
NFDataList xTarget;
xTarget.AddObject(xTargetID);
xTarget.AddString(strItemID); //this is Item Config ID
xTarget.AddInt(nCount); //this is Item Count to Consume
if (pConsumeProcessModule->ConsumeLegal(self, strItemID, xTarget) == 0)
{
pConsumeProcessModule->ConsumeProcess(self, strItemID, xTarget);
}
}
break;
break;
default:
break;
}
/* AddItemEffectDataProperty(self, xTargetID, strItemID);
const std::string& strAwardPackID = m_pElementModule->GetPropertyString(strItemID, "AwardData");
if (!strAwardPackID.empty())
{
DoAwardPack( self, strAwardPackID);
}
*/
return false;
}