From ff07f8148b7db35a6751ecefb3c2e1e94d764bc4 Mon Sep 17 00:00:00 2001 From: Chanbin Kim <127280695+JinhoBa@users.noreply.github.com> Date: Mon, 12 Jan 2026 16:03:01 +0900 Subject: [PATCH] =?UTF-8?q?[add]=20Npc=20=EB=B0=B0=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Client/Private/InfoInstance.cpp | 4 ++ .../Client/Private/Level_GamePlay.cpp | 7 +++- Jusin154_Team3D/Client/Private/MapInfo.cpp | 42 +++++++++++++++++++ Jusin154_Team3D/Client/Private/RandomNpc.cpp | 6 +-- Jusin154_Team3D/Client/Public/InfoInstance.h | 1 + Jusin154_Team3D/Client/Public/MapInfo.h | 1 + .../Resources/Data/Map/NPC/DummyNPC_Data.xml | 39 ++++++----------- 7 files changed, 69 insertions(+), 31 deletions(-) diff --git a/Jusin154_Team3D/Client/Private/InfoInstance.cpp b/Jusin154_Team3D/Client/Private/InfoInstance.cpp index bf5a90cfe..43f940805 100644 --- a/Jusin154_Team3D/Client/Private/InfoInstance.cpp +++ b/Jusin154_Team3D/Client/Private/InfoInstance.cpp @@ -176,6 +176,10 @@ HRESULT CInfoInstance::Load_DADA_INT() { return m_pMapInfo->Load_DADA_INT(); } +HRESULT CInfoInstance::Load_Npc() +{ + return m_pMapInfo->Load_Npc(); +} #pragma endregion #pragma region EFFECT_INFO diff --git a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp index c196eeaed..6995bfb62 100644 --- a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp +++ b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp @@ -1126,10 +1126,12 @@ HRESULT CLevel_GamePlay::Ready_Layer_Npc() { _bool isLoad_NPC = { true }; _bool isLoad_RandomNPC = { true }; + _bool isRandomPosition = { true }; #ifdef _DEBUG #ifdef gimch isLoad_NPC = true; isLoad_RandomNPC = true; + isRandomPosition = false; #endif // gimch #ifdef 진우 isLoad_RandomNPC = true; @@ -1170,8 +1172,9 @@ HRESULT CLevel_GamePlay::Ready_Layer_Npc() if (true == isLoad_RandomNPC) { - for (_uint i = 0; i < 11; i++) + if(isRandomPosition) { + for (_uint i = 0; i < 11; i++) { CRandomNpc::NPCDESC NPCDesc{}; _float X = m_pGameInstance->Real_Random_Float(22.f, 29.f); @@ -1184,6 +1187,8 @@ HRESULT CLevel_GamePlay::Ready_Layer_Npc() } } } + else + m_pInfoInstance->Load_Npc(); } return S_OK; } diff --git a/Jusin154_Team3D/Client/Private/MapInfo.cpp b/Jusin154_Team3D/Client/Private/MapInfo.cpp index 33f3553c6..1aca396d4 100644 --- a/Jusin154_Team3D/Client/Private/MapInfo.cpp +++ b/Jusin154_Team3D/Client/Private/MapInfo.cpp @@ -18,6 +18,7 @@ #include "InstancedProp_Light.h" #include "Layer.h" #include "EffectParts.h" +#include "RandomNpc.h" CMapInfo::CMapInfo() { @@ -853,6 +854,47 @@ HRESULT CMapInfo::Load_DADA_INT() return S_OK; } +HRESULT CMapInfo::Load_Npc() +{ + tinyxml2::XMLDocument xmlDoc; + + string strPath = "../Bin/Resources/Data/Map/NPC/DummyNPC_Data.xml"; + + if ((tinyxml2::XML_SUCCESS != xmlDoc.LoadFile(strPath.c_str()))) + return E_FAIL; + + tinyxml2::XMLElement* root = xmlDoc.FirstChildElement("NPC"); + + if (nullptr == root) + { + MSG_BOX("Failed to Find root"); + return S_OK; + } + + for (auto* Object = root->FirstChildElement("Object"); Object; Object = Object->NextSiblingElement("Object")) + { + CRandomNpc::NPCDESC NPCDesc{}; + Object->QueryIntAttribute("Index", &NPCDesc.iIndex); + /* Transform */ + auto* Position = Object->FirstChildElement("Position"); + Position->QueryFloatAttribute("x", &NPCDesc.vPos.x); + Position->QueryFloatAttribute("y", &NPCDesc.vPos.y); + Position->QueryFloatAttribute("z", &NPCDesc.vPos.z); + NPCDesc.vPos.w = 1.f; + + auto* Rotation = Object->FirstChildElement("Rotation"); + Rotation->QueryFloatAttribute("x", &NPCDesc.vRotQ.x); + Rotation->QueryFloatAttribute("y", &NPCDesc.vRotQ.y); + Rotation->QueryFloatAttribute("z", &NPCDesc.vRotQ.z); + NPCDesc.vRotQ.w = 1.f; + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_NPC, &NPCDesc))) { + return E_FAIL; + } + } + + return S_OK; +} + HRESULT CMapInfo::Initialize(ID3D11Device* pDevice, ID3D11DeviceContext* pContex) { m_pGameInstance = CGameInstance::GetInstance(); diff --git a/Jusin154_Team3D/Client/Private/RandomNpc.cpp b/Jusin154_Team3D/Client/Private/RandomNpc.cpp index 4f7fd24f7..9fa328dc2 100644 --- a/Jusin154_Team3D/Client/Private/RandomNpc.cpp +++ b/Jusin154_Team3D/Client/Private/RandomNpc.cpp @@ -40,9 +40,9 @@ HRESULT CRandomNpc::Initialize(void* pArg) _vector vPos = XMLoadFloat4(&pDesc->vPos); m_pTransformCom->Set_State(STATE::POSITION, vPos); m_pCharacter_Controller->Set_Position(vPos); - m_pTransformCom->Rotation(XMLoadFloat4(&pDesc->vRotQ)); + m_pTransformCom->Rotation(XMConvertToRadians(pDesc->vRotQ.x), XMConvertToRadians(pDesc->vRotQ.y), XMConvertToRadians(pDesc->vRotQ.z)); - m_pModelCom->Set_AnimationIndex(0, true); + m_pModelCom->Set_AnimationIndex(1, true); m_pCallBack_Behavior->Initialize(m_pCharacter_Controller); m_pCallBack_HitReport->Initialize(m_pCharacter_Controller); m_bNpc = true; @@ -320,7 +320,7 @@ HRESULT CRandomNpc::Ready_Components(void* pArg) Desc.fRotationPerSec = XMConvertToRadians(180.0f); Desc.fRadius = 10.f; - if (FAILED(Add_Component(g_iStaticLevel, &m_pTransformCom, pArg))) { + if (FAILED(Add_Component(g_iStaticLevel, &m_pTransformCom, &Desc))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Client/Public/InfoInstance.h b/Jusin154_Team3D/Client/Public/InfoInstance.h index b2d1680b4..df14842c6 100644 --- a/Jusin154_Team3D/Client/Public/InfoInstance.h +++ b/Jusin154_Team3D/Client/Public/InfoInstance.h @@ -64,6 +64,7 @@ DECLARE_SINGLETON(CInfoInstance) HRESULT Load_PointLights(const _char* pFileName, const _wchar* pLayerTag); HRESULT Load_EffectParts(const _char* pFileName, const _char* pEffectrFilePath); HRESULT Load_DADA_INT(); + HRESULT Load_Npc(); #pragma endregion #pragma region Spell_INFO HRESULT Load_SpellInfo(const _char* pFilePath); diff --git a/Jusin154_Team3D/Client/Public/MapInfo.h b/Jusin154_Team3D/Client/Public/MapInfo.h index 781163186..076549aa4 100644 --- a/Jusin154_Team3D/Client/Public/MapInfo.h +++ b/Jusin154_Team3D/Client/Public/MapInfo.h @@ -32,6 +32,7 @@ class CMapInfo final : public CBase HRESULT Load_EffectParts(const _char* pFileName, const _char* pEffectrFilePath); HRESULT Load_DADA_INT(); + HRESULT Load_Npc(); private: CGameInstance* m_pGameInstance = { nullptr }; diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/NPC/DummyNPC_Data.xml b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/NPC/DummyNPC_Data.xml index eb5b0d15b..38f556aa2 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/NPC/DummyNPC_Data.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/NPC/DummyNPC_Data.xml @@ -1,66 +1,51 @@ - - + + - - - - - - + - + - + - - - - - - + - + - + - - - - - - + - + - + - +