void NFCShopModule::OnClienBuyItem(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { CLIENT_MSG_PROCESS(nSockIndex, nMsgID, msg, nLen, NFMsg::ReqAckBuyObjectFormShop); const std::string& strShopItemID = xMsg.config_id(); NFVector3 v; v.SetX(xMsg.x()); v.SetY(xMsg.y()); v.SetZ(xMsg.z()); ReqBuyItem(nPlayerID, strShopItemID, v); }
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); } }
void NFCPlayerLogic::RequireMove(NFVector3 pos) { NFMsg::ReqAckPlayerMove xMsg; *xMsg.mutable_mover() = NFINetModule::NFToPB(m_RoleGuid); xMsg.set_movetype(0); NFMsg::Vector3 *tPos = xMsg.add_target_pos(); tPos->set_x((float)pos.X()); tPos->set_y((float)pos.Y()); tPos->set_z((float)pos.Z()); xMsg.set_speed(1.0f); xMsg.set_time(1.0f); xMsg.set_laststate(0); xMsg.set_laststate(0); g_pNetLogic->SendToServerByPB(NFMsg::EGameMsgID::EGMI_REQ_MOVE, xMsg); }
int NFGamePVPModule::OnSceneEvent(const NFGUID & self, const int nSceneID, const int nGroupID, const int nType, const NFDataList & argList) { std::string strTileData; NFVector3 vRelivePos = m_pSceneModule->GetRelivePosition(nSceneID, 0); NFGUID xViewOpponent = m_pKernelModule->GetPropertyObject(self, NFrame::Player::OpponentID()); NFMsg::ReqAckSwapScene xAckSwapScene; xAckSwapScene.set_scene_id(nSceneID); xAckSwapScene.set_transfer_type(NFMsg::ReqAckSwapScene::EGameSwapType::ReqAckSwapScene_EGameSwapType_EGST_NARMAL); xAckSwapScene.set_line_id(0); xAckSwapScene.set_x(vRelivePos.X()); xAckSwapScene.set_y(vRelivePos.Y()); xAckSwapScene.set_z(vRelivePos.Z()); E_SCENE_TYPE eSceneType = (E_SCENE_TYPE)m_pElementModule->GetPropertyInt32(std::to_string(nSceneID), NFrame::Scene::Type()); if (eSceneType == E_SCENE_TYPE::SCENE_TYPE_SINGLE_CLONE_SCENE || eSceneType == E_SCENE_TYPE::SCENE_TYPE_MULTI_CLONE_SCENE) { //if (m_pPlayerRedisModule->LoadPlayerTileRandomCache(xViewOpponent, strTileData)) { xAckSwapScene.set_data(strTileData.c_str(), strTileData.length()); } } else { m_pKernelModule->SetPropertyObject(self, NFrame::Player::OpponentID(), NFGUID()); //if (m_pTileModule->GetOnlinePlayerTileData(self, strTileData)) { xAckSwapScene.set_data(strTileData.c_str(), strTileData.length()); } } //attach tile data m_pGameServerNet_ServerModule->SendMsgPBToGate(NFMsg::EGMI_ACK_SWAP_SCENE, xAckSwapScene, self); return 0; }
bool NFCCreateRoleModule::ConvertRecordToPB(const NF_SHARE_PTR<NFIRecord>& pRecord, NFMsg::ObjectRecordBase * pRecordData) { pRecordData->set_record_name(pRecord->GetName()); for (int iRow = 0; iRow < pRecord->GetRows(); iRow++) { if (!pRecord->IsUsed(iRow)) { continue; } NFMsg::RecordAddRowStruct* pRowData = pRecordData->add_row_struct(); if (!pRowData) { continue; } pRowData->set_row(iRow); for (int iCol = 0; iCol < pRecord->GetCols(); iCol++) { const int nType = pRecord->GetColType(iCol); switch (nType) { case TDATA_INT: { NFMsg::RecordInt* pPropertyData = pRowData->add_record_int_list(); const NFINT64 xPropertyValue = pRecord->GetInt(iRow, iCol); if (pPropertyData) { pPropertyData->set_col(iCol); pPropertyData->set_row(iRow); pPropertyData->set_data(xPropertyValue); } } break; case TDATA_FLOAT: { NFMsg::RecordFloat* pPropertyData = pRowData->add_record_float_list(); const double xPropertyValue = pRecord->GetFloat(iRow, iCol); if (pPropertyData) { pPropertyData->set_col(iCol); pPropertyData->set_row(iRow); pPropertyData->set_data(xPropertyValue); } } break; case TDATA_STRING: { NFMsg::RecordString* pPropertyData = pRowData->add_record_string_list(); const std::string& xPropertyValue = pRecord->GetString(iRow, iCol); if (pPropertyData) { pPropertyData->set_col(iCol); pPropertyData->set_row(iRow); pPropertyData->set_data(xPropertyValue); } } break; case TDATA_OBJECT: { NFMsg::RecordObject* pPropertyData = pRowData->add_record_object_list(); const NFGUID xPropertyValue = pRecord->GetObject(iRow, iCol); if (pPropertyData) { pPropertyData->set_col(iCol); pPropertyData->set_row(iRow); *pPropertyData->mutable_data() = NFINetModule::NFToPB(xPropertyValue); } } break; case TDATA_VECTOR2: { NFMsg::RecordVector2* pPropertyData = pRowData->add_record_vector2_list(); const NFVector2 xPropertyValue = pRecord->GetVector2(iRow, iCol); if (pPropertyData) { pPropertyData->set_col(iCol); pPropertyData->set_row(iRow); NFMsg::Vector2* pVec = pPropertyData->mutable_data(); pVec->set_x(xPropertyValue.X()); pVec->set_y(xPropertyValue.Y()); } } break; case TDATA_VECTOR3: { NFMsg::RecordVector3* pPropertyData = pRowData->add_record_vector3_list(); const NFVector3 xPropertyValue = pRecord->GetVector3(iRow, iCol); if (pPropertyData) { pPropertyData->set_col(iCol); pPropertyData->set_row(iRow); NFMsg::Vector3* pVec = pPropertyData->mutable_data(); pVec->set_x(xPropertyValue.X()); pVec->set_y(xPropertyValue.Y()); pVec->set_z(xPropertyValue.Z()); } } break; default: break; } } } return true; }
bool operator>(const NFVector3& v) const { return this->Length() > v.Length(); }
//---------------------------------------------------------------------------- float Distance(const NFVector3& v) const { NFVector3 vX = *this - v; return vX.Length(); }