diff --git a/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl b/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl index 5495075f9..60c0ef454 100644 --- a/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl +++ b/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl @@ -2426,6 +2426,100 @@ PS_OUT PS_BoosterHpBar(PS_IN In) return Out; } +PS_OUT PS_DialogueChoice(PS_IN In) +{ + PS_OUT Out = (PS_OUT) 0; + float Alpha = g_fAlpha * g_fOwnerAlpha * g_fCanvasAlpha; + float4 Color = float4(1.f, 1.f, 1.f, 0.f); + float2 uv = In.vTexcoord; + float2 CurrentPixelPosition = uv * g_fCurrent_Size; + float OriginLeft = g_fNine_Slice.x; + float OriginRight = g_fNine_Slice.y; + float OriginTop = g_fNine_Slice.z; + float OriginBottom = g_fNine_Slice.w; + + float CurrentLeft = OriginLeft; + float CurrentRight = g_fCurrent_Size.x - (g_fOrigin_Size.x - OriginRight); + float CurrentTop = OriginTop; + float CurrentBottom = g_fCurrent_Size.y - (g_fOrigin_Size.y - OriginBottom); + + float2 Finaluv = In.vTexcoord; + + if (CurrentPixelPosition.x < CurrentLeft) + { + Finaluv.x = CurrentPixelPosition.x / g_fOrigin_Size.x; + } + else if (CurrentPixelPosition.x > CurrentRight) + { + float dist = CurrentPixelPosition.x - CurrentRight; + Finaluv.x = (OriginRight + dist) / g_fOrigin_Size.x; + } + else + { + float scale = (CurrentPixelPosition.x - CurrentLeft) / (CurrentRight - CurrentLeft); + Finaluv.x = (OriginLeft / g_fOrigin_Size.x) + scale * ((OriginRight - OriginLeft) / g_fOrigin_Size.x); + } + + if (CurrentPixelPosition.y < CurrentTop) + { + Finaluv.y = CurrentPixelPosition.y / g_fOrigin_Size.y; + } + else if (CurrentPixelPosition.y > CurrentBottom) + { + float dist = CurrentPixelPosition.y - CurrentBottom; + Finaluv.y = (OriginBottom + dist) / g_fOrigin_Size.y; + } + else + { + float scale = (CurrentPixelPosition.y - CurrentTop) / (CurrentBottom - CurrentTop); + Finaluv.y = (OriginTop / g_fOrigin_Size.y) + scale * ((OriginBottom - OriginTop) / g_fOrigin_Size.y); + } + + + if (g_iHover != 0) + { + float4 tex = g_Texture.Sample(ClampSampler, Finaluv); + Color = tex; + + float2 ImgaePos1 = g_fImageSipos1.xy; + float2 ImgaeSize1 = g_fImageSipos1.zw; + float2 ImgaePixel = Finaluv * g_fOrigin_Size; + float2 localUV = (ImgaePixel - ImgaePos1) / ImgaeSize1; + bool inside = all(localUV >= 0.0f && localUV <= 1.0f); + if (inside) + { + float4 tex2 = g_Texture1.Sample(ClampSampler, localUV); + Color = lerp(Color, tex2, tex2.a); + } + + float2 ImgaePos2 = g_fImageSipos2.xy; + float2 ImgaeSize2 = g_fImageSipos2.zw; + float2 ImgaePixe2 = Finaluv * g_fOrigin_Size; + float2 ReverseUV = (ImgaePixe2 - ImgaePos2) / ImgaeSize2; + bool inside2 = all(ReverseUV >= 0.0f && ReverseUV <= 1.0f); + if (inside2) + { + ReverseUV.y = 1.f - ReverseUV.y; + float4 tex2 = g_Texture1.Sample(ClampSampler, ReverseUV); + Color = lerp(Color, tex2, tex2.a); + } + } + + float2 ImgaePos3 = g_fImageSipos3.xy / g_fCurrent_Size; + float2 ImgaeSize3 = g_fImageSipos3.zw / g_fCurrent_Size; + float2 localUV2 = (In.vTexcoord - ImgaePos3) / ImgaeSize3; + bool inside3 = all(localUV2 >= 0.0f && localUV2 <= 1.0f); + if (inside3) + { + float4 tex2 = g_Texture2.Sample(ClampSampler, localUV2); + Color = lerp(Color, tex2, tex2.a); + } + + Color.a *= Alpha; + Out.vColor = Color; + return Out; +} + struct VS_IN3D { float3 vPosition : POSITION; @@ -3206,6 +3300,16 @@ technique11 PosTexTechnique11 PixelShader = compile ps_5_0 PS_BoosterHpBar(); } + pass DialogueChoice + { + SetRasterizerState(RS_Nocull); + SetDepthStencilState(DSS_Default, 0); + SetBlendState(BS_AlphaBlend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_MAIN(); + + PixelShader = compile ps_5_0 PS_DialogueChoice(); + } + pass Enemy_Detection { SetRasterizerState(RS_Nocull); diff --git a/Jusin154_Team3D/Client/Private/Dialogue.cpp b/Jusin154_Team3D/Client/Private/Dialogue.cpp index aa0095f1a..861f45413 100644 --- a/Jusin154_Team3D/Client/Private/Dialogue.cpp +++ b/Jusin154_Team3D/Client/Private/Dialogue.cpp @@ -181,7 +181,6 @@ void CDialogue::SizeUpdate(_wstring pName, _wstring pText) void CDialogue::Set_Time(_float fTime) { - m_bHover = true; m_fTime = fTime; } diff --git a/Jusin154_Team3D/Client/Private/Dialogue_Data.cpp b/Jusin154_Team3D/Client/Private/Dialogue_Data.cpp index 429aa7acb..ce8d72c9f 100644 --- a/Jusin154_Team3D/Client/Private/Dialogue_Data.cpp +++ b/Jusin154_Team3D/Client/Private/Dialogue_Data.cpp @@ -88,7 +88,7 @@ const CURRENTDIALOGUEINFO& CDialogue_Data::Get_Info(_wstring NpcName, _int iText } auto Text = iter->second.Info.find(iTextID); - if (iter == m_DialogueInfo.end()) + if (Text == iter->second.Info.end()) { return Dummy; } diff --git a/Jusin154_Team3D/Client/Private/Dialogue_Font.cpp b/Jusin154_Team3D/Client/Private/Dialogue_Font.cpp index e009ecd06..a3ed45d57 100644 --- a/Jusin154_Team3D/Client/Private/Dialogue_Font.cpp +++ b/Jusin154_Team3D/Client/Private/Dialogue_Font.cpp @@ -25,6 +25,7 @@ HRESULT CDialogue_Font::Initialize(void* pArg) m_pInfoInstance->Add_Event(TEXT("Dialogue"), [this](void* p) {this->Add_Text(p); }); m_pInfoInstance->Add_Event(TEXT("NpcInteract"), [this](void* p) {this->NpcInteract(*reinterpret_cast<_bool*>(p)); }); m_pInfoInstance->Add_Event(TEXT("NPCInteractionOn"), [this](void* p) {this->NpcInfo(p); }); + m_pInfoInstance->Add_Event(TEXT("NPCDialogue"), [this](void* p) {this->NpcDialogue(reinterpret_cast(p)); }); for (_int i = 0; i < 5; ++i) { @@ -75,20 +76,21 @@ void CDialogue_Font::Update(_float fTimeDelta) } } - if (!m_pCurrentDialogue.empty()) + } + + if (!m_pCurrentDialogue.empty()) + { + for (auto it = m_pCurrentDialogue.begin(); it != m_pCurrentDialogue.end();) { - for (auto it = m_pCurrentDialogue.begin(); it != m_pCurrentDialogue.end();) + if ((*it)->Get_Hover() == false) { - if ((*it)->Get_Hover() == false) - { - (*it)->Visible(false); - m_DialoguInfo.push_back((*it)); - it = m_pCurrentDialogue.erase(it); - } - else - { - it++; - } + (*it)->Visible(false); + m_DialoguInfo.push_back((*it)); + it = m_pCurrentDialogue.erase(it); + } + else + { + it++; } } } @@ -96,7 +98,7 @@ void CDialogue_Font::Update(_float fTimeDelta) void CDialogue_Font::Late_Update(_float fTimeDelta) { - if (!m_DialoguInfo.empty()) + if (!m_pCurrentDialogue.empty()) { m_pGameInstance->Add_RenderGroup(RENDER::UI_OVERLAY, this); } @@ -153,6 +155,7 @@ void CDialogue_Font::Add_Text(void* pArg) Dialogue->SizeUpdate(pInfo.pName, pInfo.pText); Dialogue->Visible(true); Dialogue->Set_Time(pInfo.fTime); + Dialogue->Set_Hover(true); m_pCurrentDialogue.push_front(Dialogue); } @@ -161,6 +164,13 @@ void CDialogue_Font::Npc_Dialogue(DIALOGUEINFO Info) { if (m_DialoguInfo.empty() == true) return; + + if (m_pCurrentDialogue.size() >= 5) + { + CDialogue* old = m_pCurrentDialogue.back(); + m_pCurrentDialogue.pop_back(); + m_DialoguInfo.push_back(old); + } CDialogue* Dialogue = m_DialoguInfo.back(); m_DialoguInfo.pop_back(); @@ -173,6 +183,7 @@ void CDialogue_Font::Npc_Dialogue(DIALOGUEINFO Info) Dialogue->SizeUpdate(Info.pName, Info.pText); Dialogue->Visible(true); Dialogue->Set_Time(Info.fTime); + Dialogue->Set_Hover(true); m_pCurrentDialogue.push_front(Dialogue); } @@ -199,10 +210,21 @@ void CDialogue_Font::NpcDialogue() m_iNextID = Info.NextTextID; } +void CDialogue_Font::NpcDialogue(CNPCStat* Stat) +{ + auto Info = m_pInfoInstance->Get_Dialogue(Stat->Get_Stat().pName, 0); + m_Info.pName = Stat->Get_Stat().pNpc_Name; + m_Info.pText = Info.pText; + m_Info.fTime = 3.f; + m_iType = Info.iTextType; + m_iNextID = Info.NextTextID; + Npc_Dialogue(m_Info); +} + void CDialogue_Font::CHoice() { auto Info = m_pInfoInstance->Get_Dialogue(m_pNpcName, m_iTextID); -// Info.ChoiceInfo.size(); + // Info.ChoiceInfo.size(); } void CDialogue_Font::Shop() @@ -220,6 +242,7 @@ void CDialogue_Font::NextText() m_pCurrentDialogue[0]->Set_Hover(false); _bool Interact = false; m_pInfoInstance->Event_CallBack(TEXT("NpcInteract"), &Interact); + m_pCurrentDialogue[0]->Set_Hover(true); } else { diff --git a/Jusin154_Team3D/Client/Private/Level_Field.cpp b/Jusin154_Team3D/Client/Private/Level_Field.cpp index 658e199bb..e22418aac 100644 --- a/Jusin154_Team3D/Client/Private/Level_Field.cpp +++ b/Jusin154_Team3D/Client/Private/Level_Field.cpp @@ -61,6 +61,9 @@ HRESULT CLevel_Field::Initialize(void* pArg) return E_FAIL; } + m_bLevel = true; + m_pInfoInstance->Event_CallBack(TEXT("UIManagerFadeIn")); + return S_OK; } @@ -86,14 +89,13 @@ void CLevel_Field::Update(_float fTimeDelta) } } - //m_bLevel = true; - //if (m_bLevel != m_bCurrentLevel) - //{ - // m_bCurrentLevel = m_bLevel; - // UI_STATE eState = UI_STATE::LEVELCHANGE; - // m_pInfoInstance->Event_CallBack(TEXT("Canvas_Change"), &eState); - //} + if (m_bLevel != m_bCurrentLevel) + { + m_bCurrentLevel = m_bLevel; + UI_STATE eState = UI_STATE::GAMEPLAYER; + m_pInfoInstance->Event_CallBack(TEXT("Canvas_Change"), &eState); + } } @@ -169,7 +171,7 @@ HRESULT CLevel_Field::Ready_Lights() _float4 vDiffuse = _float4(0.745f, 0.797f, 0.8f, 0.f); _float4 vAmbient = _float4(0.1f, 0.13f, 0.13f, 0.f); _float4 vSpecular = _float4(0.05f, 0.05f, 0.05f, 0.f); - + #if gimch || 진우 vDiffuse = _float4(0.361f, 0.451f, 0.451f, 0.204f); vAmbient = _float4(0.161f, 0.161f, 0.161f, 0.0f); @@ -177,7 +179,7 @@ HRESULT CLevel_Field::Ready_Lights() #endif // gimch - + pLight->Get_Component()->Set_Color(vDiffuse, vAmbient, vSpecular); diff --git a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp index 65216e7b5..c614a1d0b 100644 --- a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp +++ b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp @@ -115,16 +115,12 @@ HRESULT CLevel_GamePlay::Initialize(void* pArg) if (FAILED(Ready_Layer_Monster())) { return E_FAIL; } - - if(FAILED(m_pInfoInstance->Late_Initialize())) + + if (FAILED(m_pInfoInstance->Late_Initialize())) return E_FAIL; m_bLevel = true; - if (m_bCurrentLevel != m_bLevel) - { - m_bCurrentLevel = m_bLevel; - m_pInfoInstance->Event_CallBack(TEXT("UIManagerFadeIn")); - } + m_pInfoInstance->Event_CallBack(TEXT("UIManagerFadeIn")); return S_OK; } @@ -151,7 +147,7 @@ void CLevel_GamePlay::Update(_float fTimeDelta) m_pInfoInstance->Change_Level(); UI_STATE eState = UI_STATE::LEVELCHANGE; - m_pInfoInstance->Event_CallBack(TEXT("Canvas_Change"),&eState); + m_pInfoInstance->Event_CallBack(TEXT("Canvas_Change"), &eState); if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::FIELD)))) { return; @@ -231,7 +227,7 @@ HRESULT CLevel_GamePlay::Ready_Lights() HRESULT CLevel_GamePlay::Ready_Volumetric() { // Volumetric 설정 - if(m_isDay) + if (m_isDay) { m_pGameInstance->Setting_Volumetirc( 1.251f, // 밀도 @@ -282,7 +278,7 @@ HRESULT CLevel_GamePlay::Ready_Background() if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(ENUM_CLASS(LEVEL::STATIC), NEXT_LEVEL, LAYER_BACKGROUND, &Terrain_Desc))) { return E_FAIL; } - + /* 물 오브젝트 */ if (FAILED(CInfoInstance::GetInstance()->Load_WaterElemet("Element_Water_Info"))) { return E_FAIL; @@ -325,9 +321,9 @@ HRESULT CLevel_GamePlay::Ready_Background() #endif // _DEBUG - + /* Map Containters */ - if(false == isReady_Background) + if (false == isReady_Background) { /* 테스트용 맵 */ CInfoInstance::GetInstance()->Load_MapObjects("Map1215", LAYER_HOGSMEADE); @@ -337,23 +333,23 @@ HRESULT CLevel_GamePlay::Ready_Background() #if 진우 #else - if(isReady_Hogsmeade) + if (isReady_Hogsmeade) { if (FAILED(Ready_Layer_Hogsmeade())) return E_FAIL; } - if(isReady_Hogwart) + if (isReady_Hogwart) { if (FAILED(Ready_Layer_Hogwart())) return E_FAIL; } #endif - + if (FAILED(Ready_IntstanceProp())) return E_FAIL; } - + return S_OK; } @@ -831,7 +827,7 @@ HRESULT CLevel_GamePlay::Ready_Layer_Player(const _wstring& strLayerTag) #endif // Bin #endif // _DEBUG - if(true == isLoad_NPC) + if (true == isLoad_NPC) { { CNPC_Ollivander::NPCDESC NPCDesc{}; @@ -871,7 +867,7 @@ HRESULT CLevel_GamePlay::Ready_Layer_Player(const _wstring& strLayerTag) CPlayer::PLAYERDESC playerDesc = {}; playerDesc.vPos = _float4(-21.f, 0.f, -14.f, 1.f); playerDesc.vRotQ = _float4(0.f, 0.f, 0.f, 1.f); - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag,&playerDesc))) { + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &playerDesc))) { return E_FAIL; } } @@ -971,7 +967,7 @@ HRESULT CLevel_GamePlay::Ready_Layer_Monster() HRESULT CLevel_GamePlay::Ready_Layer_Manager(const _wstring& strLayerTag) { - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag,nullptr,nullptr,&m_pBroomRaceManager))) { + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, nullptr, nullptr, &m_pBroomRaceManager))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Client/Private/RandomNpc.cpp b/Jusin154_Team3D/Client/Private/RandomNpc.cpp index 778e873dd..2c435414f 100644 --- a/Jusin154_Team3D/Client/Private/RandomNpc.cpp +++ b/Jusin154_Team3D/Client/Private/RandomNpc.cpp @@ -57,7 +57,7 @@ void CRandomNpc::Priority_Update(_float fTimeDelta) m_iEntered = 0; } __super::Priority_Update(fTimeDelta); -} +} void CRandomNpc::Update(_float fTimeDelta) { @@ -87,9 +87,26 @@ void CRandomNpc::Update(_float fTimeDelta) m_fTargetDistance = { FLT_MAX }; } - if (m_fTargetDistance <= 5.f) + if (m_fTargetDistance <= 5.f && m_bInteract == false) { - _int a = 10; + m_pInfoInstance->Event_CallBack(TEXT("NPCDialogue"), m_pNpcStat); + m_bInteract = true; + } + + if (m_bInteract != m_bPreviousInteract) + { + m_bPreviousInteract = m_bInteract; + m_fInteractTime = 0.f; + } + else + { + m_fInteractTime += fTimeDelta; + } + + if (m_fInteractTime >= 5.f) + { + m_bInteract = false; + m_fInteractTime = 0.f; } } @@ -252,7 +269,7 @@ HRESULT CRandomNpc::Bind_ShaderParameters(_uint iMeshOrder) _float fMixerFactor = { FLT_MAX }; _uint iColorMixerMethod = { 0 }; - switch (m_pModelCom->Get_UsingPass(iMeshOrder,m_pShaderCom)) + switch (m_pModelCom->Get_UsingPass(iMeshOrder, m_pShaderCom)) { case 23: if (m_strModelPrototypeTag == TEXT("Prototype_Component_F_Student_Model")) @@ -297,7 +314,7 @@ HRESULT CRandomNpc::Ready_Components(void* pArg) if (FAILED(__super::Ready_Components(&Desc))) { return E_FAIL; } - + switch (m_iIndex) { case 0: @@ -341,7 +358,7 @@ HRESULT CRandomNpc::Ready_Components(void* pArg) if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("ELF"), (CComponent**)&m_pNpcStat))) { return E_FAIL; } - break; + break; case 7: m_strModelPrototypeTag = TEXT("Prototype_Component_BaiHowin_Model"); if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("BAIHOWIN"), (CComponent**)&m_pNpcStat))) { diff --git a/Jusin154_Team3D/Client/Public/Client_Struct.h b/Jusin154_Team3D/Client/Public/Client_Struct.h index 7fb940cb9..c3bc574a0 100644 --- a/Jusin154_Team3D/Client/Public/Client_Struct.h +++ b/Jusin154_Team3D/Client/Public/Client_Struct.h @@ -57,7 +57,7 @@ namespace Client { _wstring pNpcName; _int iNpcID{}; - unordered_map<_int, CURRENTDIALOGUEINFO> Info; + map<_int, CURRENTDIALOGUEINFO> Info; }NPCDIALOGUEINFO; typedef struct tagLockOnInfo { diff --git a/Jusin154_Team3D/Client/Public/Dialogue_Font.h b/Jusin154_Team3D/Client/Public/Dialogue_Font.h index ec3edb0c9..6a89809c2 100644 --- a/Jusin154_Team3D/Client/Public/Dialogue_Font.h +++ b/Jusin154_Team3D/Client/Public/Dialogue_Font.h @@ -8,6 +8,7 @@ NS_BEGIN(Engine) class CTexture; class CShader; class CVIBuffer_Rect; +class CNPCStat; NS_END NS_BEGIN(Client) @@ -46,6 +47,7 @@ class CDialogue_Font final : public CGameObject void NpcInteract(_bool bInteract); void NpcDialogue(); + void NpcDialogue(CNPCStat* Stat); void CHoice(); diff --git a/Jusin154_Team3D/Client/Public/RandomNpc.h b/Jusin154_Team3D/Client/Public/RandomNpc.h index b341a049f..3f63c55d1 100644 --- a/Jusin154_Team3D/Client/Public/RandomNpc.h +++ b/Jusin154_Team3D/Client/Public/RandomNpc.h @@ -52,6 +52,12 @@ class CRandomNpc final : public CUnit _float2 m_vEnteringTimer = { 0.f, 1.f }; _float m_fEncounterDistance = { 8.f }; _int m_iIndex = {}; + + + _bool m_bInteract = { false }; + _bool m_bPreviousInteract = { false }; + _float m_fInteractTime{}; + protected: virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Dialogue/Dialogue.xml b/Jusin154_Team3D/Editor/Bin/Resources/Data/Dialogue/Dialogue.xml index f267a4f2c..0504c04da 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Dialogue/Dialogue.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Dialogue/Dialogue.xml @@ -16,7 +16,7 @@ - + diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl index 5495075f9..60c0ef454 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl @@ -2426,6 +2426,100 @@ PS_OUT PS_BoosterHpBar(PS_IN In) return Out; } +PS_OUT PS_DialogueChoice(PS_IN In) +{ + PS_OUT Out = (PS_OUT) 0; + float Alpha = g_fAlpha * g_fOwnerAlpha * g_fCanvasAlpha; + float4 Color = float4(1.f, 1.f, 1.f, 0.f); + float2 uv = In.vTexcoord; + float2 CurrentPixelPosition = uv * g_fCurrent_Size; + float OriginLeft = g_fNine_Slice.x; + float OriginRight = g_fNine_Slice.y; + float OriginTop = g_fNine_Slice.z; + float OriginBottom = g_fNine_Slice.w; + + float CurrentLeft = OriginLeft; + float CurrentRight = g_fCurrent_Size.x - (g_fOrigin_Size.x - OriginRight); + float CurrentTop = OriginTop; + float CurrentBottom = g_fCurrent_Size.y - (g_fOrigin_Size.y - OriginBottom); + + float2 Finaluv = In.vTexcoord; + + if (CurrentPixelPosition.x < CurrentLeft) + { + Finaluv.x = CurrentPixelPosition.x / g_fOrigin_Size.x; + } + else if (CurrentPixelPosition.x > CurrentRight) + { + float dist = CurrentPixelPosition.x - CurrentRight; + Finaluv.x = (OriginRight + dist) / g_fOrigin_Size.x; + } + else + { + float scale = (CurrentPixelPosition.x - CurrentLeft) / (CurrentRight - CurrentLeft); + Finaluv.x = (OriginLeft / g_fOrigin_Size.x) + scale * ((OriginRight - OriginLeft) / g_fOrigin_Size.x); + } + + if (CurrentPixelPosition.y < CurrentTop) + { + Finaluv.y = CurrentPixelPosition.y / g_fOrigin_Size.y; + } + else if (CurrentPixelPosition.y > CurrentBottom) + { + float dist = CurrentPixelPosition.y - CurrentBottom; + Finaluv.y = (OriginBottom + dist) / g_fOrigin_Size.y; + } + else + { + float scale = (CurrentPixelPosition.y - CurrentTop) / (CurrentBottom - CurrentTop); + Finaluv.y = (OriginTop / g_fOrigin_Size.y) + scale * ((OriginBottom - OriginTop) / g_fOrigin_Size.y); + } + + + if (g_iHover != 0) + { + float4 tex = g_Texture.Sample(ClampSampler, Finaluv); + Color = tex; + + float2 ImgaePos1 = g_fImageSipos1.xy; + float2 ImgaeSize1 = g_fImageSipos1.zw; + float2 ImgaePixel = Finaluv * g_fOrigin_Size; + float2 localUV = (ImgaePixel - ImgaePos1) / ImgaeSize1; + bool inside = all(localUV >= 0.0f && localUV <= 1.0f); + if (inside) + { + float4 tex2 = g_Texture1.Sample(ClampSampler, localUV); + Color = lerp(Color, tex2, tex2.a); + } + + float2 ImgaePos2 = g_fImageSipos2.xy; + float2 ImgaeSize2 = g_fImageSipos2.zw; + float2 ImgaePixe2 = Finaluv * g_fOrigin_Size; + float2 ReverseUV = (ImgaePixe2 - ImgaePos2) / ImgaeSize2; + bool inside2 = all(ReverseUV >= 0.0f && ReverseUV <= 1.0f); + if (inside2) + { + ReverseUV.y = 1.f - ReverseUV.y; + float4 tex2 = g_Texture1.Sample(ClampSampler, ReverseUV); + Color = lerp(Color, tex2, tex2.a); + } + } + + float2 ImgaePos3 = g_fImageSipos3.xy / g_fCurrent_Size; + float2 ImgaeSize3 = g_fImageSipos3.zw / g_fCurrent_Size; + float2 localUV2 = (In.vTexcoord - ImgaePos3) / ImgaeSize3; + bool inside3 = all(localUV2 >= 0.0f && localUV2 <= 1.0f); + if (inside3) + { + float4 tex2 = g_Texture2.Sample(ClampSampler, localUV2); + Color = lerp(Color, tex2, tex2.a); + } + + Color.a *= Alpha; + Out.vColor = Color; + return Out; +} + struct VS_IN3D { float3 vPosition : POSITION; @@ -3206,6 +3300,16 @@ technique11 PosTexTechnique11 PixelShader = compile ps_5_0 PS_BoosterHpBar(); } + pass DialogueChoice + { + SetRasterizerState(RS_Nocull); + SetDepthStencilState(DSS_Default, 0); + SetBlendState(BS_AlphaBlend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_MAIN(); + + PixelShader = compile ps_5_0 PS_DialogueChoice(); + } + pass Enemy_Detection { SetRasterizerState(RS_Nocull); diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/Dialogue_Chice.png b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/Dialogue_Chice.png new file mode 100644 index 000000000..b146ba0a0 Binary files /dev/null and b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/Dialogue_Chice.png differ diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Textures/Mission/UI_T_Icon_InteractType_Straight.png b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/UI_T_Icon_InteractType_Straight.png similarity index 100% rename from Jusin154_Team3D/Editor/Bin/Resources/Textures/Mission/UI_T_Icon_InteractType_Straight.png rename to Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/UI_T_Icon_InteractType_Straight.png diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/UI_T_InteractSelectionBracket.png b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/UI_T_InteractSelectionBracket.png new file mode 100644 index 000000000..f31219fd0 Binary files /dev/null and b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/UI_T_InteractSelectionBracket.png differ diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj b/Jusin154_Team3D/Editor/Default/Editor.vcxproj index 2b600576c..afae6e31f 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj @@ -187,6 +187,9 @@ call Update_Shaders.bat + + + @@ -466,6 +469,9 @@ call Update_Shaders.bat + + + diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index 3f81afff4..d99f17de4 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -753,7 +753,7 @@ {614e67ae-6df9-4826-adbe-6be96f54041d} - + {906987cf-14ce-4676-8ca7-a68b6b2c29b6} @@ -769,6 +769,15 @@ {7a345ef7-8e16-45df-9bc3-e8fc665f729f} + + {a5413132-f824-4e59-b3bb-1e6ad539b274} + + + {54dbea26-acfa-49be-9a97-1e2408cbd9b2} + + + {0201d2a8-9187-468c-aa2f-491bd3ae6ae1} + @@ -1557,6 +1566,15 @@ 02.GameObjects\Layer_Effect\Effect_Editor\Effect\Monster_Effect\Ranrok\DeadImpact + + 50.UI\Dialogue_Canvas\Dialogue_Panel + + + 50.UI\Dialogue_Canvas + + + 50.UI\Dialogue_Canvas\Dialogue_Panel\Dialogue_Choice + @@ -2353,6 +2371,15 @@ 02.GameObjects\Layer_Effect\Effect_Editor\Effect\Monster_Effect\Ranrok\DeadImpact + + 50.UI\Dialogue_Canvas\Dialogue_Panel + + + 50.UI\Dialogue_Canvas + + + 50.UI\Dialogue_Canvas\Dialogue_Panel\Dialogue_Choice + diff --git a/Jusin154_Team3D/Editor/Private/Dialogue_Canvas.cpp b/Jusin154_Team3D/Editor/Private/Dialogue_Canvas.cpp new file mode 100644 index 000000000..919fc4d6a --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/Dialogue_Canvas.cpp @@ -0,0 +1,137 @@ +#include "pch.h" +#include "Dialogue_Canvas.h" +#include "GameInstance.h" +#include "UI_Manager.h" +#include "Dialogue_Panel.h" + +CDialogue_Canvas::CDialogue_Canvas(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + :CCanvasObject(pDevice, pContext) +{ +} + +CDialogue_Canvas::CDialogue_Canvas(const CDialogue_Canvas& rhs) + :CCanvasObject(rhs) +{ +} + +HRESULT CDialogue_Canvas::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CDialogue_Canvas::Initialize(void* pArg) +{ + CUIObject::UIOBJECT_DESC Desc{}; + + Desc.fX = 0.f; + Desc.fY = 0.f; + Desc.fSizeX = 1920.f; + Desc.fSizeY = 1080.f; + + if (FAILED(__super::Initialize(&Desc))) + { + return E_FAIL; + } + if (FAILED(Ready_Components(pArg))) + { + return E_FAIL; + } + if (FAILED(Ready_Panel(pArg))) + { + return E_FAIL; + } + Visible(true); + return S_OK; +} + +void CDialogue_Canvas::Priority_Update(_float fTimeDelta) +{ + __super::Priority_Update(fTimeDelta); +} + +void CDialogue_Canvas::Update(_float fTimeDelta) +{ + __super::Update(fTimeDelta); +} + +void CDialogue_Canvas::Late_Update(_float fTimeDelta) +{ + if (m_bVisible) { + } + __super::Late_Update(fTimeDelta); +} + +HRESULT CDialogue_Canvas::Render() +{ + return S_OK; +} + +_vector CDialogue_Canvas::Get_WorldPostion() +{ + return m_pTransformCom->Get_State(STATE::POSITION); +} + +HRESULT CDialogue_Canvas::Bind_ShaderResources() +{ + return S_OK; +} + +HRESULT CDialogue_Canvas::Ready_Components(void* pArg) +{ + if (FAILED(Add_Component(g_iStaticLevel, &m_pVIBufferCom))) { + return E_FAIL; + } + + return S_OK; +} +HRESULT CDialogue_Canvas::Ready_Panel(void* pArg) +{ + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_UI, nullptr, this, reinterpret_cast(&m_pDialogue_Panel)))) + { + return E_FAIL; + } + Add_Panel(TEXT("Dialogue_Panel"), m_pDialogue_Panel); + + return S_OK; +} + +void CDialogue_Canvas::Clear_Penel() +{ +} + +CDialogue_Canvas* CDialogue_Canvas::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CDialogue_Canvas* pInstance = new CDialogue_Canvas(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CDialogue_Canvas"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CGameObject* CDialogue_Canvas::Clone(void* pArg, CGameObject* pOwner) +{ + CDialogue_Canvas* pInstance = new CDialogue_Canvas(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CDialogue_Canvas"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CDialogue_Canvas::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pVIBufferCom); +} + +void CDialogue_Canvas::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Editor/Private/Dialogue_Choice.cpp b/Jusin154_Team3D/Editor/Private/Dialogue_Choice.cpp new file mode 100644 index 000000000..23c36a73f --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/Dialogue_Choice.cpp @@ -0,0 +1,317 @@ +#include "pch.h" +#include "Dialogue_Choice.h" +#include "GameInstance.h" + +CDialogue_Choice::CDialogue_Choice(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + :CElementObject(pDevice, pContext) +{ +} + +CDialogue_Choice::CDialogue_Choice(const CDialogue_Choice& rhs) + :CElementObject(rhs) +{ +} + +HRESULT CDialogue_Choice::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CDialogue_Choice::Initialize(void* pArg) +{ + CUIObject::UIOBJECT_DESC Desc{}; + + Desc.fX = -100.f; + Desc.fY = -200.f; + Desc.fSizeX = 100.f; + Desc.fSizeY = 65.f; + + m_pRect = { long(Desc.fX - Desc.fSizeX * 0.5f), long(Desc.fY - Desc.fSizeY * 0.5f), long(Desc.fX + Desc.fSizeX * 0.5f), long(Desc.fY + Desc.fSizeY * 0.5f) }; + + if (FAILED(__super::Initialize(&Desc))) + { + return E_FAIL; + } + if (FAILED(Ready_Components(pArg))) + { + return E_FAIL; + } + + m_fTimeMult = 3.f; + m_fAlpha = 1.f; + m_fAlphaTime = 3.f; + m_vNine_Slice = _float4(20.f, 100.f, 0.f, 65.f); + m_vImagePosi1 = _float4(0.f, 0.f, 90.f, 20.f); + m_vImagePosi2 = _float4(0.f, 45.f, 90.f, 20.f); + m_vImagePosi3 = _float4(15.f, 12.5f, 40.f, 40.f); + m_fFontX = 370.f; + m_fFontY = 607.5f; + m_iHover = 0; + SizeUpX(400.f); + return S_OK; +} + +void CDialogue_Choice::Mouse_Hover() +{ + POINT ptMouse{}; + GetCursorPos(&ptMouse); + ScreenToClient(g_hWnd, &ptMouse); // 윈도우 왼쪽 상단 (0,0) 기준 + + // 윈도우 실제 내부 크기를 '직접' 가져옵니다. (g_iWinSize 대신) + RECT rc; + GetClientRect(g_hWnd, &rc); + _float fWidth = (_float)(rc.right - rc.left); + _float fHeight = (_float)(rc.bottom - rc.top); + + _float2 fMouse; + // 캔버스 배치 로직(Update)과 마우스 변환 로직을 완벽하게 일치시킵니다. + fMouse.x = (_float)ptMouse.x - (fWidth * 0.5f); + fMouse.y = -((_float)ptMouse.y - (fHeight * 0.494f)); // Y축 뒤집기 + + POINT pt = { (long)fMouse.x, (long)fMouse.y }; + + Hover(PtInRect(&m_pRect, pt)); +} + +void CDialogue_Choice::Hover(_bool iHover) +{ + m_iHover = iHover; + if (m_iHover != 0) + { + m_fFontX = 390.f; + m_vImagePosi3 = _float4(35.f, 12.5f, 40.f, 40.f); + } + else + { + m_fFontX = 370.f; + m_vImagePosi3 = _float4(15.f, 12.5f, 40.f, 40.f); + } +} + +void CDialogue_Choice::Priority_Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + __super::Priority_Update(fTimeDelta); +} + +void CDialogue_Choice::Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + + if (m_bFadeIn == true) + { + if (m_fAlpha <= 7.f) + m_fAlpha += fTimeDelta * m_fAlphaTime; + + if (m_fAlpha >= 7.f) + { + m_bFadeIn = false; + m_fAlpha = 7.f; + } + } + + if (m_bFadeOut == true) + { + if (m_fAlpha >= 0.f) + m_fAlpha -= fTimeDelta; + + if (m_fAlpha <= 0.f) + { + m_bFadeOut = false; + m_fAlpha = 0.f; + } + } + + Mouse_Hover(); + + m_fTime += fTimeDelta * m_fTimeMult; + __super::Update(fTimeDelta); +} + +void CDialogue_Choice::Late_Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + if (m_bVisible) { + m_pGameInstance->Add_RenderGroup(RENDER::UI, this); + __super::Late_Update(fTimeDelta); + } +} + +HRESULT CDialogue_Choice::Render() +{ + if (FAILED(Bind_ShaderResources())) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_UIEDITOR::DIALOGUECHOICE)))) { + return E_FAIL; + } + if (FAILED(m_pVIBufferCom->Bind_Resources())) { + return E_FAIL; + } + if (FAILED(m_pVIBufferCom->Render())) { + return E_FAIL; + } + + m_pGameInstance->Render_Text(TEXT("Font_size20"), TEXT("아아"), _float2(m_fFontX + m_fX, m_fFontY - m_fY), XMVectorSet((208.f / 255.f) * m_fAlpha, (177.f / 255.f) * m_fAlpha, (52.f / 255.f) * m_fAlpha, m_fAlpha)); + + return S_OK; +} + +_vector CDialogue_Choice::Get_WorldPostion() +{ + return m_pTransformCom->Get_State(STATE::POSITION); +} + +HRESULT CDialogue_Choice::Bind_ShaderResources() +{ + if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", &m_ViewMatrix))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", &m_ProjMatrix))) + { + return E_FAIL; + } + if (FAILED(m_pDiffuse_TextureCom->Bind_ShaderResource(m_pShaderCom, "g_Texture", 0))) + { + return E_FAIL; + } + if (FAILED(m_pDiffuse_TextureCom1->Bind_ShaderResource(m_pShaderCom, "g_Texture1", 0))) + { + return E_FAIL; + } + if (FAILED(m_pDiffuse_TextureCom2->Bind_ShaderResource(m_pShaderCom, "g_Texture2", 0))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fTime", &m_fTime, sizeof(_float)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fAlpha", &m_fAlpha, sizeof(_float)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fOwnerAlpha", &m_fOwnerAlpha, sizeof(_float)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fCanvasAlpha", &m_fCanvasAlpha, sizeof(_float)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fOrigin_Size", &m_fOrigin_Size, sizeof(_float2)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fCurrent_Size", &m_vScale, sizeof(_float2)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fNine_Slice", &m_vNine_Slice, sizeof(_float4)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fImageSipos1", &m_vImagePosi1, sizeof(_float4)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fImageSipos2", &m_vImagePosi2, sizeof(_float4)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fImageSipos3", &m_vImagePosi3, sizeof(_float4)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_iHover", &m_iHover, sizeof(_int)))) + { + return E_FAIL; + } + + return S_OK; +} + +HRESULT CDialogue_Choice::Ready_Components(void* pArg) +{ + if (FAILED(Add_Component(g_iStaticLevel, &m_pVIBufferCom))) + { + return E_FAIL; + } + if (FAILED(Add_Asset_Component(ENUM_CLASS(LEVEL::UI), TEXT("Prototype_Texture_Dialogue_Chice"), reinterpret_cast(&m_pDiffuse_TextureCom), nullptr))) + { + return E_FAIL; + } + if (FAILED(Add_Asset_Component(ENUM_CLASS(LEVEL::UI), TEXT("Prototype_Texture_UI_T_InteractSelectionBracket"), reinterpret_cast(&m_pDiffuse_TextureCom1), nullptr))) + { + return E_FAIL; + } + if (FAILED(Add_Asset_Component(ENUM_CLASS(LEVEL::UI), TEXT("Prototype_Texture_UI_T_Icon_InteractType_Straight"), reinterpret_cast(&m_pDiffuse_TextureCom2), nullptr))) + { + return E_FAIL; + } + if (FAILED(Add_Asset_Component(g_iStaticLevel, FX_UIEDITOR, (CComponent**)&m_pShaderCom, nullptr))) + { + return E_FAIL; + } + + return S_OK; +} + +CDialogue_Choice* CDialogue_Choice::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CDialogue_Choice* pInstance = new CDialogue_Choice(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CDialogue_Choice"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CGameObject* CDialogue_Choice::Clone(void* pArg, CGameObject* pOwner) +{ + CDialogue_Choice* pInstance = new CDialogue_Choice(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CDialogue_Choice"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CDialogue_Choice::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pDiffuse_TextureCom); + SAFE_RELEASE(m_pDiffuse_TextureCom1); + SAFE_RELEASE(m_pDiffuse_TextureCom2); + SAFE_RELEASE(m_pShaderCom); + SAFE_RELEASE(m_pVIBufferCom); +} + +void CDialogue_Choice::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Editor/Private/Dialogue_Panel.cpp b/Jusin154_Team3D/Editor/Private/Dialogue_Panel.cpp new file mode 100644 index 000000000..2fc59c31b --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/Dialogue_Panel.cpp @@ -0,0 +1,149 @@ +#include "pch.h" +#include "Dialogue_Panel.h" +#include "GameInstance.h" +#include "Dialogue_Choice.h" + +CDialogue_Panel::CDialogue_Panel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + :CPanelObject(pDevice, pContext) +{ +} + +CDialogue_Panel::CDialogue_Panel(const CDialogue_Panel& rhs) + :CPanelObject(rhs) +{ +} + +HRESULT CDialogue_Panel::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CDialogue_Panel::Initialize(void* pArg) +{ + CUIObject::UIOBJECT_DESC Desc{}; + + Desc.fX = 500.f; + Desc.fY = -625.f; + Desc.fSizeX = 750.f; + Desc.fSizeY = 410.f; + + if (FAILED(__super::Initialize(&Desc))) + { + return E_FAIL; + } + if (FAILED(Ready_Components(pArg))) + { + return E_FAIL; + } + if (FAILED(Ready_Element(pArg))) + { + return E_FAIL; + } + + m_fCanvasAlpha = 1.f; + Visible(true); + ElementAllVisible(true); + return S_OK; +} + +void CDialogue_Panel::Priority_Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + __super::Priority_Update(fTimeDelta); +} + +void CDialogue_Panel::Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + + __super::Update(fTimeDelta); +} + +void CDialogue_Panel::Late_Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + + if (m_bVisible) { + __super::Late_Update(fTimeDelta); + } +} + +HRESULT CDialogue_Panel::Render() +{ + return S_OK; +} + +_vector CDialogue_Panel::Get_WorldPostion() +{ + return m_pTransformCom->Get_State(STATE::POSITION); +} + +HRESULT CDialogue_Panel::Bind_ShaderResources() +{ + return S_OK; +} + +HRESULT CDialogue_Panel::Ready_Components(void* pArg) +{ + if (FAILED(Add_Component(g_iStaticLevel, &m_pVIBufferCom))) + { + return E_FAIL; + } + return S_OK; +} + +HRESULT CDialogue_Panel::Ready_Element(void* pArg) +{ + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_UI, nullptr, this, reinterpret_cast(&m_pDialogue_Choice)))) + { + return E_FAIL; + } + Add_Element(TEXT("Dialogue_Choice"), m_pDialogue_Choice); + return S_OK; +} + +CDialogue_Panel* CDialogue_Panel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CDialogue_Panel* pInstance = new CDialogue_Panel(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CDialogue_Panel"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CGameObject* CDialogue_Panel::Clone(void* pArg, CGameObject* pOwner) +{ + CDialogue_Panel* pInstance = new CDialogue_Panel(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CDialogue_Panel"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CDialogue_Panel::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pVIBufferCom); +} + +void CDialogue_Panel::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Editor/Private/GamePlay_Canvas.cpp b/Jusin154_Team3D/Editor/Private/GamePlay_Canvas.cpp index aed21bd50..c453da583 100644 --- a/Jusin154_Team3D/Editor/Private/GamePlay_Canvas.cpp +++ b/Jusin154_Team3D/Editor/Private/GamePlay_Canvas.cpp @@ -48,7 +48,7 @@ HRESULT CGamePlay_Canvas::Initialize(void* pArg) { return E_FAIL; } - Visible(true); + Visible(false); return S_OK; } @@ -155,6 +155,8 @@ HRESULT CGamePlay_Canvas::Ready_Panel(void* pArg) } Add_Panel(TEXT("Ride_Panel"), m_pRide_Panel); + + return S_OK; } diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 6f1b59325..ff84bf860 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -144,6 +144,10 @@ #include "Ride_HpBar.h" #include "Ride_HpSlot.h" +#include "Dialogue_Canvas.h" +#include "Dialogue_Panel.h" +#include "Dialogue_Choice.h" + #include "NPCInteraction.h" #include "Dialogue.h" @@ -1261,8 +1265,21 @@ HRESULT CLoader::Loading_For_UI() { return E_FAIL; } + + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CDialogue_Canvas::Create(m_pDevice, m_pContext)))) + { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CDialogue_Panel::Create(m_pDevice, m_pContext)))) + { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CDialogue_Choice::Create(m_pDevice, m_pContext)))) + { + return E_FAIL; + } - if(FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CNPCInteraction::Create(m_pDevice, m_pContext)))) + if(FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CNPCInteraction::Create(m_pDevice, m_pContext)))) { return E_FAIL; diff --git a/Jusin154_Team3D/Editor/Private/Potion.cpp b/Jusin154_Team3D/Editor/Private/Potion.cpp index b573fd073..ddd100b2a 100644 --- a/Jusin154_Team3D/Editor/Private/Potion.cpp +++ b/Jusin154_Team3D/Editor/Private/Potion.cpp @@ -135,7 +135,7 @@ HRESULT CPotion::Render() return E_FAIL; } - m_pGameInstance->Render_Text(TEXT("UI_size15"), m_strPotion.c_str(), _float2((m_fFontX + m_fX) - m_fFontOffSet, m_fFontY + m_fY), XMVectorSet((208.f / 255.f) * m_fAlpha, (177.f / 255.f) * m_fAlpha, (52.f / 255.f)* m_fAlpha, m_fAlpha)); + m_pGameInstance->Render_Text(TEXT("UI_size15"), m_strPotion.c_str(), _float2((m_fFontX + m_fX) - m_fFontOffSet, m_fFontY - m_fY), XMVectorSet((208.f / 255.f) * m_fAlpha, (177.f / 255.f) * m_fAlpha, (52.f / 255.f)* m_fAlpha, m_fAlpha)); return S_OK; } diff --git a/Jusin154_Team3D/Editor/Private/UI_Manager.cpp b/Jusin154_Team3D/Editor/Private/UI_Manager.cpp index 8510b5409..4b166ef47 100644 --- a/Jusin154_Team3D/Editor/Private/UI_Manager.cpp +++ b/Jusin154_Team3D/Editor/Private/UI_Manager.cpp @@ -8,6 +8,7 @@ #include "Mouse_Cursor.h" #include "CameraLockOn.h" #include "Loding_Canvas.h" +#include "Dialogue_Canvas.h" #include "tinyxml2.h" CUI_Manager::CUI_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) @@ -321,6 +322,11 @@ HRESULT CUI_Manager::Ready_Components(void* pArg) } Add_Canvas(TEXT("SpellLearn_Canvas"), m_pSpellLearn_Canvas); + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, g_iStaticLevel, LAYER_UI, nullptr, this, reinterpret_cast(&m_pDialogue_Canvas)))) { + return E_FAIL; + } + Add_Canvas(TEXT("Dialogue_Canvas"), m_pDialogue_Canvas); + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, g_iStaticLevel, LAYER_UI, nullptr, this, reinterpret_cast(&m_pMouse_Cursor)))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Editor/Public/Dialogue_Canvas.h b/Jusin154_Team3D/Editor/Public/Dialogue_Canvas.h new file mode 100644 index 000000000..6b47e828d --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/Dialogue_Canvas.h @@ -0,0 +1,47 @@ +#pragma once + +#include "Editor_Define.h" +#include "CanvasObject.h" + +NS_BEGIN(Engine) +class CGameObject; +NS_END + +NS_BEGIN(Editor) + +class CDialogue_Canvas final : public CCanvasObject +{ +private: + CDialogue_Canvas(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CDialogue_Canvas(const CDialogue_Canvas& rhs); + virtual ~CDialogue_Canvas() = default; + +public: + virtual void Priority_Update(_float fTimeDelta); + virtual void Update(_float fTimeDelta); + virtual void Late_Update(_float fTimeDelta); + virtual HRESULT Render() override; + virtual _vector Get_WorldPostion() override; + +private: + virtual HRESULT Bind_ShaderResources() override; + virtual HRESULT Ready_Components(void* pArg) override; + virtual HRESULT Ready_Panel(void* pArg) override; + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + +public: + void Clear_Penel(); + +private: + CVIBuffer_Rect* m_pVIBufferCom = { nullptr }; + CGameObject* m_pDialogue_Panel = { nullptr }; + +public: + static CDialogue_Canvas* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; + virtual void Free() override; + void Describe_Entity() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/Dialogue_Choice.h b/Jusin154_Team3D/Editor/Public/Dialogue_Choice.h new file mode 100644 index 000000000..0e9276e17 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/Dialogue_Choice.h @@ -0,0 +1,55 @@ +#pragma once + +#include "Editor_Define.h" +#include "ElementObject.h" + +NS_BEGIN(Editor) + +class CDialogue_Choice final : public CElementObject +{ +private: + CDialogue_Choice(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CDialogue_Choice(const CDialogue_Choice& rhs); + virtual ~CDialogue_Choice() = default; + +public: + virtual void Priority_Update(_float fTimeDelta); + virtual void Update(_float fTimeDelta); + virtual void Late_Update(_float fTimeDelta); + virtual HRESULT Render() override; + virtual _vector Get_WorldPostion() override; + + +private: + virtual HRESULT Bind_ShaderResources() override; + virtual HRESULT Ready_Components(void* pArg) override; + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + +public: + void Mouse_Hover(); + +private: + void Hover(_bool iHover); + +private: + CTexture* m_pDiffuse_TextureCom = { nullptr }; + CTexture* m_pDiffuse_TextureCom1 = { nullptr }; + CTexture* m_pDiffuse_TextureCom2 = { nullptr }; + CShader* m_pShaderCom = { nullptr }; + CVIBuffer_Rect* m_pVIBufferCom = { nullptr }; + + _float4 m_vImagePosi1{}; + _float4 m_vImagePosi2{}; + _float4 m_vImagePosi3{}; + + _int m_iHover{}; + +public: + static CDialogue_Choice* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; + virtual void Free() override; + void Describe_Entity() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/Dialogue_Panel.h b/Jusin154_Team3D/Editor/Public/Dialogue_Panel.h new file mode 100644 index 000000000..a79fa6644 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/Dialogue_Panel.h @@ -0,0 +1,47 @@ +#pragma once + +#include "Editor_Define.h" +#include "PanelObject.h" + +NS_BEGIN(Engine) +class CGameObject; +NS_END + +NS_BEGIN(Editor) + +class CDialogue_Panel final : public CPanelObject +{ +private: + CDialogue_Panel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CDialogue_Panel(const CDialogue_Panel& rhs); + virtual ~CDialogue_Panel() = default; + +public: + virtual void Priority_Update(_float fTimeDelta); + virtual void Update(_float fTimeDelta); + virtual void Late_Update(_float fTimeDelta); + virtual HRESULT Render() override; + virtual _vector Get_WorldPostion() override; + +private: + virtual HRESULT Bind_ShaderResources() override; + virtual HRESULT Ready_Components(void* pArg) override; + virtual HRESULT Ready_Element(void* pArg) override; + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + +private: + CVIBuffer_Rect* m_pVIBufferCom = { nullptr }; + CTexture* m_pDiffuse_TextureCom = { nullptr }; + CShader* m_pShaderCom = { nullptr }; + + CGameObject* m_pDialogue_Choice = { nullptr }; + +public: + static CDialogue_Panel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; + virtual void Free() override; + void Describe_Entity() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/Editor_Define.h b/Jusin154_Team3D/Editor/Public/Editor_Define.h index 5001520c7..1842ef9b0 100644 --- a/Jusin154_Team3D/Editor/Public/Editor_Define.h +++ b/Jusin154_Team3D/Editor/Public/Editor_Define.h @@ -44,7 +44,7 @@ namespace Editor ENEMY_HPBAR, BOSS_HPBAR, QUEST_BORDER, QUEST_INFO, QUEST_STATUS, BROOMSTICK, SPELL_LEARN, SPELLLEARNCOLOR, SPELLLEARNBOOSTER, NPCINTERACTION, CANVASFADE, FLAGWAVE, BROOMCIRCLE, RIDE_INFO_KEY, RIDE_INFO, RIDE_HPSLOT, BOOSTERGAUGE, - BOOSTERHPBAR, + BOOSTERHPBAR, DIALOGUECHOICE, ENEMY_DETECTION, INTERACTION_OBJECT, INTERACTION_NPC, BROOMTARGETGATE, END }; enum class SHADER_PASS_INSTANCE_MODEL { DEFAULT, NON_NOMALMAP, BLUR, WEIGHTBLEND, NON_WORLD, NON_WORLD_BLUR, BLEND, BLEND_NOWORLD, BLOOM, BLOOM_NOWORLD, BLUR_NO_EMMISVE, BLUR_NO_WORLD_NO_EMISSIVE, WEIGHTBLEND_FOR_BLEND, DEPTH_STOP, WB_CULLING, SCREEN_FX , DISTORTION , NONPOS , NONPOS_BLUR, BLUR_MESH, BLUR_CULLING , BLUR_CULLING_NO_EMISSIVE, BLOOM_CULLING , DEFAULT_NONPOS , NONWB_NONPOS, DECAL, DECAL_WB, DECAL_BLUR, BLEND_CULLING, DECAL_BLEND, END}; diff --git a/Jusin154_Team3D/Editor/Public/GamePlay_Canvas.h b/Jusin154_Team3D/Editor/Public/GamePlay_Canvas.h index 6db90f1fb..30443d3e3 100644 --- a/Jusin154_Team3D/Editor/Public/GamePlay_Canvas.h +++ b/Jusin154_Team3D/Editor/Public/GamePlay_Canvas.h @@ -42,6 +42,7 @@ class CGamePlay_Canvas final : public CCanvasObject CGameObject* m_pEnemy_Panel = { nullptr }; CGameObject* m_pBroom_Panel = { nullptr }; CGameObject* m_pRide_Panel = { nullptr }; + CGameObject* m_pDialogue_Panel = { nullptr }; _bool m_bRide = { false }; diff --git a/Jusin154_Team3D/Editor/Public/UI_Manager.h b/Jusin154_Team3D/Editor/Public/UI_Manager.h index 4953e8c16..49caec491 100644 --- a/Jusin154_Team3D/Editor/Public/UI_Manager.h +++ b/Jusin154_Team3D/Editor/Public/UI_Manager.h @@ -59,6 +59,7 @@ class CUI_Manager final : public CUIObject CGameObject* m_pLoding_Canvas= { nullptr }; CGameObject* m_pQuest_Canves= { nullptr }; CGameObject* m_pSpellLearn_Canvas = { nullptr }; + CGameObject* m_pDialogue_Canvas = { nullptr }; CGameObject* m_pMouse_Cursor = { nullptr }; CGameObject* m_pCamera_LockOn = { nullptr }; _bool m_bCanvas_Change = { false }; diff --git a/Jusin154_Team3D/Engine/Private/ElementObject.cpp b/Jusin154_Team3D/Engine/Private/ElementObject.cpp index f06ff23ee..f0dca55bb 100644 --- a/Jusin154_Team3D/Engine/Private/ElementObject.cpp +++ b/Jusin154_Team3D/Engine/Private/ElementObject.cpp @@ -43,18 +43,28 @@ void CElementObject::Update(_float fTimeDelta) m_vScale = _float3(m_fSizeX, m_fSizeY, 1.f); m_pTransformCom->Set_Scale(m_vScale); - m_pTransformCom->Set_State(STATE::POSITION, XMVectorSet( - m_fX + m_pOwner->Get_WorldPostion().m128_f32[0], - m_fY + m_pOwner->Get_WorldPostion().m128_f32[1], - m_fSortZ, 1.f)); + // 1. 최종 월드 좌표 계산 (부모 좌표 + 내 로컬 좌표) + _float fFinalX = m_fX + m_pOwner->Get_WorldPostion().m128_f32[0]; + _float fFinalY = m_fY + m_pOwner->Get_WorldPostion().m128_f32[1]; - m_pRect = - { - long((m_fX + m_pOwner->Get_WorldPostion().m128_f32[0]) - m_fSizeX * 0.5f), - long((m_fY + m_pOwner->Get_WorldPostion().m128_f32[1]) - m_fSizeY * 0.5f), - long((m_fX + m_pOwner->Get_WorldPostion().m128_f32[0]) + m_fSizeX * 0.5f), - long((m_fY + m_pOwner->Get_WorldPostion().m128_f32[1]) + m_fSizeY * 0.5f) - }; + // 2. Transform 업데이트 + m_pTransformCom->Set_State(STATE::POSITION, XMVectorSet(fFinalX, fFinalY, m_fSortZ, 1.f)); + + // 3. m_pRect 업데이트 (마우스 호버용) + // float 오차를 줄이기 위해 floor(내림) 또는 round(반올림)를 사용하는 것이 좋습니다. + _float fLeft = fFinalX - m_fSizeX * 0.5f; + _float fRight = fFinalX + m_fSizeX * 0.5f; + _float fTop = fFinalY - m_fSizeY * 0.5f; + _float fBottom = fFinalY + m_fSizeY * 0.5f; + + m_pRect.left = (long)fLeft; + m_pRect.right = (long)fRight; + + // 중요: 현재 좌표계가 Y축이 위로 갈수록 +인 수학 좌표계라면, + // 실제 화면상 '위'에 해당하는 좌표값(fTop)이 숫자가 더 작아야 PtInRect가 작동합니다. + // 만약 살짝 어긋난다면 여기서 min, max로 안전하게 잡아줍니다. + m_pRect.top = (long)min(fTop, fBottom); + m_pRect.bottom = (long)max(fTop, fBottom); m_fCurrent_Position = _float4(m_fX, m_fY, 0.f, 1.f); m_vLerp_Position = _float4(m_fLerpX, m_fLerpY, 0.f, 1.f);