#include "pch.h" #include "SpellLearn.h" #include "GameInstance.h" #include "InfoInstance.h" CSpellLearn::CSpellLearn(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) :CElementObject(pDevice, pContext) { } CSpellLearn::CSpellLearn(const CSpellLearn& rhs) :CElementObject(rhs), m_pInfoInstance(CInfoInstance::GetInstance()) { } HRESULT CSpellLearn::Initialize_Prototype() { return S_OK; } HRESULT CSpellLearn::Initialize(void* pArg) { CUIObject::UIOBJECT_DESC Desc{}; Desc.fX = 600.f; Desc.fY = 0.f; Desc.fSizeX = 550.f; Desc.fSizeY = 550.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; Change_Image(0); Visible(false); return S_OK; } void CSpellLearn::Priority_Update(_float fTimeDelta) { if (!__super::Chack_Visible()) { return; } __super::Priority_Update(fTimeDelta); } void CSpellLearn::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; } } m_fTime += fTimeDelta * m_fTimeMult; __super::Update(fTimeDelta); } void CSpellLearn::Late_Update(_float fTimeDelta) { if (!__super::Chack_Visible()) { return; } if (m_bVisible) { m_pGameInstance->Add_RenderGroup(RENDER::UI, this); __super::Late_Update(fTimeDelta); } } HRESULT CSpellLearn::Render() { if (FAILED(Bind_ShaderResources())) { return E_FAIL; } if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_UIEDITOR::COLOR)))) { return E_FAIL; } if (FAILED(m_pVIBufferCom->Bind_Resources())) { return E_FAIL; } if (FAILED(m_pVIBufferCom->Render())) { return E_FAIL; } return S_OK; } _vector CSpellLearn::Get_WorldPostion() { return m_pTransformCom->Get_State(STATE::POSITION); } HRESULT CSpellLearn::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_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 CSpellLearn::Ready_Components(void* pArg) { if (FAILED(Add_Component(g_iStaticLevel, &m_pVIBufferCom))) { return E_FAIL; } if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Texture_Levioso"), reinterpret_cast(&m_pDiffuse_TextureCom), nullptr))) { return E_FAIL; } if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Texture_UI_T_Goldleaf_Large"), reinterpret_cast(&m_pDiffuse_TextureCom1), nullptr))) { return E_FAIL; } if (FAILED(Add_Asset_Component(g_iStaticLevel, FX_UIEDITOR, (CComponent**)&m_pShaderCom, nullptr))) { return E_FAIL; } return S_OK; } HRESULT CSpellLearn::Change_Image(_int SpellID) { _wstring pName = TEXT("Prototype_Texture_"); _wstring pImageName = pName + m_pInfoInstance->Get_SpellLearn(SpellID).pImageName; if (m_pDiffuse_TextureCom) { Remove_Component(); SAFE_RELEASE(m_pDiffuse_TextureCom); } if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, pImageName, reinterpret_cast(&m_pDiffuse_TextureCom)))) return E_FAIL; return S_OK; } CSpellLearn* CSpellLearn::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) { CSpellLearn* pInstance = new CSpellLearn(pDevice, pContext); if (FAILED(pInstance->Initialize_Prototype())) { MSG_BOX("Failed to Created : CSpellLearn"); SAFE_RELEASE(pInstance); } return pInstance; } CGameObject* CSpellLearn::Clone(void* pArg, CGameObject* pOwner) { CSpellLearn* pInstance = new CSpellLearn(*this); pInstance->m_pOwner = pOwner; if (FAILED(pInstance->Initialize(pArg))) { MSG_BOX("Failed to Cloned : CSpellLearn"); SAFE_RELEASE(pInstance); } return pInstance; } void CSpellLearn::Free() { __super::Free(); SAFE_RELEASE(m_pDiffuse_TextureCom); SAFE_RELEASE(m_pDiffuse_TextureCom1); SAFE_RELEASE(m_pShaderCom); SAFE_RELEASE(m_pVIBufferCom); } #ifdef _DEBUG void CSpellLearn::Describe_Entity() { } #endif // _DEBUG