本文整理汇总了C++中NFDataList::AddFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ NFDataList::AddFloat方法的具体用法?C++ NFDataList::AddFloat怎么用?C++ NFDataList::AddFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NFDataList
的用法示例。
在下文中一共展示了NFDataList::AddFloat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RandomPatrol
bool NFPatrolState::RandomPatrol(const NFGUID& self, NFIStateMachine* pStateMachine)
{
//首先,得看有没路径
//没有的话,随机找个地址走吧(以出生点为中心开始找,种子地址)NPCConfigID
const std::string& strConfigID = m_pKernelModule->GetPropertyString(self, "NPCConfigID");
const std::string& strNPCID = m_pKernelModule->GetPropertyString(self, "ConfigID");
if (!strConfigID.empty())
{
NF_SHARE_PTR<NFIPropertyManager> xPropertyManager = m_pElementModule->GetPropertyManager(strConfigID);
if (xPropertyManager)
{
NF_SHARE_PTR<NFIProperty> xPropertyX = xPropertyManager->GetElement("SeedX");
NF_SHARE_PTR<NFIProperty> xPropertyY = xPropertyManager->GetElement("SeedY");
NF_SHARE_PTR<NFIProperty> xPropertyZ = xPropertyManager->GetElement("SeedZ");
double fCurX = xPropertyX->GetFloat();
double fCurY = xPropertyY->GetFloat();
double fCurZ = xPropertyZ->GetFloat();
double fPosOffestX = (double)(rand() / double(RAND_MAX) - 0.5);
double fPosOffestZ = (double)(rand() / double(RAND_MAX) - 0.5);
fPosOffestX *= 10;
fPosOffestZ *= 10;
fCurX += fPosOffestX;
fCurZ += fPosOffestZ;
//if (fCurX > 0.0f && fCurZ > 0.0f)
{
//看能否寻路,不能寻路则重来
NFAI_STATE eStateType = NFAI_STATE::ChaseState;
double fRand = (double)(rand() / double(RAND_MAX));
if (fRand < 0.5f)
{
eStateType = NFAI_STATE::ChaseState;
}
NFDataList valueList;
valueList.AddFloat(fCurX);
valueList.AddFloat(fCurY);
valueList.AddFloat(fCurZ);
//m_pKernelModule->DoEvent(self, NFED_ON_CLIENT_REQUIRE_MOVE, valueList);
m_pKernelModule->SetPropertyFloat(self, "X", fCurX);
m_pKernelModule->SetPropertyFloat(self, "Y", fCurY);
m_pKernelModule->SetPropertyFloat(self, "Z", fCurZ);
return true;
}
}
}
return false;
}
示例2: OnObjectEntry
void NFCPlayerLogic::OnObjectEntry(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
NFGUID nPlayerID;
NFMsg::AckPlayerEntryList xMsg;
if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID))
{
return;
}
for(int i = 0; i < xMsg.object_list_size(); i++)
{
const NFMsg::PlayerEntryInfo info = xMsg.object_list(i);
NFDataList var;
var.Add("X");
var.AddFloat(info.x());
var.Add("Y");
var.AddFloat(info.y());
var.Add("Z");
var.AddFloat(info.z());
g_pKernelModule->CreateObject(NFINetModule::PBToNF(info.object_guid()), info.scene_id(), 0, info.class_id(), info.config_id(), var);
}
}
示例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);
}