[Add] 다이얼로그 만듬

This commit is contained in:
qordlsgur
2025-12-28 10:57:49 +09:00
parent 0d020aebce
commit cc1a3f6680
27 changed files with 245 additions and 110 deletions
@@ -1892,13 +1892,13 @@ PS_OUT PS_SpellLearnBooster(PS_IN In)
float4 tex3 = g_Texture3.Sample(DefaultSampler, In.vTexcoord);
Color = lerp(Color, tex3, tex3.a);
}
}
else if (g_iBoosterOn == 0 && g_iBoosterOff != 0)
{
float4 tex2 = g_Texture2.Sample(DefaultSampler, In.vTexcoord);
tex2.rgb *= float3(1.f, 0.f, 0.f);
Color = tex;
Color = tex;
Color = lerp(Color, tex2, tex2.a);
}
@@ -2259,23 +2259,21 @@ PS_OUT PS_Interaction_Npc(PS_IN In)
float4 tex1 = g_Texture.Sample(ClampSampler, Finaluv);
Color = tex1;
if (g_iHover != 0)
{
float2 texpos1 = g_fImageSipos1.xy / g_fCurrent_Size;
float2 texsize1 = g_fImageSipos1.zw / g_fCurrent_Size;
float2 texlocal1 = (In.vTexcoord - texpos1) / texsize1;
bool inside1 = all(texlocal1 >= 0.0f && texlocal1 <= 1.0f);
if (inside1)
{
float2 startUV = g_fImageUV.xy;
float2 endUV = g_fImageUV.zw;
float2 atlasUV = atlasUV = startUV + texlocal1 * (endUV - startUV);
float4 tex2 = g_Texture1.Sample(DefaultSampler, atlasUV);
Color = lerp(Color, tex2, tex2.a);
}
float2 texpos1 = g_fImageSipos1.xy / g_fCurrent_Size;
float2 texsize1 = g_fImageSipos1.zw / g_fCurrent_Size;
float2 texlocal1 = (In.vTexcoord - texpos1) / texsize1;
bool inside1 = all(texlocal1 >= 0.0f && texlocal1 <= 1.0f);
if (inside1)
{
float2 startUV = g_fImageUV.xy;
float2 endUV = g_fImageUV.zw;
float2 atlasUV = atlasUV = startUV + texlocal1 * (endUV - startUV);
float4 tex2 = g_Texture1.Sample(DefaultSampler, atlasUV);
Color = lerp(Color, tex2, tex2.a);
}
Color.a *= Alpha;
@@ -167,6 +167,7 @@ call Update_Resources.bat
<ClInclude Include="..\Public\CallBack_NonPlayable_HitReport.h" />
<ClInclude Include="..\Public\CallBack_Ranrok_HitReport.h" />
<ClInclude Include="..\public\Dialogue.h" />
<ClInclude Include="..\public\Dialogue_Data.h" />
<ClInclude Include="..\public\Dialogue_Font.h" />
<ClInclude Include="..\public\NPCInteraction.h" />
<ClInclude Include="..\Public\State_Fall.h" />
@@ -404,6 +405,7 @@ call Update_Resources.bat
<ClCompile Include="..\Private\CallBack_NonPlayable_HitReport.cpp" />
<ClCompile Include="..\Private\CallBack_Ranrok_HitReport.cpp" />
<ClCompile Include="..\private\Dialogue.cpp" />
<ClCompile Include="..\private\Dialogue_Data.cpp" />
<ClCompile Include="..\private\Dialogue_Font.cpp" />
<ClCompile Include="..\private\NPCInteraction.cpp" />
<ClCompile Include="..\Private\State_Fall.cpp" />
@@ -731,6 +731,9 @@
<ClInclude Include="..\public\Dialogue.h">
<Filter>04.Mechanic\Dialogue</Filter>
</ClInclude>
<ClInclude Include="..\public\Dialogue_Data.h">
<Filter>04.Mechanic\Dialogue\Dialogue_Data</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="Client.ico">
@@ -1518,6 +1521,9 @@
<Filter Include="04.Mechanic\Dialogue">
<UniqueIdentifier>{11c35878-12b4-4c55-b872-004fed9a4fb2}</UniqueIdentifier>
</Filter>
<Filter Include="04.Mechanic\Dialogue\Dialogue_Data">
<UniqueIdentifier>{b03591a7-a14e-425a-8a3f-2a6a054c884a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Client.cpp">
@@ -2196,6 +2202,9 @@
<ClCompile Include="..\private\Dialogue.cpp">
<Filter>04.Mechanic\Dialogue</Filter>
</ClCompile>
<ClCompile Include="..\private\Dialogue_Data.cpp">
<Filter>04.Mechanic\Dialogue\Dialogue_Data</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Private\Goblin_States.cpp">
@@ -0,0 +1,102 @@
#include "pch.h"
#include "Dialogue_Data.h"
#include "GameObject.h"
#include "tinyxml2.h"
#include "InfoInstance.h"
CDialogue_Data::CDialogue_Data()
:m_pInfoInstance(CInfoInstance::GetInstance())
{
}
HRESULT CDialogue_Data::Initialize(ID3D11Device* pDevice, ID3D11DeviceContext* pContex)
{
Load_SpellInfo("../Bin/Resources/Data/UI/Dialogue/Dialogue.xml");
return S_OK;
}
void CDialogue_Data::Update(_float fTimeDelta)
{
}
HRESULT CDialogue_Data::Load_SpellInfo(const _char* pFilePath)
{
tinyxml2::XMLDocument doc;
if (doc.LoadFile(pFilePath) != tinyxml2::XML_SUCCESS)
return E_FAIL;
tinyxml2::XMLElement* pDialogueInfo = doc.FirstChildElement("DialogueInfo");
if (!pDialogueInfo) return E_FAIL;
tinyxml2::XMLElement* pDialogue = pDialogueInfo->FirstChildElement("Dialogue");
while (pDialogue)
{
NpcDialogue npc{};
pDialogue->QueryIntAttribute("NpcID", &npc.iNpcID);
tinyxml2::XMLElement* pLine = pDialogue->FirstChildElement("Line");
while (pLine)
{
DialogueInfo line{};
pLine->QueryIntAttribute("ID", &line.iLineID);
int type = 0;
pLine->QueryIntAttribute("Type", &type);
line.bType = (type == 1);
const char* text = pLine->Attribute("Text");
if (text) line.pText = CMyTools::ToWstring(text);
pLine->QueryIntAttribute("NextText", &line.NextTextID);
// 선택지 처리
tinyxml2::XMLElement* pChoice = pLine->FirstChildElement("Choice");
while (pChoice)
{
DialogueChoice choice{};
int choiceType = 0;
pChoice->QueryIntAttribute("Type", &choiceType);
choice.eType = choiceType;
const char* choiceText = pChoice->Attribute("Text");
if (choiceText) choice.pText = CMyTools::ToWstring(choiceText);
pChoice->QueryIntAttribute("NextText", &choice.NextTypeID);
line.ChoiceInfo.push_back(choice);
pChoice = pChoice->NextSiblingElement("Choice");
}
npc.Info.push_back(line);
pLine = pLine->NextSiblingElement("Line");
}
m_DialogueInfo.push_back(npc);
pDialogue = pDialogue->NextSiblingElement("Dialogue");
}
return S_OK;
}
const NPCDIALOGUEINFO& CDialogue_Data::Get_Info(_uint DialogueID) const
{
return m_DialogueInfo[DialogueID];
}
CDialogue_Data* CDialogue_Data::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
CDialogue_Data* pInstance = new CDialogue_Data();
if (FAILED(pInstance->Initialize(pDevice, pContext)))
{
MSG_BOX("Failed to Created : CDialogue_Data");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
void CDialogue_Data::Free()
{
__super::Free();
}
@@ -360,7 +360,7 @@ HRESULT CInfoInstance::Initialize_Information(ID3D11Device* pDevice, ID3D11Devic
if (FAILED(Stat_FileLoad("../Bin/Resources/Data/Stat/Stat.xml"))) {
return E_FAIL;
}
if (FAILED(Stat_FileLoad("../Bin/Resources/Data/Stat/NpcStat.xml"))) {
if (FAILED(NPC_FileLoad("../Bin/Resources/Data/Stat/NpcStat.xml"))) {
return E_FAIL;
}
#pragma endregion
@@ -101,9 +101,9 @@ HRESULT CLoding_Panel::Render()
if (FAILED(m_pVIBufferCom->Render())) {
return E_FAIL;
}
m_pGameInstance->Render_Text(TEXT("Font_size20"), TEXT("<- N M ->."), _float2(100.f, 750.f));
m_pGameInstance->Render_Text(TEXT("Font_size20"), TEXT("<- N M ->."), _float2(50.f, 850.f));
m_pGameInstance->Render_Text(TEXT("Font_size20"), ToolTip[m_iToolTip_Count].c_str(), _float2(100.f, 800.f));
m_pGameInstance->Render_Text(TEXT("Font_size20"), ToolTip[m_iToolTip_Count].c_str(), _float2(50.f, 900.f));
return S_OK;
}
@@ -82,11 +82,6 @@ void CNPCInteraction::NpcInfo(_wstring Name)
m_NpcName = Name;
}
void CNPCInteraction::Interaction(_bool bInteraction)
{
m_bInteraction = bInteraction;
}
void CNPCInteraction::Priority_Update(_float fTimeDelta)
{
@@ -169,15 +164,12 @@ HRESULT CNPCInteraction::Render()
m_NpcName.c_str(),
m_vFontPosition);
if (m_bInteraction == true)
{
m_pGameInstance->Perspective_Render_Text(
m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW),
m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ),
TEXT("Font_size15"),
TEXT("대화하기"),
m_vPosition);
}
m_pGameInstance->Perspective_Render_Text(
m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW),
m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ),
TEXT("Font_size15"),
TEXT("대화하기"),
m_vPosition);
return S_OK;
@@ -243,10 +235,6 @@ HRESULT CNPCInteraction::Bind_ShaderResources()
{
return E_FAIL;
}
if (FAILED(m_pShaderCom->Bind_RawValue("g_iHover", &m_bInteraction, sizeof(_bool))))
{
return E_FAIL;
}
return S_OK;
}
@@ -33,20 +33,6 @@ void CNPC_Ollivander::Update(_float fTimeDelta)
#ifdef _DEBUG
Describe_Entity();
#endif // _DEBUG
if (false == m_bHasInteracted)
{
if (true == InteractWithPlayer()) {
m_vEnteringTimer.x += fTimeDelta;
if (m_vEnteringTimer.x > m_vEnteringTimer.y) {
m_vEnteringTimer.x -= m_vEnteringTimer.y;
m_bHasInteracted = true;
// Active();
}
}
}
if (false == m_bEntered)
{
if (true == CastToPlayer()) {
@@ -54,7 +40,6 @@ void CNPC_Ollivander::Update(_float fTimeDelta)
if (m_vEnteringTimer.x > m_vEnteringTimer.y) {
m_vEnteringTimer.x -= m_vEnteringTimer.y;
m_bEntered = true;
m_bHasInteracted = false;
// Active();
}
#ifdef _DEBUG
@@ -73,7 +58,6 @@ void CNPC_Ollivander::Update(_float fTimeDelta)
if (m_vEnteringTimer.x > m_vEnteringTimer.y) {
m_vEnteringTimer.x -= m_vEnteringTimer.y;
m_bEntered = false;
m_bHasInteracted = false;
// DeActive(), Ready To Enter;
}
#ifdef _DEBUG
@@ -116,9 +100,8 @@ void CNPC_Ollivander::Update(_float fTimeDelta)
}
m_pNPCInteraction->Set_Visible(m_bEntered);
m_pNPCInteraction->Interaction(m_bHasInteracted);
if (m_bHasInteracted == true)
if (m_bEntered == true)
{
if (m_pGameInstance->Key_Down(DIK_F))
{
@@ -253,19 +236,6 @@ _bool CNPC_Ollivander::CastToPlayer()
return false;
}
_bool CNPC_Ollivander::InteractWithPlayer()
{
_vector vCurrentPos = m_pTransformCom->Get_State(STATE::POSITION);
_vector vTargetPos = {};
pair<CUnit*, CTransform*> pairAllyInfo = m_pInfoInstance->Get_NearestPlayerAlly(m_pTransformCom->Get_State(STATE::POSITION));
vTargetPos = pairAllyInfo.second->Get_State(STATE::POSITION);
_float fLength = XMVectorGetX(XMVector4Length(vTargetPos - vCurrentPos));
if (fLength < m_fInteractionDistance) {
return true;
}
return false;
}
HRESULT CNPC_Ollivander::Initialize_Prototype()
{
return S_OK;
@@ -337,7 +307,7 @@ HRESULT CNPC_Ollivander::Ready_Components(void* pArg)
m_pCharacter_Controller->SetGravity(true);
}
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("OLLIVENDER"), (CComponent**)&m_pStat))) {
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("OLLIVENDER"), (CComponent**)&m_pNpcStat))) {
return E_FAIL;
}
@@ -345,7 +315,7 @@ HRESULT CNPC_Ollivander::Ready_Components(void* pArg)
return E_FAIL;
}
m_pNPCInteraction->NpcInfo(m_pStat->Get_Stat().pNpc_Name);
m_pNPCInteraction->NpcInfo(m_pNpcStat->Get_Stat().pNpc_Name);
return S_OK;
}
@@ -379,7 +349,7 @@ void CNPC_Ollivander::Free()
__super::Free();
SAFE_RELEASE(m_pCharacter_Controller);
SAFE_RELEASE(m_pStat);
SAFE_RELEASE(m_pNpcStat);
if (nullptr != m_pInfoInstance) {
CInfoInstance* pInfo = m_pInfoInstance;
m_pInfoInstance = nullptr;
@@ -2621,7 +2621,7 @@ void CPlayer::Add_SpellEvent(_uint AnimIndex,_float fRatio)
Add_Event(AnimIndex,
[this]() {m_pEffectPool->Use_Skill(SKILL_TYPE::TRANSFORMATION_SIDE, Get_PartObject<CWand>()); },
0.f);
Info.pText = TEXT("봄바르다");
Info.pText = TEXT("베라베르토!");
m_pInfoInstance->Event_CallBack(TEXT("Dialogue"), &Info);
break;
@@ -37,6 +37,28 @@ namespace Client
_float fVidio{};
}SPELL_INFO;
typedef struct DialogueChoice
{
_int eType = {false};
_wstring pText;
_int NextTypeID{};
}DIALOGUECHOICEINFO;
typedef struct DialogueInfo
{
_int iLineID{};
_bool bType = {false};
_wstring pText;
_int NextTextID{};
vector<DIALOGUECHOICEINFO> ChoiceInfo;
}CURRENTDIALOGUEINFO;
typedef struct NpcDialogue
{
_int iNpcID{};
vector<CURRENTDIALOGUEINFO> Info;
}NPCDIALOGUEINFO;
typedef struct tagLockOnInfo {
CUnit* pUnit = { nullptr };
class CMapElement_Interactable* pInteractive = { nullptr };
@@ -0,0 +1,45 @@
#pragma once
#include "Client_Define.h"
#include "Base.h"
NS_BEGIN(Engine)
class CGameInstance;
class CUIObject;
NS_END
NS_BEGIN(Client)
class CDialogue_Data final : public CBase
{
public:
private:
CDialogue_Data();
~CDialogue_Data() = default;
public:
void Update(_float fTimeDelta);
public:
HRESULT Load_SpellInfo(const _char* pFilePath);
public:
const NPCDIALOGUEINFO& Get_Info(_uint DialogueID) const;
private:
CInfoInstance* m_pInfoInstance = { nullptr };
_int m_iDialogue_Count{};
vector<NPCDIALOGUEINFO> m_DialogueInfo;
private:
HRESULT Initialize(ID3D11Device* pDevice, ID3D11DeviceContext* pContex);
public:
static CDialogue_Data* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual void Free() override;
};
NS_END
@@ -32,7 +32,6 @@ class CNPCInteraction final : public CGameObject
public:
void NpcInfo(_wstring Name);
void Interaction(_bool bInteraction);
private:
CTexture* m_pDiffuse_TextureCom = { nullptr };
@@ -41,8 +40,6 @@ class CNPCInteraction final : public CGameObject
CShader* m_pShaderCom = { nullptr };
CVIBuffer_Rect* m_pVIBufferCom = { nullptr };
_bool m_bInteraction = {false};
_vector m_vFontPosition{};
_vector m_vFontPosition1{};
@@ -32,21 +32,18 @@ class CNPC_Ollivander final : public CUnit
CUnit* m_pPlayerAllyUnit = { nullptr };
CNPC_Ollivander* m_pNPC_Ollivander = { nullptr };
class CNPCInteraction* m_pNPCInteraction = { nullptr };
class CNPCInteraction* m_pNPCInteraction = { nullptr };
CNPCStat* m_pStat = { nullptr };
_bool m_bEntered = { false };
_bool m_bHasInteracted = { false };
_float2 m_vEnteringTimer = { 0.f, 1.f };
_float m_fEncounterDistance = { 10.f };
_float m_fInteractionDistance = { 3.f };
CNPCStat* m_pNpcStat = { nullptr };
_bool m_bEntered = { false };
_float2 m_vEnteringTimer = { 0.f, 1.f };
_float m_fEncounterDistance = { 3.f };
protected:
virtual HRESULT Initialize_Prototype() override;
virtual HRESULT Initialize(void* pArg) override;
HRESULT Ready_Components(void* pArg);
HRESULT Bind_ShaderResources() override;
_bool CastToPlayer();
_bool InteractWithPlayer();
public:
static CNPC_Ollivander* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
@@ -1,6 +1,11 @@
<Dialogue>
<Npc NpcName="Ollivander" NpcID="0" >
<Text ID="0" Size="0" NpcName="올리벤더:" Text="반갑네 친구 나는 올리벤더 라고 하네"></Text>
<Text ID="1" Size="0" NpcName="올리벤더:" Text="나는 여기서 지팡이를 팔고있어"></Text>
</Npc>
</Dialogue>
<DialogueInfo>
<Dialogue NpcID="0">
<Line ID="0000" Type="0" Text="반갑네 친구 나는 올리벤더 라고 하네" NextText="0001"> </Line>
<Line ID="0001" Type="0" Text="나는 여기서 지팡이를 팔고있어" NextText="0002"> </Line>
<Line ID="0002" Type="1" Text="뭐 필요한게 있나?" >
<Choice Type="1" Text="상점 이용하기" NextText="-1" />
<Choice Type="2" Text="퀘스트 확인하기" NextText="-1" />
<Choice Type="0" Text="다른일 하러가기" NextText="-1" />
</Line>
</Dialogue>
</DialogueInfo>
@@ -1,4 +1,4 @@
<StatInfo>
<OLLIVENDER Name="올리벤더" TAG="1" SizeX="256"/>
<OLLIVENDER ID="0" Name="올리벤더" TAG="1" SizeX="256"/>
</StatInfo>
@@ -1892,13 +1892,13 @@ PS_OUT PS_SpellLearnBooster(PS_IN In)
float4 tex3 = g_Texture3.Sample(DefaultSampler, In.vTexcoord);
Color = lerp(Color, tex3, tex3.a);
}
}
else if (g_iBoosterOn == 0 && g_iBoosterOff != 0)
{
float4 tex2 = g_Texture2.Sample(DefaultSampler, In.vTexcoord);
tex2.rgb *= float3(1.f, 0.f, 0.f);
Color = tex;
Color = tex;
Color = lerp(Color, tex2, tex2.a);
}
@@ -2259,23 +2259,21 @@ PS_OUT PS_Interaction_Npc(PS_IN In)
float4 tex1 = g_Texture.Sample(ClampSampler, Finaluv);
Color = tex1;
if (g_iHover != 0)
{
float2 texpos1 = g_fImageSipos1.xy / g_fCurrent_Size;
float2 texsize1 = g_fImageSipos1.zw / g_fCurrent_Size;
float2 texlocal1 = (In.vTexcoord - texpos1) / texsize1;
bool inside1 = all(texlocal1 >= 0.0f && texlocal1 <= 1.0f);
if (inside1)
{
float2 startUV = g_fImageUV.xy;
float2 endUV = g_fImageUV.zw;
float2 atlasUV = atlasUV = startUV + texlocal1 * (endUV - startUV);
float4 tex2 = g_Texture1.Sample(DefaultSampler, atlasUV);
Color = lerp(Color, tex2, tex2.a);
}
float2 texpos1 = g_fImageSipos1.xy / g_fCurrent_Size;
float2 texsize1 = g_fImageSipos1.zw / g_fCurrent_Size;
float2 texlocal1 = (In.vTexcoord - texpos1) / texsize1;
bool inside1 = all(texlocal1 >= 0.0f && texlocal1 <= 1.0f);
if (inside1)
{
float2 startUV = g_fImageUV.xy;
float2 endUV = g_fImageUV.zw;
float2 atlasUV = atlasUV = startUV + texlocal1 * (endUV - startUV);
float4 tex2 = g_Texture1.Sample(DefaultSampler, atlasUV);
Color = lerp(Color, tex2, tex2.a);
}
Color.a *= Alpha;
Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

+3 -2
View File
@@ -16,9 +16,10 @@ CNPCStat::CNPCStat(const CNPCStat& rhs)
HRESULT CNPCStat::Initialize_Prototype(tinyxml2::XMLNode* pChild)
{
auto pElement = pChild->ToElement();
pElement->QueryIntAttribute("ID", &m_NpcInfo.iID);
m_NpcInfo.pNpc_Name = CMyTools::ToWstring(pElement->Attribute("Name"));
pElement->QueryIntAttribute("OBJECTID", &m_NpcInfo.iNpcType);
pElement->QueryFloatAttribute("HP", &m_NpcInfo.fFontPos);
pElement->QueryIntAttribute("TAG", &m_NpcInfo.iNpcType);
pElement->QueryFloatAttribute("SizeX", &m_NpcInfo.fFontPos);
return S_OK;
}
+1
View File
@@ -8,6 +8,7 @@ class ENGINE_DLL CNPCStat final : public CComponent
{
typedef struct tagNpcInfo
{
_int iID{};
_wstring pNpc_Name;
_int iNpcType{};
_float fFontPos{};