diff --git a/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl b/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl index 3ac1e5d5d..c4aaf44f6 100644 --- a/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl +++ b/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl @@ -66,11 +66,15 @@ Texture2D g_MaskingTexture; int g_iHover; int g_iClick; int g_iColor; +int g_Count; int g_iStep1 = 0; int g_iStep2 = 0; int g_iStep3 = 0; +float2 g_Trail[1000]; + + struct VS_IN { float3 vPosition : POSITION; @@ -1795,33 +1799,45 @@ PS_OUT PS_SpellLearnColor(PS_IN In) Color = tex; Color.rgb *= tex1.rgb; - - float2 rectPos = g_fPosition; + + float2 rectPos = g_fPosition - float2(256.f,259.f); float2 rectSize = g_fCurrent_Size; float2 itemPos = g_fItemPosition1; float2 itemSize = g_fItemImageSizes1; - float x0 = max(rectPos.x, itemPos.x); - float x1 = min(rectPos.x + rectSize.x, itemPos.x + itemSize.x); - float y0 = max(rectPos.y, itemPos.y); - float y1 = min(rectPos.y + rectSize.y, itemPos.y + itemSize.y); + float2 pixelPos; + pixelPos.x = rectPos.x + In.vTexcoord.x * rectSize.x; + pixelPos.y = rectPos.y + (1.0f - In.vTexcoord.y) * rectSize.y; - float uMin = (x0 - rectPos.x) / rectSize.x; - float uMax = (x1 - rectPos.x) / rectSize.x; - float vMin = (y0 - rectPos.y) / rectSize.y; - float vMax = (y1 - rectPos.y) / rectSize.y; - - vMin = 1.0f - vMin; - vMax = 1.0f - vMax; - - if (In.vTexcoord.x >= min(uMin, uMax) && In.vTexcoord.x <= max(uMin, uMax) && - In.vTexcoord.y >= min(vMin, vMax) && In.vTexcoord.y <= max(vMin, vMax)) + if (pixelPos.x >= itemPos.x && + pixelPos.x <= itemPos.x + itemSize.x && + pixelPos.y >= itemPos.y && + pixelPos.y <= itemPos.y + itemSize.y) { Color.rgb = float3(0.f, 0.f, 1.f); } - - Color.a *= Alpha; + + for (int i = 0; i < g_Count; ++i) + { + float2 trailTopLeft = g_Trail[i]; + float2 trailCenter = trailTopLeft + itemSize / 2.0f; + + float halfWidth = itemSize.x / 2.0f + 6.f; + float halfHeight = itemSize.y / 2.0f + 6.f; + + if (pixelPos.x >= trailCenter.x - halfWidth && + pixelPos.x <= trailCenter.x + halfWidth && + pixelPos.y >= trailCenter.y - halfHeight && + pixelPos.y <= trailCenter.y + halfHeight) + { + Color.rgb = float3(0.f, 144.f, 248.f) / 255.f; + break; + } + } + + Color. + a *= Alpha; Out.vColor = Color; return Out; } diff --git a/Jusin154_Team3D/Client/Private/SpellLearn_MovePointer.cpp b/Jusin154_Team3D/Client/Private/SpellLearn_MovePointer.cpp index 85ca12265..4e817c981 100644 --- a/Jusin154_Team3D/Client/Private/SpellLearn_MovePointer.cpp +++ b/Jusin154_Team3D/Client/Private/SpellLearn_MovePointer.cpp @@ -57,7 +57,7 @@ void CSpellLearn_MovePointer::Set_SpellLearn(_int Index) m_fY = m_pInfoInstance->Get_SpellLearn(Index).fStartPosition.y; } -void CSpellLearn_MovePointer::Line(_float fTime) +void CSpellLearn_MovePointer::Line(_float fTime, _float2 fMouse) { m_vLerp_Position = m_MoveLine[m_iCurrentLine]; @@ -116,6 +116,17 @@ void CSpellLearn_MovePointer::Update(_float fTimeDelta) } } + POINT ptMouse{}; + GetCursorPos(&ptMouse); + ScreenToClient(g_hWnd, &ptMouse); + _float2 fMouse{}; + fMouse.x = ptMouse.x - (g_iWinSizeX * 0.5f); + fMouse.y = -ptMouse.y + (g_iWinSizeY * 0.5f); + + _float2 fFinalMouse{}; + fFinalMouse.x = fMouse.x - m_fX; + fFinalMouse.y = fMouse.y - m_fY; + if (m_pGameInstance->Key_Down(DIK_L)) { m_bMoveStart = true; @@ -123,21 +134,10 @@ void CSpellLearn_MovePointer::Update(_float fTimeDelta) if (m_bMoveStart == true) { - Line(fTimeDelta); + Line(fTimeDelta, fMouse); } - POINT ptMouse{}; - GetCursorPos(&ptMouse); - ScreenToClient(g_hWnd, &ptMouse); - _float2 fMouse; - fMouse.x = ptMouse.x - (g_iWinSizeX * 0.5f); - fMouse.y = -ptMouse.y + (g_iWinSizeY * 0.5f); - - fMouse.x = fMouse.x - m_fX; - fMouse.y = fMouse.y - m_fY; - - - m_fAngle = atan2(-fMouse.x, fMouse.y); + m_fAngle = atan2(-fFinalMouse.x, fFinalMouse.y); m_fTime += fTimeDelta * m_fTimeMult; __super::Update(fTimeDelta); diff --git a/Jusin154_Team3D/Client/Public/SpellLearn_MovePointer.h b/Jusin154_Team3D/Client/Public/SpellLearn_MovePointer.h index a467bb9b9..b2754a919 100644 --- a/Jusin154_Team3D/Client/Public/SpellLearn_MovePointer.h +++ b/Jusin154_Team3D/Client/Public/SpellLearn_MovePointer.h @@ -34,7 +34,7 @@ class CSpellLearn_MovePointer final : public CElementObject public: void Set_SpellLearn(_int Index); private: - void Line(_float fTime); + void Line(_float fTime, _float2 fMouse); private: diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/UI/SpellLearn.xml b/Jusin154_Team3D/Editor/Bin/Resources/Data/UI/SpellLearn.xml index a5a168e36..a09c28f29 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/UI/SpellLearn.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/UI/SpellLearn.xml @@ -2,24 +2,225 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl index 3ac1e5d5d..c4aaf44f6 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl @@ -66,11 +66,15 @@ Texture2D g_MaskingTexture; int g_iHover; int g_iClick; int g_iColor; +int g_Count; int g_iStep1 = 0; int g_iStep2 = 0; int g_iStep3 = 0; +float2 g_Trail[1000]; + + struct VS_IN { float3 vPosition : POSITION; @@ -1795,33 +1799,45 @@ PS_OUT PS_SpellLearnColor(PS_IN In) Color = tex; Color.rgb *= tex1.rgb; - - float2 rectPos = g_fPosition; + + float2 rectPos = g_fPosition - float2(256.f,259.f); float2 rectSize = g_fCurrent_Size; float2 itemPos = g_fItemPosition1; float2 itemSize = g_fItemImageSizes1; - float x0 = max(rectPos.x, itemPos.x); - float x1 = min(rectPos.x + rectSize.x, itemPos.x + itemSize.x); - float y0 = max(rectPos.y, itemPos.y); - float y1 = min(rectPos.y + rectSize.y, itemPos.y + itemSize.y); + float2 pixelPos; + pixelPos.x = rectPos.x + In.vTexcoord.x * rectSize.x; + pixelPos.y = rectPos.y + (1.0f - In.vTexcoord.y) * rectSize.y; - float uMin = (x0 - rectPos.x) / rectSize.x; - float uMax = (x1 - rectPos.x) / rectSize.x; - float vMin = (y0 - rectPos.y) / rectSize.y; - float vMax = (y1 - rectPos.y) / rectSize.y; - - vMin = 1.0f - vMin; - vMax = 1.0f - vMax; - - if (In.vTexcoord.x >= min(uMin, uMax) && In.vTexcoord.x <= max(uMin, uMax) && - In.vTexcoord.y >= min(vMin, vMax) && In.vTexcoord.y <= max(vMin, vMax)) + if (pixelPos.x >= itemPos.x && + pixelPos.x <= itemPos.x + itemSize.x && + pixelPos.y >= itemPos.y && + pixelPos.y <= itemPos.y + itemSize.y) { Color.rgb = float3(0.f, 0.f, 1.f); } - - Color.a *= Alpha; + + for (int i = 0; i < g_Count; ++i) + { + float2 trailTopLeft = g_Trail[i]; + float2 trailCenter = trailTopLeft + itemSize / 2.0f; + + float halfWidth = itemSize.x / 2.0f + 6.f; + float halfHeight = itemSize.y / 2.0f + 6.f; + + if (pixelPos.x >= trailCenter.x - halfWidth && + pixelPos.x <= trailCenter.x + halfWidth && + pixelPos.y >= trailCenter.y - halfHeight && + pixelPos.y <= trailCenter.y + halfHeight) + { + Color.rgb = float3(0.f, 144.f, 248.f) / 255.f; + break; + } + } + + Color. + a *= Alpha; Out.vColor = Color; return Out; } diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Textures/SpellUnlock/UI_T_SpellMinigame_SpeedBurstDropBack.png b/Jusin154_Team3D/Editor/Bin/Resources/Textures/SpellUnlock/UI_T_SpellMinigame_SpeedBurstDropBack.png new file mode 100644 index 000000000..4e4b60dda Binary files /dev/null and b/Jusin154_Team3D/Editor/Bin/Resources/Textures/SpellUnlock/UI_T_SpellMinigame_SpeedBurstDropBack.png differ diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj b/Jusin154_Team3D/Editor/Default/Editor.vcxproj index 1980633a3..03ef1f6ee 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj @@ -197,7 +197,7 @@ call Update_Shaders.bat - + @@ -422,7 +422,7 @@ call Update_Shaders.bat - + diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index 3eb9266b7..b90865562 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -627,11 +627,11 @@ {eef1db06-8a9f-42b4-93e2-cc29de2b275d} - + {6e769435-83c4-4f64-b306-1b8c5f2d228d} - + {54a92f0d-26f1-49bf-a13b-ab11995968c7} @@ -1260,8 +1260,8 @@ 50.UI\SpellLearn_Data - - 50.UI\SpellLearn_Canvas\SpellLearn_Panel\SPellLeam_SpeedPointer + + 50.UI\SpellLearn_Canvas\SpellLearn_Panel\SPellLeam_ChaserPointer @@ -1891,8 +1891,8 @@ 50.UI\SpellLearn_Data - - 50.UI\SpellLearn_Canvas\SpellLearn_Panel\SPellLeam_SpeedPointer + + 50.UI\SpellLearn_Canvas\SpellLearn_Panel\SPellLeam_ChaserPointer diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 879703ab6..12f65afd1 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -118,6 +118,7 @@ #include "SpellLearn_Name.h" #include "SpellLearn.h" #include "SpellLearn_MovePointer.h" +#include "SPellLeam_ChaserPointer.h" #include "IMGUIUI.h" @@ -1233,6 +1234,10 @@ HRESULT CLoader::Loading_For_UI() { return E_FAIL; } + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CSPellLeam_ChaserPointer::Create(m_pDevice, m_pContext)))) + { + return E_FAIL; + } if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CIMGUIUI::Create(m_pDevice, m_pContext)))) { diff --git a/Jusin154_Team3D/Editor/Private/SPellLeam_ChaserPointer.cpp b/Jusin154_Team3D/Editor/Private/SPellLeam_ChaserPointer.cpp new file mode 100644 index 000000000..aceebd8a7 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/SPellLeam_ChaserPointer.cpp @@ -0,0 +1,302 @@ +#include "pch.h" +#include "SPellLeam_ChaserPointer.h" +#include "GameInstance.h" +#include "SpellLearn_MovePointer.h" + +CSPellLeam_ChaserPointer::CSPellLeam_ChaserPointer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + :CElementObject(pDevice, pContext) +{ +} + +CSPellLeam_ChaserPointer::CSPellLeam_ChaserPointer(const CSPellLeam_ChaserPointer& rhs) + :CElementObject(rhs) +{ +} + +HRESULT CSPellLeam_ChaserPointer::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CSPellLeam_ChaserPointer::Initialize(void* pArg) +{ + CUIObject::UIOBJECT_DESC Desc{}; + + Desc.fX = 476.f; + Desc.fY = -253.f; + Desc.fSizeX = 32.f; + Desc.fSizeY = 32.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 = 5.f; + m_fMoveSpeed = 140.f; + Set_SpellLearn(0); + Visible(false); + return S_OK; +} + +void CSPellLeam_ChaserPointer::Priority_Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + __super::Priority_Update(fTimeDelta); +} + +void CSPellLeam_ChaserPointer::Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + if (m_bFadeIn == true) + { + if (m_fAlpha <= 1.f) + { + m_fAlpha += fTimeDelta * m_fAlphaTime; + } + + if (m_fAlpha >= 1.f) + { + m_bFadeIn = false; + m_fAlpha = 1.f; + } + } + + if (m_bFadeOut == true) + { + if (m_fAlpha >= 0.f) + m_fAlpha -= fTimeDelta * m_fAlphaTime;; + + if (m_fAlpha <= 0.f) + { + m_bFadeOut = false; + m_fAlpha = 0.f; + } + } + + POINT ptMouse{}; + GetCursorPos(&ptMouse); + ScreenToClient(g_hWnd, &ptMouse); + _float2 fMouse{}; + fMouse.x = ptMouse.x - (g_iWinSizeX * 0.5f); + fMouse.y = -ptMouse.y + (g_iWinSizeY * 0.5f); + + _float2 fFinalMouse{}; + fFinalMouse.x = fMouse.x - m_fX; + fFinalMouse.y = fMouse.y - m_fY; + + if (m_pGameInstance->Key_Down(DIK_L)) + { + m_bMoveStart = true; + } + + if (m_bMoveStart == true) + { + m_fTime += fTimeDelta * m_fTimeMult; + if (m_fTime >= 1.f) + { + m_bHover = true; + Line(fTimeDelta); + } + } + + if (m_bHover == true) + { + _float Dir = XMVectorGetX( + XMVector3Length( + XMVectorSubtract(m_pPointer->Get_Current_Position(), m_fCurrent_Position))); + + if (Dir <= 16.f) + { + _int a = 10; + } + } + + m_fAngle = atan2(-fFinalMouse.x, fFinalMouse.y); + __super::Update(fTimeDelta); +} + +void CSPellLeam_ChaserPointer::Late_Update(_float fTimeDelta) +{ + if (!__super::Chack_Visible()) + { + return; + } + if (m_bVisible) { + if (m_bHover == true) + { + m_pGameInstance->Add_RenderGroup(RENDER::UI, this); + } + __super::Late_Update(fTimeDelta); + } +} + +HRESULT CSPellLeam_ChaserPointer::Render() +{ + if (FAILED(Bind_ShaderResources())) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_UIEDITOR::DEFAULT)))) { + return E_FAIL; + } + if (FAILED(m_pVIBufferCom->Bind_Resources())) { + return E_FAIL; + } + if (FAILED(m_pVIBufferCom->Render())) { + return E_FAIL; + } + + return S_OK; +} + +_vector CSPellLeam_ChaserPointer::Get_WorldPostion() +{ + return m_pTransformCom->Get_State(STATE::POSITION); +} + +void CSPellLeam_ChaserPointer::Set_SpellLearn(_int Index) +{ + m_bHover = false; + m_bMoveStart = false; + m_fTime = 0.f; + m_iLineIndex = _int(static_cast(m_pOwner)->Get_Learninfo(Index).Lines.size()); + m_MoveLine = static_cast(m_pOwner)->Get_Learninfo(Index).Lines; + m_iCurrentLine = 0; + m_fX = static_cast(m_pOwner)->Get_Learninfo(Index).fStartPosition.x; + m_fY = static_cast(m_pOwner)->Get_Learninfo(Index).fStartPosition.y; +} + +void CSPellLeam_ChaserPointer::Set_Pointer(CSpellLearn_MovePointer* Pointer) +{ + m_pPointer = Pointer; +} + +void CSPellLeam_ChaserPointer::Line(_float fTime) +{ + m_vLerp_Position = m_MoveLine[m_iCurrentLine]; + + if (Start_Lerp(fTime) == true) + { + if (m_iCurrentLine < m_iLineIndex - 1) + { + ++m_iCurrentLine; + } + else + { + m_bMoveStart = false; + } + } + +} + +HRESULT CSPellLeam_ChaserPointer::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_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; + } + return S_OK; +} + +HRESULT CSPellLeam_ChaserPointer::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_UI_T_SpellMinigame_SpeedBurstDropBack"), reinterpret_cast(&m_pDiffuse_TextureCom), nullptr))) + { + return E_FAIL; + } + if (FAILED(Add_Asset_Component(g_iStaticLevel, FX_UIEDITOR, (CComponent**)&m_pShaderCom, nullptr))) + { + return E_FAIL; + } + + return S_OK; +} + +CSPellLeam_ChaserPointer* CSPellLeam_ChaserPointer::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CSPellLeam_ChaserPointer* pInstance = new CSPellLeam_ChaserPointer(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CSPellLeam_ChaserPointer"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CGameObject* CSPellLeam_ChaserPointer::Clone(void* pArg, CGameObject* pOwner) +{ + CSPellLeam_ChaserPointer* pInstance = new CSPellLeam_ChaserPointer(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CSPellLeam_ChaserPointer"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CSPellLeam_ChaserPointer::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pDiffuse_TextureCom); + SAFE_RELEASE(m_pShaderCom); + SAFE_RELEASE(m_pVIBufferCom); +} + +void CSPellLeam_ChaserPointer::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Editor/Private/SPellLeam_SpeedPointer.cpp b/Jusin154_Team3D/Editor/Private/SPellLeam_SpeedPointer.cpp deleted file mode 100644 index de1ee7712..000000000 --- a/Jusin154_Team3D/Editor/Private/SPellLeam_SpeedPointer.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "pch.h" -#include "SPellLeam_SpeedPointer.h" -#include "GameInstance.h" - -CSPellLeam_SpeedPointer::CSPellLeam_SpeedPointer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) - :CElementObject(pDevice, pContext) -{ -} - -CSPellLeam_SpeedPointer::CSPellLeam_SpeedPointer(const CSPellLeam_SpeedPointer& rhs) - :CElementObject(rhs) -{ -} - -HRESULT CSPellLeam_SpeedPointer::Initialize_Prototype() -{ - return S_OK; -} - -HRESULT CSPellLeam_SpeedPointer::Initialize(void* pArg) -{ - CUIObject::UIOBJECT_DESC Desc{}; - - Desc.fX = 476.f; - Desc.fY = -253.f; - Desc.fSizeX = 32.f; - Desc.fSizeY = 32.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 = 5.f; - m_fMoveSpeed = 15.f; - m_fAngle = XMConvertToRadians(0); - Visible(false); - return S_OK; -} - -void CSPellLeam_SpeedPointer::Priority_Update(_float fTimeDelta) -{ -} - -void CSPellLeam_SpeedPointer::Update(_float fTimeDelta) -{ -} - -void CSPellLeam_SpeedPointer::Late_Update(_float fTimeDelta) -{ -} - -HRESULT CSPellLeam_SpeedPointer::Render() -{ - return S_OK; -} - -_vector CSPellLeam_SpeedPointer::Get_WorldPostion() -{ - return _vector(); -} - -HRESULT CSPellLeam_SpeedPointer::Bind_ShaderResources() -{ - return S_OK; -} - -HRESULT CSPellLeam_SpeedPointer::Ready_Components(void* pArg) -{ - return S_OK; -} - -CSPellLeam_SpeedPointer* CSPellLeam_SpeedPointer::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) -{ - return nullptr; -} - -CGameObject* CSPellLeam_SpeedPointer::Clone(void* pArg, CGameObject* pOwner) -{ - return nullptr; -} - -void CSPellLeam_SpeedPointer::Free() -{ -} - -void CSPellLeam_SpeedPointer::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Private/SpellLearn.cpp b/Jusin154_Team3D/Editor/Private/SpellLearn.cpp index 8a0468f02..19b1d6244 100644 --- a/Jusin154_Team3D/Editor/Private/SpellLearn.cpp +++ b/Jusin154_Team3D/Editor/Private/SpellLearn.cpp @@ -40,6 +40,7 @@ HRESULT CSpellLearn::Initialize(void* pArg) m_fTimeMult = 3.f; m_fAlpha = 1.f; m_fAlphaTime = 5.f; + m_iTrailIndex = 0; Change_Image(0); Visible(false); return S_OK; @@ -86,7 +87,27 @@ void CSpellLearn::Update(_float fTimeDelta) } } - m_fTime += fTimeDelta * m_fTimeMult; + if (m_pPointer != nullptr) + { + if (m_pPointer->Get_bMoveStart() == true) + { + m_vPointerPosition = m_pPointer->Get_Position(); + m_vPointerScale = m_pPointer->Get_Current_Size(); + + m_fTime += fTimeDelta * m_fTimeMult; + if (m_fTime >= 1.f) + { + m_Trail.push_back(m_vPointerPosition); + m_iTrailIndex++; + } + } + else + { + + } + } + + __super::Update(fTimeDelta); } @@ -98,11 +119,7 @@ void CSpellLearn::Late_Update(_float fTimeDelta) } if (m_bVisible) { if (m_pPointer != nullptr) - { - m_vPointerPosition = m_pPointer->Get_Position(); - m_vPointerScale = m_pPointer->Get_Current_Size(); - } - m_pGameInstance->Add_RenderGroup(RENDER::UI, this); + m_pGameInstance->Add_RenderGroup(RENDER::UI, this); __super::Late_Update(fTimeDelta); } } @@ -188,7 +205,18 @@ HRESULT CSpellLearn::Bind_ShaderResources() { return E_FAIL; } - + if (FAILED(m_pShaderCom->Bind_RawValue("g_Trail", m_Trail.data(), sizeof(_float2) * _uint(m_Trail.size())))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_Count", &m_iTrailIndex, sizeof(_int)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_iHover", &m_bHover, sizeof(_bool)))) + { + return E_FAIL; + } return S_OK; } @@ -216,9 +244,12 @@ HRESULT CSpellLearn::Ready_Components(void* pArg) HRESULT CSpellLearn::Change_Image(_int SpellID) { + m_Trail.clear(); + m_Trail.push_back(_float2(0.f,0.f)); + m_iTrailIndex = 0; _wstring pName = TEXT("Prototype_Texture_"); _wstring pImageName = pName + static_cast(m_pOwner)->Get_Learninfo(SpellID).pImageName; - + m_MoveLine = static_cast(m_pOwner)->Get_Learninfo(SpellID).Lines; if (m_pDiffuse_TextureCom) { Remove_Component(); diff --git a/Jusin154_Team3D/Editor/Private/SpellLearn_MovePointer.cpp b/Jusin154_Team3D/Editor/Private/SpellLearn_MovePointer.cpp index 2c9c95b4c..9376cc97d 100644 --- a/Jusin154_Team3D/Editor/Private/SpellLearn_MovePointer.cpp +++ b/Jusin154_Team3D/Editor/Private/SpellLearn_MovePointer.cpp @@ -39,7 +39,7 @@ HRESULT CSpellLearn_MovePointer::Initialize(void* pArg) m_fTimeMult = 3.f; m_fAlpha = 1.f; m_fAlphaTime = 5.f; - m_fMoveSpeed = 15.f; + m_fMoveSpeed = 130.f; Set_SpellLearn(0); m_fAngle = XMConvertToRadians(0); Visible(false); @@ -48,6 +48,7 @@ HRESULT CSpellLearn_MovePointer::Initialize(void* pArg) void CSpellLearn_MovePointer::Set_SpellLearn(_int Index) { + m_bMoveStart = false; m_iLineIndex = _int(static_cast(m_pOwner)->Get_Learninfo(Index).Lines.size()); m_MoveLine = static_cast(m_pOwner)->Get_Learninfo(Index).Lines; m_iCurrentLine = 0; @@ -55,15 +56,26 @@ void CSpellLearn_MovePointer::Set_SpellLearn(_int Index) m_fY = static_cast(m_pOwner)->Get_Learninfo(Index).fStartPosition.y; } -void CSpellLearn_MovePointer::Line(_float fTime) +_int CSpellLearn_MovePointer::Get_SpellTrail() +{ + return m_iCurrentLine; +} + +_bool CSpellLearn_MovePointer::Get_bMoveStart() +{ + return m_bMoveStart; +} + +void CSpellLearn_MovePointer::Line(_float fTime, _float2 fMouse) { m_vLerp_Position = m_MoveLine[m_iCurrentLine]; - if (Start_Lerp(m_fMoveSpeed * fTime) == true) + if (Start_Lerp_Speed(fTime, fMouse) == true) { if (m_iCurrentLine < m_iLineIndex - 1) { ++m_iCurrentLine; + m_fPerPosition = _float2(m_MoveLine[m_iCurrentLine - 1].m128_f32[0], m_MoveLine[m_iCurrentLine - 1].m128_f32[1]); } else { @@ -114,6 +126,17 @@ void CSpellLearn_MovePointer::Update(_float fTimeDelta) } } + POINT ptMouse{}; + GetCursorPos(&ptMouse); + ScreenToClient(g_hWnd, &ptMouse); + _float2 fMouse{}; + fMouse.x = ptMouse.x - (g_iWinSizeX * 0.5f); + fMouse.y = -ptMouse.y + (g_iWinSizeY * 0.5f); + + _float2 fFinalMouse{}; + fFinalMouse.x = fMouse.x - m_fX; + fFinalMouse.y = fMouse.y - m_fY; + if (m_pGameInstance->Key_Down(DIK_L)) { m_bMoveStart = true; @@ -121,21 +144,10 @@ void CSpellLearn_MovePointer::Update(_float fTimeDelta) if (m_bMoveStart == true) { - Line(fTimeDelta); + Line(fTimeDelta, fMouse); } - POINT ptMouse{}; - GetCursorPos(&ptMouse); - ScreenToClient(g_hWnd, &ptMouse); - _float2 fMouse; - fMouse.x = ptMouse.x - (g_iWinSizeX * 0.5f); - fMouse.y = -ptMouse.y + (g_iWinSizeY * 0.5f); - - fMouse.x = fMouse.x - m_fX; - fMouse.y = fMouse.y - m_fY; - - - m_fAngle = atan2(-fMouse.x, fMouse.y); + m_fAngle = atan2(-fFinalMouse.x, fFinalMouse.y); m_fTime += fTimeDelta * m_fTimeMult; __super::Update(fTimeDelta); diff --git a/Jusin154_Team3D/Editor/Private/SpellLearn_Panel.cpp b/Jusin154_Team3D/Editor/Private/SpellLearn_Panel.cpp index 928db31af..3eb0832a6 100644 --- a/Jusin154_Team3D/Editor/Private/SpellLearn_Panel.cpp +++ b/Jusin154_Team3D/Editor/Private/SpellLearn_Panel.cpp @@ -4,6 +4,7 @@ #include "SpellLearn_Name.h" #include "SpellLearn.h" #include "SpellLearn_MovePointer.h" +#include "SPellLeam_ChaserPointer.h" #include "SpellLearn_Data.h" CSpellLearn_Panel::CSpellLearn_Panel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) @@ -46,6 +47,7 @@ HRESULT CSpellLearn_Panel::Initialize(void* pArg) m_fSortZ = 0.05f; m_fDelayTime = 1.f; static_cast(m_pSpellLearn)->Set_Pointer(static_cast(m_pSpellLearn_MovePointer)); + static_cast(m_pSPellLeam_ChaserPointer)->Set_Pointer(static_cast(m_pSpellLearn_MovePointer)); Visible(true); ElementAllVisible(true); return S_OK; @@ -84,6 +86,7 @@ void CSpellLearn_Panel::Update(_float fTimeDelta) } static_cast(m_pSpellLearn)->Change_Image(Index); static_cast(m_pSpellLearn_MovePointer)->Set_SpellLearn(Index); + static_cast(m_pSPellLeam_ChaserPointer)->Set_SpellLearn(Index); static_cast(m_pSpellLearn_Name)->Set_Name(Index); } @@ -213,6 +216,12 @@ HRESULT CSpellLearn_Panel::Ready_Element(void* pArg) } Add_Element(TEXT("SpellLearn_MovePointer"), m_pSpellLearn_MovePointer); + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_UI, nullptr, this, reinterpret_cast(&m_pSPellLeam_ChaserPointer)))) + { + return E_FAIL; + } + Add_Element(TEXT("SPellLeam_ChaserPointer"), m_pSPellLeam_ChaserPointer); + return S_OK; } diff --git a/Jusin154_Team3D/Editor/Public/SPellLeam_SpeedPointer.h b/Jusin154_Team3D/Editor/Public/SPellLeam_ChaserPointer.h similarity index 56% rename from Jusin154_Team3D/Editor/Public/SPellLeam_SpeedPointer.h rename to Jusin154_Team3D/Editor/Public/SPellLeam_ChaserPointer.h index a2c881d6d..eb92440ff 100644 --- a/Jusin154_Team3D/Editor/Public/SPellLeam_SpeedPointer.h +++ b/Jusin154_Team3D/Editor/Public/SPellLeam_ChaserPointer.h @@ -5,12 +5,12 @@ NS_BEGIN(Editor) -class CSPellLeam_SpeedPointer final : public CElementObject +class CSPellLeam_ChaserPointer final : public CElementObject { private: - CSPellLeam_SpeedPointer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); - CSPellLeam_SpeedPointer(const CSPellLeam_SpeedPointer& rhs); - virtual ~CSPellLeam_SpeedPointer() = default; + CSPellLeam_ChaserPointer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CSPellLeam_ChaserPointer(const CSPellLeam_ChaserPointer& rhs); + virtual ~CSPellLeam_ChaserPointer() = default; public: virtual void Priority_Update(_float fTimeDelta); @@ -25,13 +25,29 @@ class CSPellLeam_SpeedPointer final : public CElementObject virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; +public: + void Set_SpellLearn(_int Index); + void Set_Pointer(class CSpellLearn_MovePointer* Pointer); + +private: + void Line(_float fTime); + + private: CTexture* m_pDiffuse_TextureCom = { nullptr }; CShader* m_pShaderCom = { nullptr }; CVIBuffer_Rect* m_pVIBufferCom = { nullptr }; + class CSpellLearn_MovePointer* m_pPointer = { nullptr }; + + + _bool m_bMoveStart = { false }; + + _int m_iLineIndex{}; + _int m_iCurrentLine{}; + vector<_vector> m_MoveLine; public: - static CSPellLeam_SpeedPointer* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + static CSPellLeam_ChaserPointer* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; virtual void Free() override; void Describe_Entity() override; diff --git a/Jusin154_Team3D/Editor/Public/SpellLearn.h b/Jusin154_Team3D/Editor/Public/SpellLearn.h index d7d9db4b4..2a82b0b7e 100644 --- a/Jusin154_Team3D/Editor/Public/SpellLearn.h +++ b/Jusin154_Team3D/Editor/Public/SpellLearn.h @@ -38,6 +38,12 @@ class CSpellLearn final : public CElementObject _float2 m_vPointerPosition{}; _float3 m_vPointerScale{}; + + _int m_iIndex{}; + vector<_float2> m_Trail; + _int m_iTrailIndex{}; + vector<_vector> m_MoveLine; + public: static CSpellLearn* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; diff --git a/Jusin154_Team3D/Editor/Public/SpellLearn_MovePointer.h b/Jusin154_Team3D/Editor/Public/SpellLearn_MovePointer.h index b3c0b4b60..57d2677f8 100644 --- a/Jusin154_Team3D/Editor/Public/SpellLearn_MovePointer.h +++ b/Jusin154_Team3D/Editor/Public/SpellLearn_MovePointer.h @@ -27,9 +27,10 @@ class CSpellLearn_MovePointer final : public CElementObject public: void Set_SpellLearn(_int Index); - + _int Get_SpellTrail(); + _bool Get_bMoveStart(); private: - void Line(_float fTime); + void Line(_float fTime, _float2 fMouse); private: diff --git a/Jusin154_Team3D/Editor/Public/SpellLearn_Panel.h b/Jusin154_Team3D/Editor/Public/SpellLearn_Panel.h index 5405b5c18..c0dca3d7d 100644 --- a/Jusin154_Team3D/Editor/Public/SpellLearn_Panel.h +++ b/Jusin154_Team3D/Editor/Public/SpellLearn_Panel.h @@ -45,6 +45,7 @@ class CSpellLearn_Panel final : public CPanelObject CGameObject* m_pSpellLearn_Name = { nullptr }; CGameObject* m_pSpellLearn = { nullptr }; CGameObject* m_pSpellLearn_MovePointer = { nullptr }; + CGameObject* m_pSPellLeam_ChaserPointer = { nullptr }; CGameObject* m_pSpellLearn_Data = { nullptr }; _int Index{}; diff --git a/Jusin154_Team3D/Engine/Private/ElementObject.cpp b/Jusin154_Team3D/Engine/Private/ElementObject.cpp index 92e573c9f..7d2df1d4d 100644 --- a/Jusin154_Team3D/Engine/Private/ElementObject.cpp +++ b/Jusin154_Team3D/Engine/Private/ElementObject.cpp @@ -158,6 +158,42 @@ _bool CElementObject::Start_Lerp(_float fTimeDelta) } } +_bool CElementObject::Start_Lerp_Speed(_float fTimeDelta, _float2 MousePoint) +{ + _vector Mouse = XMVectorSet(MousePoint.x, MousePoint.y, 1.f, 1.f); + _vector Pos = m_fCurrent_Position; + _vector Target = m_vLerp_Position; + + _vector Dir = XMVectorSubtract(Target, Pos); + _vector MouseDir = XMVectorSubtract(Mouse, Pos); + + _vector NorDir = XMVector3Normalize(Dir); + _vector NorMouse = XMVector3Normalize(MouseDir); + + _float SameDir = XMVectorGetX(XMVector3Dot(NorDir, NorMouse)); + _float Weight = max(0.5f, SameDir); + _vector LenVec = XMVector3Length(Dir); + _float Distance = XMVectorGetX(LenVec); + + _float move = m_fMoveSpeed * fTimeDelta * Weight; + + if (Distance <= move) + { + m_fX = m_vLerp_Position.m128_f32[0]; + m_fY = m_vLerp_Position.m128_f32[1]; + return true; + } + + else + { + m_fPerPosition = _float2(m_fX, m_fY); + XMVECTOR DirNorm = XMVector3Normalize(Dir); + m_fX = (Pos + DirNorm * move).m128_f32[0]; + m_fY = (Pos + DirNorm * move).m128_f32[1]; + return false; + } +} + void CElementObject::Reset_Pos(_float fTimeDelta) { _vector Pos = m_fCurrent_Position; diff --git a/Jusin154_Team3D/Engine/Private/UIObject.cpp b/Jusin154_Team3D/Engine/Private/UIObject.cpp index cf9262857..f7a2f40b1 100644 --- a/Jusin154_Team3D/Engine/Private/UIObject.cpp +++ b/Jusin154_Team3D/Engine/Private/UIObject.cpp @@ -377,7 +377,7 @@ _bool CUIObject::Start_Lerp(_float fTimeDelta) return false; } -_bool CUIObject::Start_Bezier(_float fTimeDelta) +_bool CUIObject::Start_Lerp_Speed(_float fTimeDelta, _float2 Mouse_Point) { return _bool(); } @@ -538,6 +538,11 @@ _float2 CUIObject::Get_Font() return _float2(m_fFontX, m_fFontY); } +_float2 CUIObject::Get_PerPosition() +{ + return m_fPerPosition; +} + void CUIObject::Free() { __super::Free(); diff --git a/Jusin154_Team3D/Engine/Public/ElementObject.h b/Jusin154_Team3D/Engine/Public/ElementObject.h index 90b5c68b5..acf454950 100644 --- a/Jusin154_Team3D/Engine/Public/ElementObject.h +++ b/Jusin154_Team3D/Engine/Public/ElementObject.h @@ -31,6 +31,7 @@ class ENGINE_DLL CElementObject abstract : public CUIObject virtual _float Get_Nine_Slice_Bottom() override; virtual _bool Start_Lerp(_float fTimeDelta) override; + virtual _bool Start_Lerp_Speed(_float fTimeDelta, _float2 MousePoint) override; virtual void Reset_Pos(_float fTimeDelta)override; virtual void Start_Size_Lerp(_float fTimeDelta) override; virtual void Reset_Size_Lerp(_float fTimeDelta) override; diff --git a/Jusin154_Team3D/Engine/Public/UIObject.h b/Jusin154_Team3D/Engine/Public/UIObject.h index b2104dc38..e00286dcd 100644 --- a/Jusin154_Team3D/Engine/Public/UIObject.h +++ b/Jusin154_Team3D/Engine/Public/UIObject.h @@ -152,7 +152,7 @@ typedef struct tagSpellLearnInfo virtual void Lerp_PosX(_float PosX); virtual void Lerp_PosY(_float PosY); virtual _bool Start_Lerp(_float fTimeDelta); - virtual _bool Start_Bezier(_float fTimeDelta); + virtual _bool Start_Lerp_Speed(_float fTimeDelta, _float2 Mouse_Point); virtual void Reset_Pos(_float fTimeDelta); virtual void Start_Size_Lerp(_float fTimeDelta); virtual void Reset_Size_Lerp(_float fTimeDelta); @@ -190,6 +190,7 @@ typedef struct tagSpellLearnInfo virtual void Set_FontX(_float fFontX); virtual void Set_FontY(_float fFontY); virtual _float2 Get_Font(); + virtual _float2 Get_PerPosition(); protected: _vector m_fOrigin_Position_vector{}; _float2 m_fOrigin_Position{}; @@ -246,6 +247,8 @@ typedef struct tagSpellLearnInfo _float m_fFontX{}; _float m_fFontY{}; _float m_fFontOffSet{}; + + _float2 m_fPerPosition{}; protected: virtual HRESULT Initialize_Prototype(); virtual HRESULT Initialize(void* pArg);