diff --git a/Jusin154_Team3D/Client/Private/Goblin.cpp b/Jusin154_Team3D/Client/Private/Goblin.cpp index 7430ececa..9790e7611 100644 --- a/Jusin154_Team3D/Client/Private/Goblin.cpp +++ b/Jusin154_Team3D/Client/Private/Goblin.cpp @@ -392,7 +392,7 @@ HRESULT CGoblin::Ready_Parts() #pragma endregion - return S_OK; + return S_OK; } diff --git a/Jusin154_Team3D/Client/Private/Goblin_States.cpp b/Jusin154_Team3D/Client/Private/Goblin_States.cpp index 98618c6eb..06705a150 100644 --- a/Jusin154_Team3D/Client/Private/Goblin_States.cpp +++ b/Jusin154_Team3D/Client/Private/Goblin_States.cpp @@ -481,9 +481,9 @@ void CGoblin::Behavior_DeadEnter() } pairAnimInfo = m_Animation[iState + bStrongerKnockDown]; - Get_PartObject("Goblin_Particle")->Set_Visible(false); - Get_PartObject("Goblin_Particle2")->Set_Visible(false); - Get_PartObject("Goblin_Smoke")->Set_Visible(false); + //Get_PartObject("Goblin_Particle")->Set_Visible(false); + //Get_PartObject("Goblin_Particle2")->Set_Visible(false); + //Get_PartObject("Goblin_Smoke")->Set_Visible(false); m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); } diff --git a/Jusin154_Team3D/Client/Private/Troll.cpp b/Jusin154_Team3D/Client/Private/Troll.cpp index d7d20725d..1377aef05 100644 --- a/Jusin154_Team3D/Client/Private/Troll.cpp +++ b/Jusin154_Team3D/Client/Private/Troll.cpp @@ -121,28 +121,28 @@ void CTroll::Update(_float fTimeDelta) #pragma region TRAIL_UPDATE - _matrix WorldMat = m_pTransformCom->Get_XMWorldMatrix(); + //_matrix WorldMat = m_pTransformCom->Get_XMWorldMatrix(); - _matrix LeftHandMatrix = {}; - _matrix RightHandMatrix = {}; - _matrix WeaponMatrix = {}; + //_matrix LeftHandMatrix = {}; + //_matrix RightHandMatrix = {}; + //_matrix WeaponMatrix = {}; - LeftHandMatrix = XMLoadFloat4x4(m_pLeftHand_BoneMat); - RightHandMatrix = XMLoadFloat4x4(m_pRightHand_BoneMat); - WeaponMatrix = XMLoadFloat4x4(m_pWeapon_BoneMat); + //LeftHandMatrix = XMLoadFloat4x4(m_pLeftHand_BoneMat); + //RightHandMatrix = XMLoadFloat4x4(m_pRightHand_BoneMat); + //WeaponMatrix = XMLoadFloat4x4(m_pWeapon_BoneMat); - for (int i = 0; i < 3; ++i) { - LeftHandMatrix.r[i] = XMVector3Normalize(LeftHandMatrix.r[i]); - RightHandMatrix.r[i] = XMVector3Normalize(RightHandMatrix.r[i]); - WeaponMatrix.r[i] = XMVector3Normalize(WeaponMatrix.r[i]); - } + //for (int i = 0; i < 3; ++i) { + // LeftHandMatrix.r[i] = XMVector3Normalize(LeftHandMatrix.r[i]); + // RightHandMatrix.r[i] = XMVector3Normalize(RightHandMatrix.r[i]); + // WeaponMatrix.r[i] = XMVector3Normalize(WeaponMatrix.r[i]); + //} - _matrix WeaponSoket = WeaponMatrix * Get_PartObject()->Get_Component()->Get_XMWorldMatrix(); + //_matrix WeaponSoket = WeaponMatrix * Get_PartObject()->Get_Component()->Get_XMWorldMatrix(); - m_pLeftTrail->Trail_Update(LeftHandMatrix * WorldMat, fTimeDelta); - m_pRightTrail->Trail_Update(RightHandMatrix * WorldMat, fTimeDelta); - m_pWeaponTrail->Trail_Update(WeaponSoket, fTimeDelta); + //m_pLeftTrail->Trail_Update(LeftHandMatrix * WorldMat, fTimeDelta); + //m_pRightTrail->Trail_Update(RightHandMatrix * WorldMat, fTimeDelta); + //m_pWeaponTrail->Trail_Update(WeaponSoket, fTimeDelta); #pragma endregion diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Hogwart_AlphaMap.dds b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Hogwart_AlphaMap.dds new file mode 100644 index 000000000..95887abf3 Binary files /dev/null and b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Hogwart_AlphaMap.dds differ diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj b/Jusin154_Team3D/Editor/Default/Editor.vcxproj index f1479f203..cfba68a06 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj @@ -176,9 +176,16 @@ call Update_Shaders.bat + + + + + + + @@ -370,9 +377,16 @@ call Update_Shaders.bat + + + + + + + diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index 7b349ef5f..3bcbbe461 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -547,6 +547,18 @@ {3a12f2c2-0472-41b7-99ce-2c2f17f26e92} + + {0fdb9c5b-7edd-4915-8fce-a8e78c9e1e9a} + + + {0952e2b6-0430-42db-942f-75cb70310240} + + + {f4f76745-6de8-4670-bd96-a4a4beb39415} + + + {7ba1f85d-a9c4-4002-b425-43796bec6869} + @@ -1073,7 +1085,7 @@ 02.GameObjects\Layer_Effect\Effect\Monster_Effect\Goblin_Protego - + 50.UI\GamePlay_Canvas\Enemy_Panel @@ -1083,6 +1095,27 @@ 50.UI\GamePlay_Canvas\Enemy_Panel\Enemy_Info + + 02.GameObjects\Monster\Goblin\Item + + + 02.GameObjects\Monster\Goblin\Item + + + 02.GameObjects\Monster\Goblin\State + + + 02.GameObjects\Monster\Goblin\State + + + 02.GameObjects\Monster\Goblin\State + + + 02.GameObjects\Monster\Goblin\Item + + + 04.InfoInstance\03.Skill_Info + @@ -1621,6 +1654,27 @@ 02.GameObjects\Layer_Effect\Effect\Monster_Effect\Goblin_Protego + + 02.GameObjects\Monster\Goblin\Item + + + 02.GameObjects\Monster\Goblin\Item + + + 02.GameObjects\Monster\Goblin\State + + + 02.GameObjects\Monster\Goblin\State + + + 02.GameObjects\Monster\Goblin\State + + + 02.GameObjects\Monster\Goblin\Item + + + 04.InfoInstance\03.Skill_Info + diff --git a/Jusin154_Team3D/Editor/Private/Goblin.cpp b/Jusin154_Team3D/Editor/Private/Goblin.cpp index 773e4fe8c..ec6495f5d 100644 --- a/Jusin154_Team3D/Editor/Private/Goblin.cpp +++ b/Jusin154_Team3D/Editor/Private/Goblin.cpp @@ -2,7 +2,12 @@ #include "Goblin.h" #include "GameInstance.h" -#include "EditEffect.h" +#include "InfoInstance.h" +#include "Layer.h" +#include "Player.h" +#include "Goblin_Dagger.h" +#include "Goblin_Spector.h" +#include "Effect_Container.h" #pragma region STATE #include "State_Idle.h" @@ -11,9 +16,11 @@ #include "State_Land.h" #include "State_Move.h" #include "State_Combat.h" -#include "InfoInstance.h" #pragma endregion +#include "EditEffect.h" + + CGoblin::CGoblin(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) : CMonster(pDevice, pContext) { @@ -56,9 +63,7 @@ HRESULT CGoblin::Initialize(void* pArg) m_pCallBack_Behavior->Initialize(m_pCharacter_Controller, m_pRigidBody); m_pCallBack_HitReport->Initialize(m_pCharacter_Controller, m_pRigidBody); - m_pCharacter_Controller->Set_Position(XMVectorSet(-10.f, 0.f, -10.f, 1.f)); - - CInfoInstance::GetInstance()->Regist_ActiveMonster(this); + m_pCharacter_Controller->Set_Position(XMVectorSet(-40.f, 5.f, -20.f, 1.f)); return S_OK; } @@ -66,8 +71,6 @@ HRESULT CGoblin::Initialize(void* pArg) void CGoblin::Priority_Update(_float fTimeDelta) { __super::Priority_Update(fTimeDelta); - - m_pTransformCom->RewindMomentum(); } void CGoblin::Update(_float fTimeDelta) @@ -78,28 +81,68 @@ void CGoblin::Update(_float fTimeDelta) m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom); - //m_pCharacter_Controller->Move(fTimeDelta); - + Play_Event(); + + GUI::Text("%d", m_pCharacter_Controller->IsActive()); + GUI::Text("%f %f", m_vStunTimer.x, m_vStunTimer.y); + if (true == m_pCharacter_Controller->IsActive()) { + m_pCharacter_Controller->Move(fTimeDelta); + m_vStunTimer.x = 0.f; + } + else if (true == m_pRigidBody->IsActive()) { + if (0.f == m_vStunTimer.x) { + PSX::PxExtendedVec3 pxControlllerPos = m_pCharacter_Controller->Get_Controller()->getPosition(); + PSX::PxTransform pxTransform((_float)pxControlllerPos.x, (_float)pxControlllerPos.y + 100.f, (_float)pxControlllerPos.z); + m_pCharacter_Controller->Set_Position(XMLoadFloat3((_float3*)&pxTransform.p)); + //m_pCharacter_Controller->Move(fTimeDelta); + } + m_vStunTimer.x += fTimeDelta; + m_pTransformCom->Set_WorldMatrix(m_pRigidBody->Get_Actor()->getGlobalPose()); + if (m_vStunTimer.y < m_vStunTimer.x) { + m_pRigidBody->ConvertToCCT(*m_pCharacter_Controller); + } + } +#ifdef _DEBUG + Describe_Entity(); +#endif // _DEBUG + + for (_uint i = 0; i < ENUM_CLASS(GOBLIN_SKILL::END); i++) + m_fSkillCoolTime[i] = max(0.f, m_fSkillCoolTime[i] - fTimeDelta); + + + } void CGoblin::Late_Update(_float fTimeDelta) { __super::Late_Update(fTimeDelta); - m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position()); + if (true == m_pCharacter_Controller->IsActive()) { + m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_FootPosition()); + } + else if (true == m_pRigidBody->IsActive()) { + m_pTransformCom->Set_WorldMatrix(m_pRigidBody->Get_FootPositionPxTransform()); + } + if (true == m_bLookAt) { + m_pTransformCom->LookAt_Horizontal(XMLoadFloat4(&m_vTargetPos)); + } - //m_pTransformCom->LookAt(m_pPlayerTransform->Get_State(STATE::POSITION)); - - m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this); + m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this); + m_pGameInstance->Add_RenderGroup(RENDER::SHADOW, this); } HRESULT CGoblin::Render() { + if (!m_bVisible) + return S_OK; if (FAILED(Bind_ShaderResources())) { return E_FAIL; } _uint iNumMeshes = m_pModelCom->Get_NumMeshes(); - + _uint iShaderPass = ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT); + if (true == m_bDrawOutLine) { + iShaderPass = ENUM_CLASS(SHADER_PASS_ANIM::OUTLINE_WRITE); + } for (_uint i = 0; i < iNumMeshes; i++) { if (FAILED(m_pModelCom->Bind_BoneMatrices(i, m_pShaderCom, "g_BoneMatrices"))) { @@ -110,7 +153,7 @@ HRESULT CGoblin::Render() return E_FAIL; } - if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) { + if (FAILED(m_pShaderCom->Begin(iShaderPass))) { return E_FAIL; } @@ -119,14 +162,115 @@ HRESULT CGoblin::Render() } } + if (m_bDrawOutLine) { + Render_OutLine(); + } + #ifdef _DEBUG - m_pCharacter_Controller->Render(); - //m_pRigidBody->Render(); + if (true == m_pCharacter_Controller->IsActive()) { + if (FAILED(m_pCharacter_Controller->Render())) { + return E_FAIL; + } + } + else if (true == m_pRigidBody->IsActive()) { + if (FAILED(m_pRigidBody->Render())) { + return E_FAIL; + } + } #endif + return S_OK; } +HRESULT CGoblin::Render_Shadow() +{ + if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Bind_Shadow_Resource(m_pShaderCom, "g_ViewMatrix", D3DTS::VIEW))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Bind_Shadow_Resource(m_pShaderCom, "g_ProjMatrix", D3DTS::PROJ))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", &m_pGameInstance->Get_ShadowDesc()->fFar, sizeof(_float)))) { + return E_FAIL; + } + _uint iNumMeshes = m_pModelCom->Get_NumMeshes(); + for (_uint i = 0; i < iNumMeshes; i++) + { + if (FAILED(m_pModelCom->Bind_BoneMatrices(i, m_pShaderCom, "g_BoneMatrices"))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::SHADOW)))) { + return E_FAIL; + } + + if (FAILED(m_pModelCom->Render(i))) { + return E_FAIL; + } + } + + return S_OK; +} + +_vector CGoblin::Get_LockOnPos() +{ + if (nullptr != m_pCharacter_Controller && true == m_pCharacter_Controller->IsActive()) { + return m_pCharacter_Controller->Get_Position(); + } + else if (nullptr != m_pRigidBody) { + return m_pRigidBody->Get_Position(); + } + return Get_WorldPostion(); +} + +void CGoblin::OnCollision(CGameObject* pOther, void* pDesc) +{ + if (true == m_bDead) { + return; + } + ON_COLLISION_INFO* CollisionDesc = static_cast(pDesc); + + _uint iSkillType = dynamic_cast(pOther)->Get_SkillType(); + m_fHitRadius = CMyTools::Get_Direction2D(m_pTransformCom->Get_State(STATE::LOOK), XMLoadFloat4(&CollisionDesc->vHitDir)); + switch (iSkillType) + { + case ENUM_CLASS(SKILL_TYPE::DESCENDO): + m_eHitSpell = STATEANIM::KNOCKDOWN_FWD; + break; + case ENUM_CLASS(SKILL_TYPE::FLIPENDO): + m_eHitSpell = STATEANIM::TUMBLE2; + break; + case ENUM_CLASS(SKILL_TYPE::JAP): + { + m_eHitSpell = STATEANIM::HIT_LEVIOSO; + _float fSkillRatio = m_pInfoInstance->Get_Spell_Info(ENUM_CLASS(SKILL_TYPE::JAP)).fSpell_Damage; + _float fCoefficient = CollisionDesc->pObject->Get_Component()->Get_Stat(ENUM_CLASS(STAT::MAGIC)); + if (true == Get_Damage(fSkillRatio * fCoefficient)) { + m_pFSM->Change_State(FSMSTATE::DEAD); + return; + } + } + break; + case ENUM_CLASS(SKILL_TYPE::LEVIOSO): + m_eHitSpell = STATEANIM::HIT_LEVIOSO; + break; + default: + m_eHitSpell = STATEANIM::KNOCKDOWN_FWD; + break; + } + if (!m_pFSM->IsEnable(FSMSTATE::BLINK)) { + m_pFSM->Change_State(FSMSTATE::HIT); + } + +} + +void CGoblin::OnHit(CGameObject* pOther, CGameObject* pCaller) +{ +} + HRESULT CGoblin::Ready_Components() { CTransform::TRANSFORM_DESC Desc = {}; @@ -141,21 +285,22 @@ HRESULT CGoblin::Ready_Components() /* Com_Model */ if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, m_strModelPrototypeTag, - reinterpret_cast(&m_pModelCom)))) + reinterpret_cast(&m_pModelCom)))) { return E_FAIL; + } { // CCT CCharacter_Controller::Character_Controller_DESC Desc{}; - Desc.iSubKind = ENUM_CLASS(COLLIDABLEOBJECT::MONSTER); + Desc.iSubKind = ENUM_CLASS(PXOBJECT::GOBLIN_WARRIOR); Desc.pTransform = m_pTransformCom; Desc.eBodyType = ACTOR::CAPSULE; - Desc.fContactOffset = 0.1f; - Desc.fMaterial = { 0.5f, 0.5f, 0.6f }; + Desc.fContactOffset = 0.001f; + Desc.fMaterial = { 1.2f, 1.0f, 0.0f }; Desc.bAutoStepping = { false }; Desc.fStepOffset = { 0.05f }; - Desc.fRadius = 0.5f; - Desc.fHeight = 1.0f; + Desc.fRadius = 0.6f; + Desc.fHeight = 0.7f; Desc.pCallback_HitReport = m_pCallBack_HitReport = CCallBack_Monster_HitReport::Create(); Desc.pCallback_Behavior = m_pCallBack_Behavior = CCallBack_Monster_Behavior::Create(); Desc.eClimbingMode = PSX::PxCapsuleClimbingMode::eEASY; @@ -167,18 +312,42 @@ HRESULT CGoblin::Ready_Components() m_pCharacter_Controller->Set_Position(m_pTransformCom->Get_State(STATE::POSITION)); { // DO CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{}; - Desc.iSubKind = ENUM_CLASS(COLLIDABLEOBJECT::MONSTER); + Desc.iSubKind = ENUM_CLASS(PXOBJECT::GOBLIN_WARRIOR); if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), (CComponent**)&m_pRigidBody, &Desc))) { return E_FAIL; } m_pGameInstance->Detach_Actor(*m_pRigidBody->Get_Actor()); } + //if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("STAT_GOBLIN"), (CComponent**)&m_pStat))) { + // return E_FAIL; + //} return S_OK; } HRESULT CGoblin::Ready_Parts() { + CGoblin_Dagger::GOBLINDAGGER_DESC Goblin_DaggerDesc{}; + + Goblin_DaggerDesc.pParentTransform = m_pTransformCom; + Goblin_DaggerDesc.pSocketMatrices = m_pModelCom->Get_BoneMatrixPtr("LeftHand"); + + if (FAILED(Add_PartObject("Goblin_Dagger", g_iStaticLevel, nullptr, &Goblin_DaggerDesc))) + { + return E_FAIL; + } + + Get_PartObject()->Set_Visible(false); + + + CGoblin_Spector::GOBLIN_SPECTOR_DESC Goblin_SpectorDesc{}; + + Goblin_SpectorDesc.pParentTransform = m_pTransformCom; + + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER, &Goblin_SpectorDesc, this))) { + return E_FAIL; + } + #pragma region EFFECT /* EFFECT */ @@ -186,41 +355,39 @@ HRESULT CGoblin::Ready_Parts() PartsDesc.pParentTransform = m_pTransformCom; - - - if (FAILED(Add_PartObject("Goblin_Particle", ENUM_CLASS(LEVEL::EFFECT), &m_pTroll_Particle, &PartsDesc))) + if (FAILED(Add_PartObject("Goblin_Particle", NEXT_LEVEL, &m_pGoblin_Particle, &PartsDesc))) { return E_FAIL; } - m_pTroll_Particle->Load("../Bin/Resources/Data/Effect/Goblin/GoblinSide/Goblin_Particle", static_cast(NEXT_LEVEL)); - m_pTroll_Particle->FollowParants(m_pModelCom->Get_BoneMatrixPtr("RightShoulder")); + m_pGoblin_Particle->Load("../Bin/Resources/Data/Effect/Goblin/GoblinSide/Goblin_Particle", static_cast(NEXT_LEVEL)); + m_pGoblin_Particle->FollowParants(m_pModelCom->Get_BoneMatrixPtr("RightShoulder")); - if (FAILED(Add_PartObject("Goblin_Particle2", ENUM_CLASS(LEVEL::EFFECT), &m_pTroll_Particle2, &PartsDesc))) + if (FAILED(Add_PartObject("Goblin_Particle2", NEXT_LEVEL, &m_pGoblin_Particle2, &PartsDesc))) { return E_FAIL; } - m_pTroll_Particle2->Load("../Bin/Resources/Data/Effect/Goblin/GoblinSide/Goblin_Particle2", static_cast(NEXT_LEVEL)); - m_pTroll_Particle2->FollowParants(m_pModelCom->Get_BoneMatrixPtr("RightShoulder")); + m_pGoblin_Particle2->Load("../Bin/Resources/Data/Effect/Goblin/GoblinSide/Goblin_Particle2", static_cast(NEXT_LEVEL)); + m_pGoblin_Particle2->FollowParants(m_pModelCom->Get_BoneMatrixPtr("RightShoulder")); - if (FAILED(Add_PartObject("Goblin_Smoke", ENUM_CLASS(LEVEL::EFFECT), &m_pRight_Smoke, &PartsDesc))) + if (FAILED(Add_PartObject("Goblin_Smoke", NEXT_LEVEL, &m_pSmoke, &PartsDesc))) { return E_FAIL; } - m_pRight_Smoke->Load("../Bin/Resources/Data/Effect/Goblin/GoblinSide/Goblin_Smoke", static_cast(NEXT_LEVEL)); - m_pRight_Smoke->FollowParants(m_pModelCom->Get_BoneMatrixPtr("Spine2")); + m_pSmoke->Load("../Bin/Resources/Data/Effect/Goblin/GoblinSide/Goblin_Smoke", static_cast(NEXT_LEVEL)); + m_pSmoke->FollowParants(m_pModelCom->Get_BoneMatrixPtr("Spine2")); #pragma endregion + return S_OK; } - HRESULT CGoblin::Bind_ShaderResources() { if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) { @@ -276,39 +443,51 @@ void CGoblin::Free() SAFE_RELEASE(m_pCharacter_Controller); SAFE_RELEASE(m_pRigidBody); + SAFE_RELEASE(m_pSmoke); + SAFE_RELEASE(m_pGoblin_Particle); + SAFE_RELEASE(m_pGoblin_Particle2); Safe_Delete(m_pCallBack_Behavior); Safe_Delete(m_pCallBack_HitReport); - - SAFE_RELEASE(m_pTroll_Particle); - SAFE_RELEASE(m_pTroll_Particle2); - SAFE_RELEASE(m_pRight_Smoke); - SAFE_RELEASE(m_pLeft_Smoke); } +#ifdef _DEBUG void CGoblin::Describe_Entity() { - for (auto& pComponent : m_Components) - { - if (GUI::TreeNode(typeid(*pComponent).name())) - { - pComponent->Describe_Entity(); + GUI::Begin("Goblin"); - GUI::TreePop(); - } + GUI::Checkbox("LookAt", &m_bLookAt); + + string AnimList = m_pModelCom->Get_AnimList(m_pModelCom->Get_AnimIndex()); + GUI::Text(AnimList.c_str()); + + GUI::Text("AnimTrack %.2f", m_pModelCom->Get_CurrentTrackPosition()); + GUI::Text("AnimRatio %.2f", m_pModelCom->Get_CurrentTrackProgressRatio()); + + _float4 vMomentum = {}; + XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum()); + GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w); + + _float3 Pos; + XMStoreFloat3(&Pos, Get_WorldPostion()); + + if (GUI::DragFloat3("Pos", (_float*)&Pos)) + { + m_pCharacter_Controller->Set_Position(XMLoadFloat3(&Pos)); } - _uint iIndex = {}; + XMFLOAT3 f3; + XMStoreFloat3(&f3, m_vOriginPos); - for (auto& pParts : m_PartObjects) - { - _string strName = to_string(iIndex++) + " : " + typeid(*pParts.second).name(); + GUI::Text("Origin: %.2f, %.2f, %.2f", f3.x, f3.y, f3.z); - if (GUI::TreeNode(strName.c_str())) - { - pParts.second->Describe_Entity(); + m_fLength = XMVectorGetX(XMVector2Length(m_pTransformCom->Get_State(STATE::POSITION) - m_vOriginPos)); - GUI::TreePop(); - } - } + GUI::Text("Length %.2f", m_fLength); + GUI::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "Distance %.2f", m_fTargetDistance); + + + GUI::End(); } + +#endif // _DEBUG diff --git a/Jusin154_Team3D/Editor/Private/Goblin_BattleAxe.cpp b/Jusin154_Team3D/Editor/Private/Goblin_BattleAxe.cpp new file mode 100644 index 000000000..c4f8a58a0 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/Goblin_BattleAxe.cpp @@ -0,0 +1,180 @@ +#include "pch.h" +#include "Goblin_BattleAxe.h" + +#include "GameInstance.h" +#include "TrailObject.h" +#include "EditEffect.h" + +CGoblin_BattleAxe::CGoblin_BattleAxe(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + : CPartObject(pDevice, pContext) +{ +} + +CGoblin_BattleAxe::CGoblin_BattleAxe(const CGoblin_BattleAxe& Prototype) + : CPartObject(Prototype) +{ +} + +HRESULT CGoblin_BattleAxe::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CGoblin_BattleAxe::Initialize(void* pArg) +{ + GOBLIN_BATTLEAXE_DESC* pDesc = static_cast (pArg); + m_pSocketMatrices = pDesc->pSocketMatrices; + + if (FAILED(__super::Initialize(pArg))) { + return E_FAIL; + } + + + if (FAILED(Ready_Components())) { + return E_FAIL; + } + + return S_OK; +} + +void CGoblin_BattleAxe::Priority_Update(_float fTimeDelta) +{ + m_pModelCom->Combined_BoneMatrix(); + _matrix socketMatrix = {}; + + socketMatrix = XMLoadFloat4x4(m_pSocketMatrices); + + for (int i = 0; i < 3; ++i) { + socketMatrix.r[i] = XMVector3Normalize(socketMatrix.r[i]); + } + + m_pTransformCom->Set_WorldMatrix(socketMatrix * XMLoadFloat4x4(m_pParentTransformCom->Get_WorldMatrixPtr())); + +#ifdef _DEBUG + Describe_Entity(); + +#endif // _DEBUG +} + +void CGoblin_BattleAxe::Update(_float fTimeDelta) +{ + + +} + +void CGoblin_BattleAxe::Late_Update(_float fTimeDelta) +{ + m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this); +} + +HRESULT CGoblin_BattleAxe::Render() +{ + if (!m_pModelCom) + return S_OK; + + if (!m_bVisible) + return S_OK; + + if (FAILED(Bind_ShaderResources())) { + return E_FAIL; + } + + _uint iNumMeshes = m_pModelCom->Get_NumMeshes(); + + for (_uint i = 0; i < iNumMeshes; i++) + { + if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) { + return E_FAIL; + } + + if (FAILED(m_pModelCom->Render(i))) { + return E_FAIL; + } + } + + return S_OK; +} + +HRESULT CGoblin_BattleAxe::Ready_Components() +{ + __super::Ready_Components(nullptr); + + /* Com_Model */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Goblin_BattleAxe_Model"), + reinterpret_cast(&m_pModelCom)))) + return E_FAIL; + + /* Com_Shader */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, + reinterpret_cast(&m_pShaderCom)))) + return E_FAIL; + + return S_OK; +} + +HRESULT CGoblin_BattleAxe::Bind_ShaderResources() +{ + if (FAILED(m_pShaderCom->Bind_Matrix("g_WorldMatrix", m_pTransformCom->Get_WorldMatrixPtr()))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { + return E_FAIL; + } + + return S_OK; +} + + +CGoblin_BattleAxe* CGoblin_BattleAxe::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CGoblin_BattleAxe* pInstance = new CGoblin_BattleAxe(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CGoblin_BattleAxe"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CGameObject* CGoblin_BattleAxe::Clone(void* pArg, CGameObject* pOwner) +{ + CGoblin_BattleAxe* pInstance = new CGoblin_BattleAxe(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CGoblin_BattleAxe"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CGoblin_BattleAxe::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pShaderCom); + SAFE_RELEASE(m_pModelCom); + +} +#ifdef _DEBUG + +void CGoblin_BattleAxe::Describe_Entity() +{ +} + +#endif // _DEBUG diff --git a/Jusin154_Team3D/Editor/Private/Goblin_Dagger.cpp b/Jusin154_Team3D/Editor/Private/Goblin_Dagger.cpp new file mode 100644 index 000000000..9000f9a41 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/Goblin_Dagger.cpp @@ -0,0 +1,197 @@ +#include "pch.h" +#include "Goblin_Dagger.h" + +#include "GameInstance.h" +#include "Goblin.h" + +CGoblin_Dagger::CGoblin_Dagger(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + : CPartObject(pDevice, pContext) +{ +} + +CGoblin_Dagger::CGoblin_Dagger(const CGoblin_Dagger& Prototype) + : CPartObject(Prototype) +{ +} + +HRESULT CGoblin_Dagger::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CGoblin_Dagger::Initialize(void* pArg) +{ + GOBLINDAGGER_DESC* pDesc = static_cast (pArg); + m_pSocketMatrices = pDesc->pSocketMatrices; + + if (FAILED(__super::Initialize(pArg))) { + return E_FAIL; + } + + + if (FAILED(Ready_Components())) { + return E_FAIL; + } + + return S_OK; +} + +void CGoblin_Dagger::Priority_Update(_float fTimeDelta) +{ + //m_pModelCom->Combined_BoneMatrix(); + if (m_bAttach) + { + _matrix socketMatrix = {}; + + socketMatrix = XMLoadFloat4x4(m_pSocketMatrices); + + for (int i = 0; i < 3; ++i) { + socketMatrix.r[i] = XMVector3Normalize(socketMatrix.r[i]); + } + + m_pTransformCom->Set_WorldMatrix(socketMatrix * XMLoadFloat4x4(m_pParentTransformCom->Get_WorldMatrixPtr())); + _float4 vTargetPos = static_cast(m_pOwner)->Get_TargetPos(); + m_pTransformCom->LookAt(XMLoadFloat4(&vTargetPos)); + } + else + { + _matrix world = XMLoadFloat4x4(m_pTransformCom->Get_WorldMatrixPtr()); + m_pTransformCom->Set_WorldMatrix(world); + m_pTransformCom->Go_Straight(fTimeDelta); + } + + +#ifdef _DEBUG + Describe_Entity(); + +#endif // _DEBUG +} + +void CGoblin_Dagger::Update(_float fTimeDelta) +{ +} + +void CGoblin_Dagger::Late_Update(_float fTimeDelta) +{ + m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this); +} + +HRESULT CGoblin_Dagger::Render() +{ + if (!m_pModelCom) + return S_OK; + + if (!m_bVisible) + return S_OK; + + if (FAILED(Bind_ShaderResources())) { + return E_FAIL; + } + + _uint iNumMeshes = m_pModelCom->Get_NumMeshes(); + + for (_uint i = 0; i < iNumMeshes; i++) + { + if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) { + return E_FAIL; + } + + if (FAILED(m_pModelCom->Render(i))) { + return E_FAIL; + } + } + + return S_OK; +} + +HRESULT CGoblin_Dagger::Ready_Components() +{ + + CTransform::TRANSFORM_DESC Desc = {}; + + Desc.fSpeedPerSec = 25.f; + Desc.fRotationPerSec = XMConvertToRadians(180.0f); + Desc.fRadius = 10.f; + + __super::Ready_Components(&Desc); + + + /* Com_Model */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Goblin_Dagger_Model"), + reinterpret_cast(&m_pModelCom)))) + return E_FAIL; + + /* Com_Shader */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, + reinterpret_cast(&m_pShaderCom)))) + return E_FAIL; + + return S_OK; +} + +HRESULT CGoblin_Dagger::Bind_ShaderResources() +{ + if (FAILED(m_pShaderCom->Bind_Matrix("g_WorldMatrix", m_pTransformCom->Get_WorldMatrixPtr()))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { + return E_FAIL; + } + + return S_OK; +} + + +CGoblin_Dagger* CGoblin_Dagger::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CGoblin_Dagger* pInstance = new CGoblin_Dagger(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CGoblin_Dagger"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CGameObject* CGoblin_Dagger::Clone(void* pArg, CGameObject* pOwner) +{ + CGoblin_Dagger* pInstance = new CGoblin_Dagger(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CGoblin_Dagger"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CGoblin_Dagger::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pShaderCom); + SAFE_RELEASE(m_pModelCom); + +} +#ifdef _DEBUG + +void CGoblin_Dagger::Describe_Entity() +{ +} + +#endif // _DEBUG diff --git a/Jusin154_Team3D/Editor/Private/Goblin_Spector.cpp b/Jusin154_Team3D/Editor/Private/Goblin_Spector.cpp new file mode 100644 index 000000000..68aa1b4bf --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/Goblin_Spector.cpp @@ -0,0 +1,245 @@ +#include "pch.h" +#include "Goblin_Spector.h" + +#include "GameInstance.h" +#include "Goblin.h" +#include "Effect_Container.h" +#include "Goblin_BattleAxe.h" + +#include "EditEffect.h" + + +CGoblin_Spector::CGoblin_Spector(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + : CMonster(pDevice, pContext) +{ +} + +CGoblin_Spector::CGoblin_Spector(const CGoblin_Spector& Prototype) + : CMonster(Prototype) +{ +} + +HRESULT CGoblin_Spector::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CGoblin_Spector::Initialize(void* pArg) +{ + GOBLIN_SPECTOR_DESC* pDesc = static_cast (pArg); + m_pParentTransformCom = pDesc->pParentTransform; + if (FAILED(__super::Initialize(pArg))) + return E_FAIL; + + if (FAILED(Ready_Components())) + return E_FAIL; + + if (FAILED(Ready_Parts())) + return E_FAIL; + + m_pGoblin = dynamic_cast(m_pOwner); + SAFE_ADDREF(m_pGoblin); + + m_vOriginScale = m_pTransformCom->Get_Scale(); + + return S_OK; +} + +void CGoblin_Spector::Priority_Update(_float fTimeDelta) +{ + __super::Priority_Update(fTimeDelta); +} + +void CGoblin_Spector::Update(_float fTimeDelta) +{ + __super::Update(fTimeDelta); + + m_Offset = _float3(0.f, 0.3f, 0.f); + + _matrix Offset = XMMatrixTranslation(m_Offset.x, + m_Offset.y, m_Offset.z); + + m_pTransformCom->Set_WorldMatrix(Offset * XMLoadFloat4x4(m_pParentTransformCom->Get_WorldMatrixPtr())); + + if (m_pGoblin->Get_Swing()) + { + if (m_vScale.x <= 2.f) + { + m_vScale.x += fTimeDelta; + m_vScale.y += fTimeDelta; + m_vScale.z += fTimeDelta; + } + m_pTransformCom->Set_Scale(m_vScale); + m_pModelCom->Set_AnimationIndex(m_pGoblin->Get_Component()->Get_AnimIndex()); + m_pModelCom->Set_CurrentTrackPosition(m_pGoblin->Get_Component()->Get_CurrentTrackPosition()); + Get_PartObject()->Set_Visible(true); + m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom); + } + else { + Get_PartObject()->Set_Visible(false); + m_vScale = { 1.f,1.f,1.f }; + m_pTransformCom->Set_Scale(m_vOriginScale); + m_pModelCom->Set_AnimationIndex(5); + } + + + Play_Event(); + +#ifdef _DEBUG + Describe_Entity(); +#endif // _DEBUG + +} + +void CGoblin_Spector::Late_Update(_float fTimeDelta) +{ + __super::Late_Update(fTimeDelta); + + m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this); +} + +HRESULT CGoblin_Spector::Render() +{ + if (!m_bVisible || !m_pGoblin->Get_Swing()) + return S_OK; + if (FAILED(Bind_ShaderResources())) { + return E_FAIL; + } + + _uint iNumMeshes = m_pModelCom->Get_NumMeshes(); + _uint iShaderPass = ENUM_CLASS(SHADER_PASS_ANIM::SPECTOR); + for (_uint i = 0; i < iNumMeshes; i++) + { + if (FAILED(m_pModelCom->Bind_BoneMatrices(i, m_pShaderCom, "g_BoneMatrices"))) { + return E_FAIL; + } + + if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Begin(iShaderPass))) { + return E_FAIL; + } + + if (FAILED(m_pModelCom->Render(i))) { + return E_FAIL; + } + } + + return S_OK; +} + +void CGoblin_Spector::OnCollision(CGameObject* pOther, void* pDesc) +{ + +} + +void CGoblin_Spector::OnHit(CGameObject* pOther, CGameObject* pCaller) +{ +} + +HRESULT CGoblin_Spector::Ready_Components() +{ + CTransform::TRANSFORM_DESC Desc = {}; + + Desc.fSpeedPerSec = 10.f; + Desc.fRotationPerSec = XMConvertToRadians(180.0f); + Desc.fRadius = 10.f; + + __super::Ready_Components(&Desc); + + m_strModelPrototypeTag = TEXT("Prototype_Component_Goblin_Spector_Model"); + + /* Com_Model */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, m_strModelPrototypeTag, + reinterpret_cast(&m_pModelCom)))) { + return E_FAIL; + } + + //if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("STAT_GOBLIN"), (CComponent**)&m_pStat))) { + // return E_FAIL; + //} + return S_OK; +} + +HRESULT CGoblin_Spector::Ready_Parts() +{ + + CGoblin_BattleAxe::GOBLIN_BATTLEAXE_DESC Goblin_BattleAxe_Desc{}; + + Goblin_BattleAxe_Desc.pParentTransform = m_pTransformCom; + Goblin_BattleAxe_Desc.pSocketMatrices = m_pModelCom->Get_BoneMatrixPtr("SKT_RightHand"); + + if (FAILED(Add_PartObject("Goblin_BattleAxe", g_iStaticLevel, nullptr, &Goblin_BattleAxe_Desc))) + { + return E_FAIL; + } + + return S_OK; +} + +HRESULT CGoblin_Spector::Bind_ShaderResources() +{ + if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { + return E_FAIL; + } + return S_OK; +} + +CGoblin_Spector* CGoblin_Spector::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CGoblin_Spector* pInstance = new CGoblin_Spector(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CGoblin_Spector"); + SAFE_RELEASE(pInstance); + } + return pInstance; +} + +CGameObject* CGoblin_Spector::Clone(void* pArg, CGameObject* pOwner) +{ + CGoblin_Spector* pInstance = new CGoblin_Spector(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CGoblin_Spector"); + SAFE_RELEASE(pInstance); + } + return pInstance; +} + +void CGoblin_Spector::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pSmoke); + SAFE_RELEASE(m_pGoblin_Particle); + SAFE_RELEASE(m_pGoblin_Particle2); + SAFE_RELEASE(m_pGoblin); +} +#ifdef _DEBUG + +void CGoblin_Spector::Describe_Entity() +{ + + GUI::Begin("GoblinSpector"); + _float3 vScale = m_pTransformCom->Get_Scale(); + GUI::DragFloat3("Scale", (_float*)&vScale); + + GUI::End(); +} + +#endif // _DEBUG diff --git a/Jusin154_Team3D/Editor/Private/Goblin_States.cpp b/Jusin154_Team3D/Editor/Private/Goblin_States.cpp index ff4a55c37..9daf4e7c4 100644 --- a/Jusin154_Team3D/Editor/Private/Goblin_States.cpp +++ b/Jusin154_Team3D/Editor/Private/Goblin_States.cpp @@ -1,8 +1,10 @@ #include "pch.h" #include "Goblin.h" - +#include "InfoInstance.h" #include "GameInstance.h" #include "Player.h" +#include "Goblin_Dagger.h" +#include "EditEffect.h" #pragma region STATE #include "State_Idle.h" @@ -11,6 +13,12 @@ #include "State_Land.h" #include "State_Move.h" #include "State_Combat.h" +#include "State_Swing.h" +#include "State_Throw.h" +#include "State_Blink.h" +#include "State_Hit.h" +#include "State_Dead.h" +#include "State_Shuffle.h" #pragma endregion @@ -24,8 +32,11 @@ void CGoblin::Behavior_IdleEnter() HRESULT CGoblin::Behavior_IdleExitCheck() { - if (m_fTargetDistance <= 15.f) + if (m_fTargetDistance <= 20.f && m_fTargetDistance != 0.f) + { + m_vOriginPos = m_pTransformCom->Get_State(STATE::POSITION); m_pFSM->Change_State(FSMSTATE::MOVE); + } return E_FAIL; } @@ -38,18 +49,68 @@ void CGoblin::Behavior_IdleExit() void CGoblin::Behavior_MoveEnter() { pair<_uint, _bool> pairAnimInfo = {}; - m_pFSM->Enable_State(FSMSTATE::MOVE); + m_bLookAt = true; m_pFSM->Enable_State(FSMSTATE::JOG); - - pairAnimInfo = m_Animation[STATEANIM::JOG_FWD]; - - m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); } -HRESULT CGoblin::Behavior_MoveExitCheck() +HRESULT CGoblin::Behavior_MoveExitCheck(_float fTimeDelta) { - if (m_fTargetDistance <= 3.f) + pair<_uint, _bool> pairAnimInfo = {}; + _uint iCurrAnimIndex = m_pModelCom->Get_AnimIndex(); + + + if (m_fTargetDistance >= 6.f) + { + pairAnimInfo = m_Animation[STATEANIM::JOG_FWD]; + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); + } + else { + if (!m_bFirstMove) + { + _uint Rand = m_pGameInstance->Real_Random_Int(0, 3); + + switch (Rand) + { + case 0: + pairAnimInfo = m_Animation[STATEANIM::JOG_112_L]; + break; + case 1: + pairAnimInfo = m_Animation[STATEANIM::JOG_112_R]; + break; + case 2: + if (iCurrAnimIndex == m_Animation[STATEANIM::JOG_90_R].first) { + pairAnimInfo = m_Animation[STATEANIM::JOG_112_R]; + } + else { + pairAnimInfo = m_Animation[STATEANIM::JOG_90_L]; + } + break; + case 3: + if (iCurrAnimIndex == m_Animation[STATEANIM::JOG_90_L].first) { + pairAnimInfo = m_Animation[STATEANIM::JOG_112_L]; + } + else { + pairAnimInfo = m_Animation[STATEANIM::JOG_90_R]; + } + break; + } + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 0.5f, true); + + m_bFirstMove = true; + m_fMoveTime = 0.f; + return S_OK; + } + m_fMoveTime += fTimeDelta; + + if (m_fMoveTime >= 2.f) + { + m_bFirstMove = false; + m_fMoveTime = 0.f; + } + } + + if (m_fTargetDistance <= 15.f && m_fTargetDistance >= 3.f && m_fTargetDistance != 0.f) m_pFSM->Change_State(FSMSTATE::COMBAT); return E_FAIL; @@ -63,28 +124,381 @@ void CGoblin::Behavior_MoveExit() void CGoblin::Behavior_CombatEnter() { pair<_uint, _bool> pairAnimInfo = {}; - m_pFSM->Enable_State(FSMSTATE::COMBAT); - - m_pFSM->Enable_State(FSMSTATE::SKILL); - - pairAnimInfo = m_Animation[STATEANIM::SKILL]; - - m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); + m_bLookAt = true; } -HRESULT CGoblin::Behavior_CombatExitCheck() +HRESULT CGoblin::Behavior_CombatExitCheck(_float fTimeDelta) { - if (m_pModelCom->IsFinishedAnim()) + m_bLookAt = true; + + if (m_fTargetDistance > 25.f && m_fTargetDistance != 0.f) { m_pFSM->Change_State(FSMSTATE::IDLE); + return E_FAIL; } + else if (m_fTargetDistance > 20.f && m_fTargetDistance != 0.f) + { + m_pFSM->Change_State(FSMSTATE::MOVE); + return E_FAIL; + } + + if (m_fTargetDistance <= 6.f && m_fSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::SWING)] <= 0.f) + { + m_pFSM->Change_State(FSMSTATE::SWING); + } + else if (m_fTargetDistance >= 7.f && m_fTargetDistance <= 12.f && m_fSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::THROW)] <= 0.f) + { + m_pFSM->Change_State(FSMSTATE::SKILL); + } + else if (m_fTargetDistance <= 15.f && m_fSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::TP)] <= 0.f) + { + m_pFSM->Change_State(FSMSTATE::BLINK); + } + else { + m_pFSM->Change_State(FSMSTATE::MOVE); + } + return E_FAIL; } void CGoblin::Behavior_CombatExit() { - m_pFSM->Disable_State(FSMSTATE::COMBAT | FSMSTATE::SKILL | FSMSTATE::SKILL2); + m_pFSM->Disable_State(FSMSTATE::COMBAT); +} + +void CGoblin::Behavior_SwingEnter() +{ + pair<_uint, _bool> pairAnimInfo = {}; + m_pFSM->Enable_State(FSMSTATE::SWING); + + pairAnimInfo = m_Animation[STATEANIM::SWING_FWD]; + + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 1.f, true); + m_fSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::SWING)] = m_fMaxSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::SWING)]; + + Add_Event(pairAnimInfo.first, + [this]() {m_bStep = false; }, + 0.2f); + + Add_Event(pairAnimInfo.first, + [this]() {m_bSwing = true; }, + 0.05f); + + Add_Event(pairAnimInfo.first, + [&]() { m_bLookAt = true; + m_bStep = true; + m_bSwing = false; + m_pFSM->Change_State(FSMSTATE::SHUFFLE); }, + 0.45f); +} + +HRESULT CGoblin::Behavior_SwingExitCheck(_float fTimeDelta) +{ + pair<_uint, _bool> pairAnimInfo = {}; + _uint iCurrAnimIndex = m_pModelCom->Get_AnimIndex(); + if (m_pFSM->IsEnable(FSMSTATE::SWING) && m_bStep) + { + _float fDesiredRange = 2.f; + _float dist = m_fTargetDistance; + + if (dist > fDesiredRange) + { + _vector vPos = Get_WorldPostion(); + _vector vDistance = XMLoadFloat4(&m_vTargetPos) - vPos; + vDistance = XMVector4Normalize(vDistance); + _float step = dist - fDesiredRange; + + m_pTransformCom->AccumulateMomentum(vDistance * step * fTimeDelta * 1.5f); + } + } + + return E_FAIL; +} + +void CGoblin::Behavior_SwingExit() +{ + m_pFSM->Disable_State(FSMSTATE::SWING); +} + +void CGoblin::Behavior_ThrowEnter() +{ + pair<_uint, _bool> pairAnimInfo = {}; + m_pFSM->Enable_State(FSMSTATE::SKILL); + + pairAnimInfo = m_Animation[STATEANIM::SKILL]; + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 1.f, true); + m_fSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::THROW)] = m_fMaxSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::THROW)]; + + Add_Event(pairAnimInfo.first, + [this]() { + Get_PartObject()->Set_Visible(true); + Get_PartObject()->Set_Attach(false); }, + 0.3f); +} + +HRESULT CGoblin::Behavior_ThrowExitCheck(_float fTimeDelta) +{ + if (m_pModelCom->IsFinishedAnim()) + { + m_bLookAt = true; + m_bStep = true; + m_pFSM->Change_State(FSMSTATE::COMBAT); + return E_FAIL; + } + + return E_FAIL; +} + +void CGoblin::Behavior_ThrowExit() +{ + m_pFSM->Disable_State(FSMSTATE::SKILL); + Get_PartObject()->Set_Attach(true); + Get_PartObject()->Set_Visible(false); +} + +void CGoblin::Behavior_BlinkEnter() +{ + + pair<_uint, _bool> pairAnimInfo = {}; + m_pFSM->Enable_State(FSMSTATE::BLINK); + + pairAnimInfo = m_Animation[STATEANIM::BLINK_START]; + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 1.f, true); + + Add_Event(pairAnimInfo.first, + [this]() { + m_bVisible = false; + m_fSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::TP)] = m_fMaxSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::TP)]; + _vector vPlayerPos = XMLoadFloat4(&m_vTargetPos); + _vector vPlayerLook = m_pTarget->Get_Component()->Get_State(STATE::LOOK); + vPlayerLook = XMVectorSetY(vPlayerLook, 1.f); + vPlayerLook = XMVector3Normalize(vPlayerLook); + + _float randAngleDeg = m_pGameInstance->Real_Random_Float(-60.f, 60.f); + _float randAngleRad = XMConvertToRadians(randAngleDeg); + + _matrix rot = XMMatrixRotationY(randAngleRad); + _vector offsetDir = XMVector3TransformNormal(vPlayerLook, rot); + + _float randDist = m_pGameInstance->Real_Random_Float(5.f, 5.5f); + + _vector vFinalPos = vPlayerPos + offsetDir * randDist; + vFinalPos = XMVectorSetY(vFinalPos, XMVectorGetY(vPlayerPos) + 1.f); + + m_pCharacter_Controller->Set_Position(vFinalPos); } + , 0.99f); +} + +HRESULT CGoblin::Behavior_BlinkExitCheck(_float fTimeDelta) +{ + pair<_uint, _bool> pairAnimInfo = {}; + _uint iCurrAnimIndex = m_pModelCom->Get_AnimIndex(); + m_fTpTime += fTimeDelta; + if (m_fTpTime >= 1.5f) + { + m_bVisible = true; + m_fTpTime = 0.f; + pairAnimInfo = m_Animation[STATEANIM::BLINK]; + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 1.f, true); + } + + if (m_pModelCom->IsFinishedAnim() && iCurrAnimIndex == m_Animation[STATEANIM::BLINK].first) + { + m_bLookAt = true; + m_fTpTime = 0.f; + m_pFSM->Change_State(FSMSTATE::COMBAT); + return E_FAIL; + } + + return E_FAIL; +} + +void CGoblin::Behavior_BlinkExit() +{ + m_pFSM->Disable_State(FSMSTATE::BLINK); +} + +void CGoblin::Behavior_ShuffleEnter() +{ + pair<_uint, _bool> pairAnimInfo = {}; + m_pFSM->Enable_State(FSMSTATE::SHUFFLE); + _uint iRand = m_pGameInstance->Real_Random_Int(0, 3); + switch (iRand) + { + case 0: + pairAnimInfo = m_Animation[STATEANIM::SHUFFLE1]; + break; + case 1: + pairAnimInfo = m_Animation[STATEANIM::SHUFFLE2]; + break; + case 2: + pairAnimInfo = m_Animation[STATEANIM::SHUFFLE3]; + break; + case 3: + pairAnimInfo = m_Animation[STATEANIM::SHUFFLE4]; + break; + } + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 1.f, true); + + Add_Event(pairAnimInfo.first, + [this]() { + m_pFSM->Change_State(FSMSTATE::COMBAT); }, + 0.3f); +} + +HRESULT CGoblin::Behavior_ShuffleExitCheck(_float fTimeDelta) +{ + return E_FAIL; +} + +void CGoblin::Behavior_ShuffleExit() +{ + m_pFSM->Disable_State(FSMSTATE::SHUFFLE); +} + +void CGoblin::Behavior_HitEnter() +{ + pair<_uint, _bool> pairAnimInfo = {}; + m_pFSM->Enable_State(FSMSTATE::HIT); + + m_bLookAt = false; + switch (m_eHitSpell) + { + case STATEANIM::KNOCKDOWN_FWD: + pairAnimInfo = m_Animation[STATEANIM::KNOCKDOWN_FWD]; + break; + case STATEANIM::TUMBLE2: + pairAnimInfo = m_Animation[STATEANIM::TUMBLE2]; + break; + case STATEANIM::HIT_LEVIOSO: + { + pairAnimInfo = m_Animation[STATEANIM::HIT_LEVIOSO]; + break; + } + default: + pairAnimInfo = m_Animation[STATEANIM::KNOCKDOWN_FWD]; + break; + } + + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CGoblin::Behavior_HitExitCheck(_float fTimeDelta) +{ + pair<_uint, _bool> pairAnimInfo = {}; + _uint iCurrAnimIndex = m_pModelCom->Get_AnimIndex(); + + if (iCurrAnimIndex == m_Animation[STATEANIM::KNOCKDOWN_FWD].first) + { + if (m_pModelCom->Get_CurrentTrackProgressRatio() >= 0.5f) + { + pairAnimInfo = m_Animation[STATEANIM::KNOCKDOWN_FWD_SPLT]; + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 1.f); + } + } + + if (iCurrAnimIndex == m_Animation[STATEANIM::HIT_LEVIOSO].first) + { + _vector vDir = m_pTransformCom->Get_State(STATE::UP); + vDir = XMVector4Normalize(vDir); + _vector vPos = m_pCharacter_Controller->Get_Position(); + m_fAirTime += fTimeDelta; + _vector Force = vDir * fTimeDelta; + if (m_fAirTime < 1.3f) { + m_pCharacter_Controller->Set_Position(vPos + Force); + } + else { + m_pCharacter_Controller->Set_Position(vPos); + } + m_pCharacter_Controller->SetGravity(false); + + if (m_pModelCom->Get_CurrentTrackProgressRatio() >= 0.31f) + { + m_fAirTime = 0.f; + m_pCharacter_Controller->SetGravity(true); + pairAnimInfo = m_Animation[STATEANIM::LAND]; + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 1.f); + } + } + + + if (m_pModelCom->IsFinishedAnim()) + { + m_bLookAt = true; + m_pFSM->Change_State(FSMSTATE::IDLE); + return E_FAIL; + } + return E_FAIL; +} + +void CGoblin::Behavior_HitExit() +{ + m_pFSM->Disable_State(FSMSTATE::HIT); +} + +void CGoblin::Behavior_DeadEnter() +{ + m_bLookAt = false; + pair<_uint, _bool> pairAnimInfo = {}; + m_pFSM->Enable_State(FSMSTATE::DEAD); + PSX::PxExtendedVec3 pxControlllerPos = m_pCharacter_Controller->Get_Controller()->getPosition(); + PSX::PxTransform pxTransform((_float)pxControlllerPos.x, (_float)pxControlllerPos.y + 100.f, (_float)pxControlllerPos.z); + m_pCharacter_Controller->Set_Position(XMLoadFloat3((_float3*)&pxTransform.p)); + m_pRigidBody->SetActive(false); + m_pCharacter_Controller->SetActive(false); + + _bool bStrongerKnockDown = { false }; + + switch (m_eHitSpell) + { + case STATEANIM::KNOCKDOWN_FWD: + bStrongerKnockDown = true; + break; + case STATEANIM::TUMBLE2: + bStrongerKnockDown = true; + break; + default: + break; + } + + _float fabsRadius = fabsf(m_fHitRadius); + _uint iState = { UINT_MAX }; + + if (fabsRadius > 135.f) { + iState = STATEANIM::DEAD_FWD; + } + else if (fabsRadius < 45.f) { + iState = STATEANIM::DEAD_BWD; + } + else { + if (m_fHitRadius < 0.f) { + iState = STATEANIM::DEAD_L; + } + else { + iState = STATEANIM::DEAD_R; + } + } + pairAnimInfo = m_Animation[iState + bStrongerKnockDown]; + + Get_PartObject("Goblin_Particle")->Set_Visible(false); + Get_PartObject("Goblin_Particle2")->Set_Visible(false); + Get_PartObject("Goblin_Smoke")->Set_Visible(false); + + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CGoblin::Behavior_DeadExitCheck(_float fTimeDelta) +{ + if (FLT_EPSILON > m_pModelCom->Get_CurrentTrackProgressRatio()) { + return E_PENDING; + } + return S_OK; +} + +void CGoblin::Behavior_DeadExit() +{ + m_bDead = true; } @@ -105,46 +519,219 @@ void CGoblin::Add_FSM() CState_Move::STATE_MOVE_DESC Desc{}; Desc.pOwner = this; Desc.funcEnterEvent = [this]() { Behavior_MoveEnter(); }; - Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_MoveExitCheck(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_MoveExitCheck(fTimedelta); }; Desc.funcExitEvent = [this]() { Behavior_MoveExit(); }; - Desc.funcPriorityUpdate = [this](_float fTimeDelta) { - if (m_pGameInstance->Key_Pressing(DIK_A)) { m_pTransformCom->Turn(-m_pTransformCom->Get_State(STATE::UP), fTimeDelta); } - if (m_pGameInstance->Key_Pressing(DIK_D)) { m_pTransformCom->Turn(m_pTransformCom->Get_State(STATE::UP), fTimeDelta); }; - }; + Desc.funcPriorityUpdate = nullptr; Desc.funcLateUpdate = nullptr; m_States.emplace(FSMSTATE::MOVE, CState_Move::Create(&Desc)); } #pragma endregion - #pragma region Behavior_Combat_NotFocus { CState_Combat::STATE_COMBAT_DESC Desc{}; Desc.pOwner = this; Desc.funcEnterEvent = [this]() { Behavior_CombatEnter(); }; - Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_CombatExitCheck(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_CombatExitCheck(fTimedelta); }; Desc.funcExitEvent = [this]() { Behavior_CombatExit(); }; Desc.funcPriorityUpdate = nullptr; Desc.funcLateUpdate = nullptr; m_States.emplace(FSMSTATE::COMBAT, CState_Combat::Create(&Desc)); } + { + CState_Swing::STATE_SWING_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_SwingEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_SwingExitCheck(fTimedelta); }; + Desc.funcExitEvent = [this]() { Behavior_SwingExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::SWING, CState_Swing::Create(&Desc)); + } + { + CState_Throw::STATE_THROW_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_ThrowEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_ThrowExitCheck(fTimedelta); }; + Desc.funcExitEvent = [this]() { Behavior_ThrowExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::SKILL, CState_Throw::Create(&Desc)); + } + { + CState_Blink::STATE_BLINK_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_BlinkEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_BlinkExitCheck(fTimedelta); }; + Desc.funcExitEvent = [this]() { Behavior_BlinkExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::BLINK, CState_Blink::Create(&Desc)); + } + + { + CState_Shuffle::STATE_SHUFFLE_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_ShuffleEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_ShuffleExitCheck(fTimedelta); }; + Desc.funcExitEvent = [this]() { Behavior_ShuffleExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::SHUFFLE, CState_Shuffle::Create(&Desc)); + } #pragma endregion #pragma region Behavior_Combat_Focus + { + CState_Dead::STATE_DEAD_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_DeadEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_DeadExitCheck(fTimedelta); }; + Desc.funcExitEvent = [this]() { Behavior_DeadExit(); }; + Desc.funcLateUpdate = [this](_float fDeadRatio) { + m_fDeadRatio = fDeadRatio; + if (m_fDeadRatio > 1.f) { + m_bDead = true; + } + }; + Desc.vDeadTimer.x = FLT_EPSILON5; + Desc.vDeadTimer.y = 2.f; + m_States.emplace(FSMSTATE::DEAD, CState_Dead::Create(&Desc)); + } +#pragma endregion + +#pragma region Hit + { + CState_Hit::STATE_HIT_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_HitEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_HitExitCheck(fTimedelta); }; + Desc.funcExitEvent = [this]() { Behavior_HitExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::HIT, CState_Hit::Create(&Desc)); + } #pragma endregion + } void CGoblin::Set_Anim() { - m_Animation[STATEANIM::IDLE] = { 22,true }; + m_Animation[STATEANIM::IDLE_TURN_BWD] = { 24, false }; + m_Animation[STATEANIM::IDLE_TURN_L] = { 26, false }; + m_Animation[STATEANIM::IDLE_TURN_R] = { 30, false }; - m_Animation[STATEANIM::WALK_FWD] = { 50,true }; + m_Animation[STATEANIM::WALK_FWD] = { 45,true }; + m_Animation[STATEANIM::WALK_START] = { 57,false }; m_Animation[STATEANIM::WALK_STOP] = { 58,false }; + m_Animation[STATEANIM::WALK_BWD] = { 252, true }; + + m_Animation[STATEANIM::JOG_FWD] = { 147,true }; // 147 + m_Animation[STATEANIM::JOG_START] = { 157,false }; + m_Animation[STATEANIM::JOG_BWD] = { 146,false }; + m_Animation[STATEANIM::JOG_112_L] = { 148,true }; + m_Animation[STATEANIM::JOG_112_R] = { 152,true }; + m_Animation[STATEANIM::JOG_90_L] = { 151,true }; + m_Animation[STATEANIM::JOG_90_R] = { 155,true }; + + m_Animation[STATEANIM::SHUFFLE1] = { 203,false }; + m_Animation[STATEANIM::SHUFFLE2] = { 204,false }; + m_Animation[STATEANIM::SHUFFLE3] = { 205,false }; + m_Animation[STATEANIM::SHUFFLE4] = { 206,false }; + + m_Animation[STATEANIM::DODGE_LEFT] = { 125, false }; + m_Animation[STATEANIM::DODGE_RIGHT] = { 126, false }; + m_Animation[STATEANIM::SPRINT] = { 90, true }; + + m_Animation[STATEANIM::SKILL] = { 85,false }; // 나이프 던지기 + m_Animation[STATEANIM::BLINK_START] = { 428,false }; // 텔레포트 + m_Animation[STATEANIM::BLINK] = { 426,false }; // 텔레포트 + m_Animation[STATEANIM::SWING_FWD] = { 100,false }; // 도끼 스윙 444 + m_Animation[STATEANIM::ATTACK_END] = { 76,false }; + + m_Animation[STATEANIM::HIT_FWD] = { 353, false }; + m_Animation[STATEANIM::HIT_BWD] = { 352, false }; + m_Animation[STATEANIM::HIT_BWD2] = { 349, false }; + m_Animation[STATEANIM::HIT_BWD3] = { 350, false }; + m_Animation[STATEANIM::HIT_BWD4] = { 351, false }; + m_Animation[STATEANIM::HIT_L] = { 354, false }; + m_Animation[STATEANIM::HIT_R] = { 355, false }; + + m_Animation[STATEANIM::KNOCKDOWN_BWD] = { 374, false }; + m_Animation[STATEANIM::KNOCKDOWN_BWD_SPLT] = { 375, false }; + m_Animation[STATEANIM::KNOCKDOWN_BWD_SPLT_HOLD] = { 370, false }; + m_Animation[STATEANIM::KNOCKDOWN_FWD] = { 371, false }; + m_Animation[STATEANIM::KNOCKDOWN_FWD_SPLT] = { 372, false }; + m_Animation[STATEANIM::KNOCKDOWN_FWD_SPLT_HOLD] = { 373, false }; + + m_Animation[STATEANIM::GETUP_BWD] = { 330, false }; + m_Animation[STATEANIM::GETUP_FWD] = { 332, false }; + m_Animation[STATEANIM::GETUP_L] = { 334, false }; + m_Animation[STATEANIM::GETUP_L_FD] = { 336, false }; + m_Animation[STATEANIM::GETUP_L_FU] = { 338, false }; + m_Animation[STATEANIM::GETUP_R] = { 340, false }; + m_Animation[STATEANIM::GETUP_R_FD] = { 342, false }; + m_Animation[STATEANIM::GETUP_R_FU] = { 344, false }; + m_Animation[STATEANIM::GETUP_SLOUCH] = { 346, false }; + + m_Animation[STATEANIM::KNOCKBACK] = { 377, true }; + m_Animation[STATEANIM::KNOCKBACK2] = { 378, true }; + m_Animation[STATEANIM::TUMBLE] = { 379, true }; + m_Animation[STATEANIM::TUMBLE2] = { 380, true };// 원래 true 였음 + m_Animation[STATEANIM::PETRIFICUSED_START] = { 383, false }; + + m_Animation[STATEANIM::LAND] = { 376, false }; + m_Animation[STATEANIM::HIT_LEVIOSO] = { 381, false }; + + m_Animation[STATEANIM::DEAD_BWD] = { 317, false }; + m_Animation[STATEANIM::DEAD_BWD2] = { 318, false }; + m_Animation[STATEANIM::DEAD_FWD] = { 319, false }; + m_Animation[STATEANIM::DEAD_FWD2] = { 320, false }; + m_Animation[STATEANIM::DEAD_L] = { 321, false }; + m_Animation[STATEANIM::DEAD_L2] = { 322, false }; + m_Animation[STATEANIM::DEAD_R] = { 323, false }; + m_Animation[STATEANIM::DEAD_R2] = { 324, false }; + + //Tp 426 + // Tp Start 428 + // 76 공격끝 + + + + + + + + + // 걷기 시작 57 + // 걷기 루프 50 + // 뛰기 시작 157 + // 뛰기 루프 45 + // 나이프 던지기 85 + // 도끼 공격 444 + // 도끼 공격 후 76 + // 도끼 찍기 439 + // + + // 텀블링 히트 380 + // 디센도 찍기전 띄우기 371 + // 디센도 찍기 372 + + // 레비오소 피격 381 + // 착지 376 + // + + // Shuffle1 211 + // Shuffle2 215 + // Shuffle3 219 + // Shuffle4 223 + + //Jog 112도 L 148 + //Jog 112도 R 152 + // Jog 90 L 151 + // Jog 90 R 155 + - m_Animation[STATEANIM::JOG_FWD] = { 46,true }; - m_Animation[STATEANIM::JOG_BWD] = { 154,false }; - m_Animation[STATEANIM::SKILL] = { 70,false }; // 도끼 스윙 - m_Animation[STATEANIM::SKILL2] = { 85,false }; // 나이프 던지기 } diff --git a/Jusin154_Team3D/Editor/Private/InfoInstance.cpp b/Jusin154_Team3D/Editor/Private/InfoInstance.cpp index 34ba525ca..a7fe2580d 100644 --- a/Jusin154_Team3D/Editor/Private/InfoInstance.cpp +++ b/Jusin154_Team3D/Editor/Private/InfoInstance.cpp @@ -4,6 +4,7 @@ #include "MapInfo.h" #include "MonsterInfo.h" #include "PlayerInfo.h" +#include "Skill_Data.h" IMPLEMENT_SINGLETON(CInfoInstance) @@ -16,14 +17,17 @@ void CInfoInstance::Update(_float fTimeDelta) { m_pPlayerInfo->Update(fTimeDelta); m_pMonsterInfo->Update(fTimeDelta); - //m_pMapInfo->Update(fTimeDelta); + m_pMapInfo->Update(fTimeDelta); + m_pSkillInfo->Update(fTimeDelta); + } void CInfoInstance::Change_Level() { m_pPlayerInfo->Change_Level(); m_pMonsterInfo->Change_Level(); - //m_pMapInfo->Change_Level(); + m_pMapInfo->Change_Level(); + m_pSkillInfo->Change_Level(); } void CInfoInstance::Update_CameraCoordinateSystem(_float3& vLook, _float3& vRight) @@ -44,7 +48,7 @@ HRESULT CInfoInstance::Regist_PlayerAlly(CUnit* pUnit) HRESULT CInfoInstance::Deregist_PlayerAlly(CUnit* pUnit) { - if (nullptr == m_pMonsterInfo) { + if (nullptr == s_pInstance || nullptr == m_pMonsterInfo) { return S_OK; // 게임 종료 된 상태 } return m_pMonsterInfo->Deregist_PlayerAlly(pUnit); @@ -57,7 +61,7 @@ HRESULT CInfoInstance::Regist_ActiveMonster(CMonster* pUnit) HRESULT CInfoInstance::Deregist_ActiveMonster(CMonster* pUnit) { - if (nullptr == m_pMonsterInfo) { + if (nullptr == s_pInstance || nullptr == m_pMonsterInfo) { return S_OK; // 게임 종료 된 상태 } return m_pMonsterInfo->Deregist_ActiveMonster(pUnit); @@ -77,14 +81,33 @@ pair CInfoInstance::Get_NearestPlayerAlly(_fvector vPos) } #pragma endregion #pragma region MAP_INFO -//HRESULT CInfoInstance::Load_MapObjects(const _char* pFilePath) -//{ -// return m_pMapInfo->Load_MapObjects(pFilePath); -//} -//HRESULT CInfoInstance::Load_LightElements(const _char* pFilePath) -//{ -// return m_pMapInfo->Load_LightElements(pFilePath); -//} + +#pragma endregion + +#pragma region SPELL_INFO +HRESULT CInfoInstance::Load_SpellInfo(const _char* pFilePath) +{ + return m_pSkillInfo->Load_SpellInfo(pFilePath); +} +SPELL_INFO CInfoInstance::Get_Spell_Info(_int Spell_Info) +{ + return m_pSkillInfo->Get_Info(Spell_Info); +} + +_int CInfoInstance::Update_Spell(_int SpellIndex) +{ + return m_pSkillInfo->Update_Spell(SpellIndex); +} + +_float CInfoInstance::Get_CoolTime(_int SpellID) +{ + return m_pSkillInfo->Get_CoolTime(SpellID); +} +void CInfoInstance::Change_Canvas() +{ + +} + #pragma endregion LEVEL CInfoInstance::Get_RestartLevel() { @@ -100,11 +123,10 @@ HRESULT CInfoInstance::Initialize_Information(ID3D11Device* pDevice, ID3D11Devic SAFE_ADDREF(m_pDevice); SAFE_ADDREF(m_pContext); - //m_pMapInfo = CMapInfo::Create(pDevice, pContext); - //if (nullptr == m_pMapInfo) { - // return E_FAIL; - //} - + m_pMapInfo = CMapInfo::Create(pDevice, pContext); + if (nullptr == m_pMapInfo) { + return E_FAIL; + } m_pPlayerInfo = CPlayerInfo::Create(pDevice, pContext); if (nullptr == m_pPlayerInfo) { return E_FAIL; @@ -113,6 +135,10 @@ HRESULT CInfoInstance::Initialize_Information(ID3D11Device* pDevice, ID3D11Devic if (nullptr == m_pMonsterInfo) { return E_FAIL; } + m_pSkillInfo = CSkill_Data::Create(pDevice, pContext); + if (nullptr == m_pSkillInfo) { + return E_FAIL; + } return S_OK; @@ -122,8 +148,11 @@ void CInfoInstance::Release_Information() { DestroyInstance(); + + SAFE_RELEASE(m_pMapInfo); SAFE_RELEASE(m_pPlayerInfo); SAFE_RELEASE(m_pMonsterInfo); + SAFE_RELEASE(m_pSkillInfo); SAFE_RELEASE(m_pDevice); SAFE_RELEASE(m_pContext); SAFE_RELEASE(m_pGameInstance); diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 6245df7b2..687b123be 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -151,6 +151,9 @@ #include "Troll.h" #include "Troll_Rock.h" #include "Troll_Weapon.h" +#include "Goblin_Dagger.h" +#include "Goblin_BattleAxe.h" +#include "Goblin_Spector.h" #pragma endregion #pragma region PHYSX_HEADER @@ -1303,6 +1306,18 @@ HRESULT CLoader::Loading_For_Effect() CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Object/Wand/Wand.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationX(XMConvertToRadians(-90.f)) * XMMatrixIdentity())))) return E_FAIL; + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Dagger_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Object/Goblin_Dagger/SK_WPN_GOB_SmallSword.bin", XMMatrixIdentity())))) + return E_FAIL; + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_BattleAxe_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Object/Goblin_BattleAxe/SK_WPN_GOB_BattleAxe01.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) + return E_FAIL; + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Spector_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/GoblinSpector/GoblinSpector.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) + return E_FAIL; + vector*>> futures = {}; futures.emplace_back(Deferred_ModelLoad( @@ -1487,6 +1502,19 @@ HRESULT CLoader::Loading_For_Effect() return E_FAIL; } + + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CGoblin_Dagger::Create(m_pDevice, m_pContext)))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CGoblin_BattleAxe::Create(m_pDevice, m_pContext)))) { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CGoblin_Spector::Create(m_pDevice, m_pContext)))) { + return E_FAIL; + } + + /* For.Prototype_GameObject_Wand */ if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CWand::Create(m_pDevice, m_pContext)))) return E_FAIL; diff --git a/Jusin154_Team3D/Editor/Private/Skill_Data.cpp b/Jusin154_Team3D/Editor/Private/Skill_Data.cpp new file mode 100644 index 000000000..aca6a9e42 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/Skill_Data.cpp @@ -0,0 +1,153 @@ +#include "pch.h" +#include "Skill_Data.h" +#include "GameObject.h" +#include "UIObject.h" +#include "tinyxml2.h" +#include "InfoInstance.h" + +CSkill_Data::CSkill_Data() + :m_pInfoInstance(CInfoInstance::GetInstance()) +{ +} + +HRESULT CSkill_Data::Initialize(ID3D11Device* pDevice, ID3D11DeviceContext* pContex) +{ + return S_OK; +} + +const SPELL_INFO& CSkill_Data::Get_Info(_uint SpellID) const +{ + return SpellInfo[SpellID]; +} + +_int CSkill_Data::Update_Spell(_int SpellID) +{ + if (SpellID < 0 || SpellID > m_iSpell_Count) + return ENUM_CLASS(SKILL_TYPE::END); + + if (SpellInfo[SpellID].bUse_Skill == false) + return -1; + + if (m_bNoCool == false) + { + SpellInfo[SpellID].bUse_Skill = false; + m_iSpell_CoolTime[SpellID] = 0.f; + } + + return SpellInfo[SpellID].iSkill_Type; +} + +void CSkill_Data::Update(_float fTimeDelta) +{ + for (_int i = 0; i < m_iSpell_Count; ++i) + { + if (SpellInfo[i].bUse_Skill == false) + { + if (m_iSpell_CoolTime[i] <= 1.f) + { + m_iSpell_CoolTime[i] += fTimeDelta * (1.f / SpellInfo[i].fSpell_CoolTime); + } + else + { + SpellInfo[i].bUse_Skill = true; + } + + } + } + + if (m_bNoCool == true) + { + for (_int i = 0; i < 34; ++i) + { + m_iSpell_CoolTime[i] = 1.f; + } + } + +} + +void CSkill_Data::Change_Level() +{ +} + +_float CSkill_Data::Get_CoolTime(_int SpellID) +{ + if (SpellID < 0 || SpellID > m_iSpell_Count) + return 0.f; + + return m_iSpell_CoolTime[SpellID]; +} + +HRESULT CSkill_Data::Load_SpellInfo(const _char* pFilePath) +{ + tinyxml2::XMLDocument doc; + tinyxml2::XMLError Error = doc.LoadFile(pFilePath); + if (Error != tinyxml2::XML_SUCCESS) + return E_FAIL; + + tinyxml2::XMLElement* pSpellInfo = doc.FirstChildElement("SpellInfo"); + if (!pSpellInfo) + return E_FAIL; + + tinyxml2::XMLElement* pSpell = pSpellInfo->FirstChildElement("Spell"); + while (pSpell) + { + int id = 0; + pSpell->QueryIntAttribute("Spell_ID", &id); + + if (id >= 0 && id <= 34) + { + SpellInfo[id].iSpell_ID = id; + SpellInfo[id].pSpell_Name = CMyTools::ToWstring(pSpell->Attribute("Spell_Name")); + SpellInfo[id].pImage_Name = CMyTools::ToWstring(pSpell->Attribute("Image_Name")); + pSpell->QueryIntAttribute("Spell_Type", &SpellInfo[id].iSpell_Type); + SpellInfo[id].pType_Name = CMyTools::ToWstring(pSpell->Attribute("Type_Name")); + pSpell->QueryIntAttribute("Skill_Type", &SpellInfo[id].iSkill_Type); + pSpell->QueryFloatAttribute("Spell_Damage", &SpellInfo[id].fSpell_Damage); + pSpell->QueryFloatAttribute("Spell_Cooltime", &SpellInfo[id].fSpell_CoolTime); + pSpell->QueryFloatAttribute("Duration", &SpellInfo[id].fDuration); + pSpell->QueryIntAttribute("AnimNum", &SpellInfo[id].iAnimNum); + SpellInfo[id].pSpellInfo = CMyTools::ToWstring(pSpell->Attribute("SpellInfo")); + _int lock = 0, equip = 0, use = 0; + pSpell->QueryIntAttribute("Spell_Lock", &lock); + pSpell->QueryIntAttribute("Equip_Spell", &equip); + pSpell->QueryIntAttribute("Use_Skill", &use); + SpellInfo[id].bSpell_Lock = lock != 0; + SpellInfo[id].bEquip_Spell = equip != 0; + SpellInfo[id].bUse_Skill = use != 0; + pSpell->QueryFloatAttribute("Preview", &SpellInfo[id].fPreview); + pSpell->QueryFloatAttribute("Vidio", &SpellInfo[id].fVidio); + + m_iSpell_Count++; + m_iSpell_CoolTime[id] = 1.2f; + } + + // 항상 다음 Spell로 이동 + pSpell = pSpell->NextSiblingElement("Spell"); + } + + return S_OK; +} + +void CSkill_Data::NoCool(_bool bNoCool) +{ + m_bNoCool = bNoCool; +} + +CSkill_Data* CSkill_Data::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CSkill_Data* pInstance = new CSkill_Data(); + + if (FAILED(pInstance->Initialize(pDevice, pContext))) + { + MSG_BOX("Failed to Created : CSkill_Data"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CSkill_Data::Free() +{ + __super::Free(); +} + diff --git a/Jusin154_Team3D/Editor/Private/State_Blink.cpp b/Jusin154_Team3D/Editor/Private/State_Blink.cpp new file mode 100644 index 000000000..a0e5e4522 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/State_Blink.cpp @@ -0,0 +1,64 @@ +#include "pch.h" +#include "State_Blink.h" +#include "Unit.h" + + +CState_Blink::CState_Blink() + :CState_Root() +{ +} + +void CState_Blink::Enter() +{ + __super::Enter(); +} + +HRESULT CState_Blink::Update(_float fTimeDelta) +{ + if (nullptr != m_funcPriorityUpdate) { + m_funcPriorityUpdate(fTimeDelta); + } + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + if (nullptr != m_funcLateUpdate) { + m_funcLateUpdate(fTimeDelta); + } + return S_OK; +} + +void CState_Blink::Exit() +{ + __super::Exit(); +} + +HRESULT CState_Blink::Initialize(STATE_BLINK_DESC* pDesc) +{ + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_funcPriorityUpdate = pDesc->funcPriorityUpdate; + m_funcLateUpdate = pDesc->funcLateUpdate; + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); + + return S_OK; +} + +CState_Blink* CState_Blink::Create(STATE_BLINK_DESC* pDesc) +{ + CState_Blink* pInstance = new CState_Blink; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; +} + +void CState_Blink::Free() +{ + __super::Free(); +} + +void CState_Blink::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Editor/Private/State_Dead.cpp b/Jusin154_Team3D/Editor/Private/State_Dead.cpp new file mode 100644 index 000000000..ef3f575f7 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/State_Dead.cpp @@ -0,0 +1,67 @@ +#include "pch.h" +#include "State_Dead.h" +#include "Unit.h" + + +CState_Dead::CState_Dead() + :CState_Root() +{ +} + +void CState_Dead::Enter() +{ + __super::Enter(); +} + +HRESULT CState_Dead::Update(_float fTimeDelta) +{ + HRESULT hr = (__super::Update(fTimeDelta)); + switch (hr) + { + case E_PENDING: + m_vDeadTimer.x += fTimeDelta; + break; + default: + break; + } + m_funcLateUpdate(m_vDeadTimer.x / m_vDeadTimer.y); + if (m_vDeadTimer.x >= m_vDeadTimer.y) { + return E_FAIL; + } + return S_OK; +} + +void CState_Dead::Exit() +{ + __super::Exit(); +} + +HRESULT CState_Dead::Initialize(STATE_DEAD_DESC* pDesc) +{ + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); + m_vDeadTimer = pDesc->vDeadTimer; + m_funcLateUpdate = pDesc->funcLateUpdate; + return S_OK; +} + +CState_Dead* CState_Dead::Create(STATE_DEAD_DESC* pDesc) +{ + CState_Dead* pInstance = new CState_Dead; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; +} + +void CState_Dead::Free() +{ + __super::Free(); +} + +void CState_Dead::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Editor/Private/State_Shuffle.cpp b/Jusin154_Team3D/Editor/Private/State_Shuffle.cpp new file mode 100644 index 000000000..d569201bd --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/State_Shuffle.cpp @@ -0,0 +1,64 @@ +#include "pch.h" +#include "State_Shuffle.h" +#include "GameInstance.h" +#include "Unit.h" + +CState_Shuffle::CState_Shuffle() + :CState_Root() +{ +} + +void CState_Shuffle::Enter() +{ + __super::Enter(); +} + +HRESULT CState_Shuffle::Update(_float fTimeDelta) +{ + if (nullptr != m_funcPriorityUpdate) { + m_funcPriorityUpdate(fTimeDelta); + } + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + if (nullptr != m_funcLateUpdate) { + m_funcLateUpdate(fTimeDelta); + } + return S_OK; +} + +void CState_Shuffle::Exit() +{ + __super::Exit(); +} + +HRESULT CState_Shuffle::Initialize(STATE_SHUFFLE_DESC* pDesc) +{ + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_funcPriorityUpdate = pDesc->funcPriorityUpdate; + m_funcLateUpdate = pDesc->funcLateUpdate; + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); + + return S_OK; +} + +CState_Shuffle* CState_Shuffle::Create(STATE_SHUFFLE_DESC* pDesc) +{ + CState_Shuffle* pInstance = new CState_Shuffle; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; +} + +void CState_Shuffle::Free() +{ + __super::Free(); +} + +void CState_Shuffle::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Editor/Public/Editor_Define.h b/Jusin154_Team3D/Editor/Public/Editor_Define.h index e21106f48..374a99796 100644 --- a/Jusin154_Team3D/Editor/Public/Editor_Define.h +++ b/Jusin154_Team3D/Editor/Public/Editor_Define.h @@ -18,7 +18,7 @@ namespace Editor enum class MAPOBJECT_TYPE { CONTAINER, ELEMENT_STATIC, ELEMENT_INTERACT, ELEMENT_LIGHT }; enum class MAPOBJECT_RENDER_TYPE { NORMAL, DECAL, GLASS }; - enum class SHADER_PASS_ANIM { DEFAULT, SHADOW, CAPTURE, BLUR, HAIR, EYELASH, OUTLINE_WRITE, OUTLINE_READ, END }; + enum class SHADER_PASS_ANIM { DEFAULT, SHADOW, CAPTURE, BLUR, HAIR, EYELASH, OUTLINE_WRITE, OUTLINE_READ, SPECTOR, END }; enum class SHADER_PASS_MESH { DEFAULT, SHADOW, SKYBOX, ALPHABLEND, EFFECT_ALPHABLEND, EFFECT_BLEND, EFFECT_ALPHABLEND_CULL, EFFECT_BLEND_CULL, CAPTURE, BLUR, EFFECT_ALPHABLEND_UVMOVE, MAPTOOL, GLASS, OUTLINE_WRITE, OUTLINE_READ, BLOOM, LAKE, END }; enum class SHADER_PASS_NORTEX { DEFAULT, TERRAIN, ENV_TERRAIN_ANISO, SHADOW, END }; enum class SHADER_PASS_PARTICLE { EXPLOSION, END }; diff --git a/Jusin154_Team3D/Editor/Public/Editor_Struct.h b/Jusin154_Team3D/Editor/Public/Editor_Struct.h index a852a7670..5631ed104 100644 --- a/Jusin154_Team3D/Editor/Public/Editor_Struct.h +++ b/Jusin154_Team3D/Editor/Public/Editor_Struct.h @@ -40,5 +40,23 @@ typedef struct tagFolderLoad { vector LoadedRigidBody; }FOLDER_LOAD; - +typedef struct tagSpellInfo +{ + _int iSpell_ID{}; + _wstring pSpell_Name; + _wstring pImage_Name; + _int iSpell_Type{}; + _wstring pType_Name; + _int iSkill_Type{}; + _float fSpell_Damage{}; + _float fSpell_CoolTime{}; + _float fDuration{}; + _int iAnimNum{}; + _wstring pSpellInfo; + _bool bSpell_Lock = false; + _bool bEquip_Spell = false; + _bool bUse_Skill = false; + _float fPreview{}; + _float fVidio{}; +}SPELL_INFO; NS_END diff --git a/Jusin154_Team3D/Editor/Public/Goblin.h b/Jusin154_Team3D/Editor/Public/Goblin.h index 82b101400..a2a62ce75 100644 --- a/Jusin154_Team3D/Editor/Public/Goblin.h +++ b/Jusin154_Team3D/Editor/Public/Goblin.h @@ -9,18 +9,28 @@ NS_BEGIN(Editor) class CGoblin final : public CMonster { + enum class GOBLIN_SKILL + { + SWING, + THROW, + TP, + END + }; private: CGoblin(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CGoblin(const CGoblin& Prototype); virtual ~CGoblin() = default; public: - virtual HRESULT Initialize_Prototype() override; - virtual HRESULT Initialize(void* pArg) override; virtual void Priority_Update(_float fTimeDelta) override; virtual void Update(_float fTimeDelta) override; virtual void Late_Update(_float fTimeDelta) override; virtual HRESULT Render() override; + virtual HRESULT Render_Shadow() override; + virtual _vector Get_LockOnPos() override; + virtual void OnCollision(CGameObject* pOther = nullptr, void* pDesc = nullptr)override; + virtual void OnHit(CGameObject* pOther, CGameObject* pCaller = nullptr)override; + _bool Get_Swing() { return m_bSwing; } private: CCallBack_Monster_Behavior* m_pCallBack_Behavior = { nullptr }; @@ -28,39 +38,82 @@ class CGoblin final : public CMonster CCharacter_Controller* m_pCharacter_Controller = { nullptr }; CRigidBody_Dynamic* m_pRigidBody = { nullptr }; + _float2 m_vStunTimer = { 0.f, 4.f }; + _uint iIndex; - class CEditEffect* m_pRight_Smoke = { nullptr }; - class CEditEffect* m_pLeft_Smoke = { nullptr }; - class CEditEffect* m_pTroll_Particle = { nullptr }; - class CEditEffect* m_pTroll_Particle2 = { nullptr }; + + class CEditEffect* m_pSmoke = { nullptr }; + class CEditEffect* m_pGoblin_Particle = { nullptr }; + class CEditEffect* m_pGoblin_Particle2 = { nullptr }; private: + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; HRESULT Ready_Components(); - HRESULT Bind_ShaderResources(); HRESULT Ready_Parts(); + HRESULT Bind_ShaderResources(); + public: static CGoblin* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override; virtual void Free() override; +#ifdef _DEBUG virtual void Describe_Entity() override; +#endif // _DEBUG + private: virtual void Add_FSM(); virtual void Set_Anim(); + _float m_fSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::END)] = {}; + _float m_fMaxSkillCoolTime[ENUM_CLASS(GOBLIN_SKILL::END)] = { 6.f,2.f,15.f }; + + _bool m_bStep = { false }; + _float m_fTpTime = {}; + _float m_fAirTime = {}; + _vector m_vOriginPos = {}; + _float m_fLength = {}; + _bool m_bSwing = { false }; + _float m_fMoveTime = {}; + _bool m_bFirstMove = {}; void Behavior_IdleEnter(); HRESULT Behavior_IdleExitCheck(); void Behavior_IdleExit(); void Behavior_MoveEnter(); - HRESULT Behavior_MoveExitCheck(); + HRESULT Behavior_MoveExitCheck(_float fTimeDelta); void Behavior_MoveExit(); void Behavior_CombatEnter(); - HRESULT Behavior_CombatExitCheck(); + HRESULT Behavior_CombatExitCheck(_float fTimeDelta); void Behavior_CombatExit(); + + void Behavior_SwingEnter(); + HRESULT Behavior_SwingExitCheck(_float fTimeDelta); + void Behavior_SwingExit(); + + void Behavior_ThrowEnter(); + HRESULT Behavior_ThrowExitCheck(_float fTimeDelta); + void Behavior_ThrowExit(); + + void Behavior_BlinkEnter(); + HRESULT Behavior_BlinkExitCheck(_float fTimeDelta); + void Behavior_BlinkExit(); + + void Behavior_ShuffleEnter(); + HRESULT Behavior_ShuffleExitCheck(_float fTimeDelta); + void Behavior_ShuffleExit(); + + void Behavior_HitEnter(); + HRESULT Behavior_HitExitCheck(_float fTimeDelta); + void Behavior_HitExit(); + + void Behavior_DeadEnter(); + HRESULT Behavior_DeadExitCheck(_float fTimeDelta); + void Behavior_DeadExit(); }; NS_END diff --git a/Jusin154_Team3D/Editor/Public/Goblin_BattleAxe.h b/Jusin154_Team3D/Editor/Public/Goblin_BattleAxe.h new file mode 100644 index 000000000..d1c66d755 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/Goblin_BattleAxe.h @@ -0,0 +1,48 @@ +#pragma once + +#include "Editor_Define.h" +#include "PartObject.h" + +NS_BEGIN(Editor) + +class CGoblin_BattleAxe final : public CPartObject +{ +public: + typedef struct tagGoblinBattleAxe : public CPartObject::PARTOBJECT_DESC + { + const _float4x4* pSocketMatrices = { }; + }GOBLIN_BATTLEAXE_DESC; +private: + CGoblin_BattleAxe(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CGoblin_BattleAxe(const CGoblin_BattleAxe& Prototype); + virtual ~CGoblin_BattleAxe() = default; + +public: + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + virtual void Priority_Update(_float fTimeDelta) override; + virtual void Update(_float fTimeDelta) override; + virtual void Late_Update(_float fTimeDelta) override; + virtual HRESULT Render() override; +public: + +private: + const _float4x4* m_pSocketMatrices = { }; + CShader* m_pShaderCom = { nullptr }; + CModel* m_pModelCom = { nullptr }; + +private: + HRESULT Ready_Components(); + HRESULT Bind_ShaderResources(); + +public: + static CGoblin_BattleAxe* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr)override; + virtual void Free() override; + +#ifdef _DEBUG + void Describe_Entity() override; +#endif // _DEBUG +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/Goblin_Dagger.h b/Jusin154_Team3D/Editor/Public/Goblin_Dagger.h new file mode 100644 index 000000000..9200d6cc1 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/Goblin_Dagger.h @@ -0,0 +1,50 @@ +#pragma once + +#include "Editor_Define.h" +#include "PartObject.h" + +NS_BEGIN(Editor) + +class CGoblin_Dagger final : public CPartObject +{ +public: + typedef struct tagDagger : public CPartObject::PARTOBJECT_DESC + { + const _float4x4* pSocketMatrices = { }; + }GOBLINDAGGER_DESC; +private: + CGoblin_Dagger(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CGoblin_Dagger(const CGoblin_Dagger& Prototype); + virtual ~CGoblin_Dagger() = default; + +public: + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + virtual void Priority_Update(_float fTimeDelta) override; + virtual void Update(_float fTimeDelta) override; + virtual void Late_Update(_float fTimeDelta) override; + virtual HRESULT Render() override; + void Set_Attach(_bool Attach) { m_bAttach = Attach; } +public: + +private: + const _float4x4* m_pSocketMatrices = { }; + CShader* m_pShaderCom = { nullptr }; + CModel* m_pModelCom = { nullptr }; + _bool m_bAttach = { true }; + +private: + HRESULT Ready_Components(); + HRESULT Bind_ShaderResources(); + +public: + static CGoblin_Dagger* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr)override; + virtual void Free() override; + +#ifdef _DEBUG + void Describe_Entity() override; +#endif // _DEBUG +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/Goblin_Spector.h b/Jusin154_Team3D/Editor/Public/Goblin_Spector.h new file mode 100644 index 000000000..9a9d4ee80 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/Goblin_Spector.h @@ -0,0 +1,74 @@ +#pragma once + +#include "Editor_Define.h" +#include "Monster.h" +#include "CallBack_Monster_Behavior.h" +#include "CallBack_Monster_HitReport.h" + +NS_BEGIN(Engine) +class CTransform; +NS_END + +NS_BEGIN(Editor) + +class CGoblin_Spector final : public CMonster +{ +public: + typedef struct tagSpector + { + CTransform* pParentTransform = { nullptr }; + }GOBLIN_SPECTOR_DESC; +private: + CGoblin_Spector(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CGoblin_Spector(const CGoblin_Spector& Prototype); + virtual ~CGoblin_Spector() = default; + +public: + virtual void Priority_Update(_float fTimeDelta) override; + virtual void Update(_float fTimeDelta) override; + virtual void Late_Update(_float fTimeDelta) override; + virtual HRESULT Render() override; + virtual void OnCollision(CGameObject* pOther = nullptr, void* pDesc = nullptr)override; + virtual void OnHit(CGameObject* pOther, CGameObject* pCaller = nullptr)override; + + +private: + class CGoblin* m_pGoblin = { nullptr }; + CTransform* m_pParentTransformCom = { nullptr }; + _uint iIndex; + _float3 m_Offset = {}; + _float3 m_vOriginScale = {}; + _float3 m_vScale = { 1.f, 1.f, 1.f }; + + + + class CEditEffect* m_pSmoke = { nullptr }; + class CEditEffect* m_pGoblin_Particle = { nullptr }; + class CEditEffect* m_pGoblin_Particle2 = { nullptr }; + +private: + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + HRESULT Ready_Components(); + HRESULT Ready_Parts(); + HRESULT Bind_ShaderResources(); + +public: + static CGoblin_Spector* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override; + virtual void Free() override; +#ifdef _DEBUG + virtual void Describe_Entity() override; + +#endif // _DEBUG + + + _bool m_bStep = { false }; + _float m_fTpTime = {}; + _float m_fAirTime = {}; + _vector m_vOriginPos = {}; + _float m_fLength = {}; + +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/InfoInstance.h b/Jusin154_Team3D/Editor/Public/InfoInstance.h index 3c24a8b6a..70d36c189 100644 --- a/Jusin154_Team3D/Editor/Public/InfoInstance.h +++ b/Jusin154_Team3D/Editor/Public/InfoInstance.h @@ -39,22 +39,25 @@ class CInfoInstance final : public CBase pair Get_NearestPlayerAlly(_fvector vPos); #pragma endregion #pragma region MAP_INFO - //HRESULT Load_MapObjects(const _char* pFilePath); - //HRESULT Load_LightElements(const _char* pFilePath); #pragma endregion #pragma region Spell_INFO HRESULT Load_SpellInfo(const _char* pFilePath); + SPELL_INFO Get_Spell_Info(_int Spell_Info); + _int Update_Spell(_int SpellIndex); + _float Get_CoolTime(_int SpellID); + void Change_Canvas(); + #pragma endregion - - private: - CGameInstance* m_pGameInstance = { nullptr }; - ID3D11Device* m_pDevice = { nullptr }; - ID3D11DeviceContext* m_pContext = { nullptr }; + CGameInstance* m_pGameInstance = { nullptr }; + ID3D11Device* m_pDevice = { nullptr }; + ID3D11DeviceContext* m_pContext = { nullptr }; - class CPlayerInfo* m_pPlayerInfo = { nullptr }; - class CMonsterInfo* m_pMonsterInfo = { nullptr }; - class CMapInfo* m_pMapInfo = { nullptr }; + class CPlayerInfo* m_pPlayerInfo = { nullptr }; + class CMonsterInfo* m_pMonsterInfo = { nullptr }; + class CMapInfo* m_pMapInfo = { nullptr }; + class CSkill_Data* m_pSkillInfo = { nullptr }; + _int m_eSpell = ENUM_CLASS(SKILL_TYPE::END); #ifdef _DEBUG _string m_strLog = {}; diff --git a/Jusin154_Team3D/Editor/Public/Monster.h b/Jusin154_Team3D/Editor/Public/Monster.h index bb03f7c3a..120de267e 100644 --- a/Jusin154_Team3D/Editor/Public/Monster.h +++ b/Jusin154_Team3D/Editor/Public/Monster.h @@ -31,7 +31,7 @@ class CMonster abstract : public CUnit _float m_fTargetDistance = { FLT_MAX }; _bool m_bDrawOutLine = { false }; _bool m_bLookAt = { true }; - + _float m_fDeadRatio = { 0.f }; protected: virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; diff --git a/Jusin154_Team3D/Editor/Public/Skill_Data.h b/Jusin154_Team3D/Editor/Public/Skill_Data.h new file mode 100644 index 000000000..d4bd1e0d8 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/Skill_Data.h @@ -0,0 +1,53 @@ +#pragma once + +#include "Editor_Define.h" +#include "Base.h" + +NS_BEGIN(Engine) +class CGameInstance; +class CUIObject; +NS_END + +NS_BEGIN(Editor) + +class CSkill_Data final : public CBase +{ +public: + +private: + CSkill_Data(); + ~CSkill_Data() = default; + +public: + void Update(_float fTimeDelta); + void Change_Level(); + _float Get_CoolTime(_int SpellID); + +public: + HRESULT Load_SpellInfo(const _char* pFilePath); + + void NoCool(_bool bNoCool); + +public: + const SPELL_INFO& Get_Info(_uint SpellID) const; + _int Update_Spell(_int SpellID); + +private: + class CInfoInstance* m_pInfoInstance = { nullptr }; + + _int m_iSpell_Count{}; + SPELL_INFO SpellInfo[34] = {}; + _float m_iSpell_CoolTime[34] = {}; + + _bool m_bNoCool = { false }; + +private: + HRESULT Initialize(ID3D11Device* pDevice, ID3D11DeviceContext* pContex); + + +public: + static CSkill_Data* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual void Free() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/State_Blink.h b/Jusin154_Team3D/Editor/Public/State_Blink.h new file mode 100644 index 000000000..0abc313ba --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/State_Blink.h @@ -0,0 +1,36 @@ +#pragma once +#include "Editor_Define.h" +#include "State_Root.h" + +NS_BEGIN(Editor) + +class CState_Blink final : public CState_Root +{ +public: + typedef struct tagBlink : public CState_Root::STATE_ROOT_DESC { + function funcPriorityUpdate = { nullptr }; + function funcLateUpdate = { nullptr }; + }STATE_BLINK_DESC; +private: + CState_Blink(); + virtual ~CState_Blink() = default; + +public: + virtual void Enter(); + virtual HRESULT Update(_float fTimeDelta); + virtual void Exit(); + +private: + function m_funcPriorityUpdate = { nullptr }; + function m_funcLateUpdate = { nullptr }; + +private: + HRESULT Initialize(STATE_BLINK_DESC* pDesc); + +public: + static CState_Blink* Create(STATE_BLINK_DESC* pDesc); + virtual void Free() override; + virtual void Describe_Entity(); +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/State_Dead.h b/Jusin154_Team3D/Editor/Public/State_Dead.h new file mode 100644 index 000000000..9a05ac180 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/State_Dead.h @@ -0,0 +1,33 @@ +#pragma once +#include "Editor_Define.h" +#include "State_Root.h" + +NS_BEGIN(Editor) + +class CState_Dead final : public CState_Root +{ +public: + typedef struct tagLand : public CState_Root::STATE_ROOT_DESC { + _float2 vDeadTimer = { 0.f, 2.f }; + function funcLateUpdate = { nullptr }; + }STATE_DEAD_DESC; +private: + CState_Dead(); + virtual ~CState_Dead() = default; + +public: + virtual void Enter(); + virtual HRESULT Update(_float fTimeDelta); + virtual void Exit(); + +private: + HRESULT Initialize(STATE_DEAD_DESC* pDesc); + _float2 m_vDeadTimer = { 0.f, 2.f }; + function m_funcLateUpdate = { nullptr }; +public: + static CState_Dead* Create(STATE_DEAD_DESC* pDesc); + virtual void Free() override; + virtual void Describe_Entity(); +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/State_Shuffle.h b/Jusin154_Team3D/Editor/Public/State_Shuffle.h new file mode 100644 index 000000000..fa0ef12e4 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/State_Shuffle.h @@ -0,0 +1,36 @@ +#pragma once +#include "Editor_Define.h" +#include "State_Root.h" + +NS_BEGIN(Editor) + +class CState_Shuffle final : public CState_Root +{ +public: + typedef struct tagShuffle : public CState_Root::STATE_ROOT_DESC { + function funcPriorityUpdate = { nullptr }; + function funcLateUpdate = { nullptr }; + }STATE_SHUFFLE_DESC; +public: + CState_Shuffle(); + virtual ~CState_Shuffle() = default; + +public: + virtual void Enter(); + virtual HRESULT Update(_float fTimeDelta); + virtual void Exit(); + +private: + function m_funcPriorityUpdate = { nullptr }; + function m_funcLateUpdate = { nullptr }; + +private: + HRESULT Initialize(STATE_SHUFFLE_DESC* pDesc); + +public: + static CState_Shuffle* Create(STATE_SHUFFLE_DESC* pDesc); + virtual void Free() override; + virtual void Describe_Entity(); +}; + +NS_END diff --git a/Jusin154_Team3D/Engine/Private/ComputeShader.cpp b/Jusin154_Team3D/Engine/Private/ComputeShader.cpp index c30a60077..62deb845e 100644 --- a/Jusin154_Team3D/Engine/Private/ComputeShader.cpp +++ b/Jusin154_Team3D/Engine/Private/ComputeShader.cpp @@ -45,12 +45,7 @@ vector CComputeShader::Dispatch(_uint iSRVIndex, _uint for (_uint i = 0; i < m_iNumInputBuffer; i++) { - D3D11_MAPPED_SUBRESOURCE PreSubResource = {}; - - m_pContext->CopyResource(m_pInputStagingBuffer[i], ppBuffers[i]); - - m_pContext->CopyResource(m_pInputBuffer[i], m_pInputStagingBuffer[i]); - + m_pContext->CopyResource(m_pInputBuffer[i], ppBuffers[i]); } @@ -76,18 +71,7 @@ vector CComputeShader::Dispatch(_uint iSRVIndex, _uint for (_uint i = 0; i < m_iNumOutputBuffer; i++) { - m_pContext->CopyResource(m_pOutputStagingBuffer[i], m_pOutputBuffer[i]); - - //스테이징 버퍼를 열어서 카피함 - D3D11_MAPPED_SUBRESOURCE StagingSubResource = {}; - - if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0, D3D11_MAP_READ, 0, &StagingSubResource))) - { - StagingSubResources.push_back(StagingSubResource); - - m_pContext->Unmap(m_pOutputStagingBuffer[i], 0); - } - + m_pContext->CopyResource(ppBuffers[i], m_pOutputBuffer[i]); } Reset(); @@ -128,32 +112,6 @@ ID3D11UnorderedAccessView* CComputeShader::GetOutputUAV(_uint iIndex) const return m_pOutputUAV[iIndex]; } -vector CComputeShader::ReadBackOutputs() -{ - std::vector StagingSubResources; - StagingSubResources.reserve(m_iNumOutputBuffer); - - for (_uint i = 0; i < m_iNumOutputBuffer; ++i) - { - if (m_pOutputStagingBuffer[i] == nullptr || m_pOutputBuffer[i] == nullptr) - continue; - - m_pContext->CopyResource(m_pOutputStagingBuffer[i], m_pOutputBuffer[i]); - - D3D11_MAPPED_SUBRESOURCE mapped = {}; - if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0, - D3D11_MAP_READ, 0, &mapped))) - { - StagingSubResources.push_back(mapped); - - m_pContext->Unmap(m_pOutputStagingBuffer[i], 0); - } - } - - return StagingSubResources; - -} - void CComputeShader::Reset() @@ -200,22 +158,6 @@ HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iInputStructStride return E_FAIL; m_pInputBuffer.push_back(pInputBuffer); - - //스테이징 버퍼 이름 - D3D11_BUFFER_DESC StagingBufferDesc = {}; - StagingBufferDesc.Usage = D3D11_USAGE_STAGING; // 스테이징 버퍼 - StagingBufferDesc.ByteWidth = iInputStructStride[i] * iNumElement; - StagingBufferDesc.StructureByteStride = iInputStructStride[i]; - StagingBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; - - ID3D11Buffer* pStagingBuffer = nullptr; - - if (FAILED(m_pDevice->CreateBuffer(&StagingBufferDesc, nullptr, &pStagingBuffer))) - return E_FAIL; - - m_pInputStagingBuffer.push_back(pStagingBuffer); - - } for (_uint i = 0; i < m_iNumOutputBuffer; i++) @@ -239,20 +181,6 @@ HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iInputStructStride return E_FAIL; m_pOutputBuffer.push_back(pOutputBuffer); - - //아웃풋 스테이징 버퍼 - D3D11_BUFFER_DESC OutPutStagingBufferDesc = {}; - OutPutStagingBufferDesc.Usage = D3D11_USAGE_STAGING; // 스테이징 버퍼 - OutPutStagingBufferDesc.ByteWidth = iOuputStructStride[i] * iNumElement; - OutPutStagingBufferDesc.StructureByteStride = iOuputStructStride[i]; - OutPutStagingBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; - - ID3D11Buffer* pOutputStagingBuffer = nullptr; - - if (FAILED(m_pDevice->CreateBuffer(&OutPutStagingBufferDesc, nullptr, &pOutputStagingBuffer))) - return E_FAIL; - - m_pOutputStagingBuffer.push_back(pOutputStagingBuffer); } return S_OK; @@ -376,7 +304,6 @@ void CComputeShader::Free() { SAFE_RELEASE(m_pInputSRV[i]); SAFE_RELEASE(m_pInputBuffer[i]); - SAFE_RELEASE(m_pInputStagingBuffer[i]); } for (_uint i = 0; i < m_iNumOutputBuffer; i++) @@ -384,7 +311,6 @@ void CComputeShader::Free() SAFE_RELEASE(m_pOutputUAV[i]); SAFE_RELEASE(m_pOutputBuffer[i]); SAFE_RELEASE(m_pOutputSRV[i]); - SAFE_RELEASE(m_pOutputStagingBuffer[i]); } diff --git a/Jusin154_Team3D/Engine/Private/Instance_Model.cpp b/Jusin154_Team3D/Engine/Private/Instance_Model.cpp index 456258b75..1c4732041 100644 --- a/Jusin154_Team3D/Engine/Private/Instance_Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Instance_Model.cpp @@ -63,7 +63,7 @@ HRESULT CInstance_Model::Initialize_Prototype(const _char* pModelFilePath, MODEL return E_FAIL; } - SaveAssimpModel(Temp , m_pAIScene); + SaveAssimpModel(Temp, m_pAIScene); return S_OK; } #pragma region Mesh @@ -171,7 +171,7 @@ HRESULT CInstance_Model::Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fma #endif #ifdef EDITOR_PROJECT -_bool CInstance_Model::SaveAssimpModel(const _char* filename , const aiScene* pAIScene) +_bool CInstance_Model::SaveAssimpModel(const _char* filename, const aiScene* pAIScene) { if (!pAIScene) { return false; @@ -416,7 +416,7 @@ HRESULT CInstance_Model::Change_NumInstance() HRESULT CInstance_Model::Create_Instance_Buffer() { - + m_iNumInstance = m_InstanceDesc.iNumInstance; @@ -517,7 +517,7 @@ HRESULT CInstance_Model::Initialize(void* pArg) //시작 시에 인스턴트 버퍼를 구성 해줌 Instane_Buffer_ReStruct(); - if(FAILED(Create_CS())) + if (FAILED(Create_CS())) return E_FAIL; return S_OK; @@ -551,7 +551,7 @@ void CInstance_Model::Drop(_float fTimeDelta) pDesc->ProjMatrix = *m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ); pDesc->fFar = *m_pGameInstance->Get_CurrentCameraFar(); pDesc->vScreenSize = m_pGameInstance->Get_ViewPortSize(); - + m_pContext->Unmap(m_pConstantBuffer, 0); @@ -575,27 +575,6 @@ void CInstance_Model::Drop(_float fTimeDelta) OutSubResources = m_pComputeShader->Dispatch(0, 0, _float3((_float)iGroupCountX, 1.f, 1.f), CSBuffers, m_pConstantBuffer); - if (SUCCEEDED(m_pContext->Map(m_pVBInstance, 0, D3D11_MAP_WRITE_DISCARD, 0, &VBInstanceResource))) - { - - memcpy(VBInstanceResource.pData, OutSubResources[0].pData, m_iInstanceStride * m_InstanceDesc.iNumInstance); // 아웃풋 버퍼에 들어온 값들을 전부 복사한다. - - m_pContext->Unmap(m_pVBInstance, 0); - } - - D3D11_MAPPED_SUBRESOURCE ParticleValueResource = {}; - - if (SUCCEEDED(m_pContext->Map(m_pParticleValueBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &ParticleValueResource))) - { - CS_PARTICLE_VALUE_DESC* pValueDesc = static_cast(OutSubResources[1].pData); - - memcpy(ParticleValueResource.pData, OutSubResources[1].pData, sizeof(CS_PARTICLE_VALUE_DESC) * m_InstanceDesc.iNumInstance); // 아웃풋 버퍼에 들어온 값들을 전부 복사한다. - - - m_pContext->Unmap(m_pParticleValueBuffer, 0); - } - - } @@ -704,7 +683,7 @@ void CInstance_Model::Instane_Buffer_ReStruct() m_pGameInstance->Random_Float(m_InstanceDesc.vVelocityMin.x, m_InstanceDesc.vVelocityMax.x), m_pGameInstance->Random_Float(m_InstanceDesc.vVelocityMin.y, m_InstanceDesc.vVelocityMax.y), m_pGameInstance->Random_Float(m_InstanceDesc.vVelocityMin.z, m_InstanceDesc.vVelocityMax.z) - ); + ); pParticleValues[i].vVelocity = vVelocity; @@ -734,7 +713,7 @@ void CInstance_Model::Instane_Buffer_ReStruct() pParticleValues[i].fSizeDrag = m_pGameInstance->Random_Float(m_InstanceDesc.vSizeDrag.x, m_InstanceDesc.vSizeDrag.y); pParticleValues[i].vDelay = _float2(0.0f, m_pGameInstance->Random_Float(m_InstanceDesc.vDelay.x, m_InstanceDesc.vDelay.y)); pParticleValues[i].fDropAttenuation = m_pGameInstance->Random_Float(m_InstanceDesc.vDropAttenuation.x, m_InstanceDesc.vDropAttenuation.y); - + pParticleValues[i].fCollisionTime = 0.f; pParticleValues[i].isCompareStop = false; @@ -814,7 +793,7 @@ void CInstance_Model::Free() SAFE_RELEASE(m_pComputeShader); SAFE_RELEASE(m_pConstantBuffer); SAFE_RELEASE(m_pParticleValueBuffer); -; + ; } #ifdef _DEBUG @@ -846,7 +825,7 @@ void CInstance_Model::Describe_Entity() { Instane_Buffer_ReStruct(); } - + if (GUI::Checkbox("Sin Wave", &m_InstanceDesc.isSinWave)) { Instane_Buffer_ReStruct(); @@ -1060,7 +1039,7 @@ void CInstance_Model::Describe_Entity() Instane_Buffer_ReStruct(); } - + ImGui::PopItemWidth(); ImGui::TreePop(); diff --git a/Jusin154_Team3D/Engine/Private/Model.cpp b/Jusin154_Team3D/Engine/Private/Model.cpp index 55b1fedff..dbcadff39 100644 --- a/Jusin154_Team3D/Engine/Private/Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Model.cpp @@ -1238,28 +1238,7 @@ HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fma #endif // EDITOR_PROJECT -HRESULT CModel::Create_CS() -{ - _uint CS1_InputStrides[] = { - sizeof(KEYFRAME_DESC), - sizeof(CHANNEL_DESC), - }; - _uint CS1_OutputStrides[] = { - sizeof(LOCALPOS_DESC), - sizeof(LOCALPOS_DESC), - }; - - - m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext, L"../Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl", - "CS_LocalSRT", (_uint)m_Bones.size(), 0, 2, nullptr, CS1_OutputStrides - ); - - if (!m_pComputeShader) - return E_FAIL; - - return S_OK; -} void CModel::Create_Temp() { @@ -1288,85 +1267,7 @@ void CModel::Create_LocalPosVB() } -void CModel::Create_Con() -{ - D3D11_BUFFER_DESC cbDesc = {}; - cbDesc.Usage = D3D11_USAGE_DYNAMIC; - cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - cbDesc.ByteWidth = sizeof(ANIMSTATE_DESC); - if (FAILED(m_pDevice->CreateBuffer(&cbDesc, nullptr, &m_pConstantBuffer))) - return; -} - - -void CModel::UpdateAnimationCS(_uint AnimIndex) -{ - D3D11_MAPPED_SUBRESOURCE sub{}; - if (SUCCEEDED(m_pContext->Map(m_pConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sub))) - { - ANIMSTATE_DESC* pDesc = (ANIMSTATE_DESC*)sub.pData; - - CAnimation* pAnim = m_Animations[AnimIndex]; - pDesc->CurrentTime = pAnim->Get_CurrentTrackPosition(); - pDesc->Duration = pAnim->Get_Duration(); - pDesc->Speed = pAnim->Get_AnimSpeed(); - pDesc->BoneCount = (_uint)m_Bones.size(); - pDesc->PreTransformMatrix = m_PreTransformMatrix; - m_pContext->Unmap(m_pConstantBuffer, 0); - } -} - -void CModel::ComputeAnimation(_uint AnimIndex) -{ - UpdateAnimationCS(AnimIndex); - - _uint iGroupCountX = ((_uint)m_Bones.size() + 255) / 256; - - CAnimation* pAnim = m_Animations[AnimIndex]; - ID3D11ShaderResourceView* srvs[2] = { - pAnim->Get_KeyFrameSrv(), - pAnim->Get_ChannelSrv(), - }; - - m_pContext->CSSetShader(m_pComputeShader->Get_Compute(), nullptr, 0); - m_pContext->CSSetConstantBuffers(0, 1, &m_pConstantBuffer); - m_pContext->CSSetShaderResources(0, 2, srvs); - - ID3D11UnorderedAccessView* uavs[1] = { m_pComputeShader->GetOutputUAV(0) }; - m_pContext->CSSetUnorderedAccessViews(0, 1, uavs, nullptr); - - m_pContext->Dispatch(iGroupCountX, 1, 1); - - auto outSubs = m_pComputeShader->ReadBackOutputs(); - m_pLocalPos[0] = static_cast(outSubs[0].pData); -} - -void CModel::ComputeAnimation_Second(_uint AnimIndex) -{ - UpdateAnimationCS(AnimIndex); - - _uint iGroupCountX = ((_uint)m_Bones.size() + 255) / 256; - - CAnimation* pAnim = m_Animations[AnimIndex]; - ID3D11ShaderResourceView* srvs[2] = { - pAnim->Get_KeyFrameSrv(), - pAnim->Get_ChannelSrv(), - }; - - m_pContext->CSSetShader(m_pComputeShader->Get_Compute(), nullptr, 0); - m_pContext->CSSetConstantBuffers(0, 1, &m_pConstantBuffer); - m_pContext->CSSetShaderResources(0, 2, srvs); - - ID3D11UnorderedAccessView* uavs[1] = { m_pComputeShader->GetOutputUAV(1) }; - m_pContext->CSSetUnorderedAccessViews(0, 1, uavs, nullptr); - - m_pContext->Dispatch(iGroupCountX, 1, 1); - - auto outSubs = m_pComputeShader->ReadBackOutputs(); - m_pLocalPos[1] = static_cast(outSubs[1].pData); -} void CModel::InItialize_BoneIndex() { diff --git a/Jusin154_Team3D/Engine/Public/ComputeShader.h b/Jusin154_Team3D/Engine/Public/ComputeShader.h index a410e7b45..859e4a7c5 100644 --- a/Jusin154_Team3D/Engine/Public/ComputeShader.h +++ b/Jusin154_Team3D/Engine/Public/ComputeShader.h @@ -19,7 +19,6 @@ class ENGINE_DLL CComputeShader final : public CBase void Bind_OutPut_SRV_VS(_uint iIndex, _uint iBufferIndex); ID3D11ComputeShader* Get_Compute() { return m_pComputeShader; } ID3D11UnorderedAccessView* GetOutputUAV(_uint iIndex) const; - vector ReadBackOutputs(); private: void Bind_SRV(_uint iIndex); void Bind_UAV(_uint iIndex); @@ -30,7 +29,7 @@ class ENGINE_DLL CComputeShader final : public CBase HRESULT CreateComputeShader(const _tchar* pShaderFilePath, const _char* pStartFunctionName); private: - ID3D11Device* m_pDevice = { nullptr }; + ID3D11Device* m_pDevice = { nullptr }; ID3D11DeviceContext* m_pContext = { nullptr }; class CGameInstance* m_pGameInstance = { nullptr }; @@ -42,11 +41,9 @@ class ENGINE_DLL CComputeShader final : public CBase vector m_pInputBuffer = {}; vector m_pOutputBuffer = {}; - vector m_pInputStagingBuffer = {}; - vector m_pOutputStagingBuffer = {}; ID3D11ComputeShader* m_pComputeShader = nullptr; - + private: diff --git a/Jusin154_Team3D/Engine/Public/Instance_Model.h b/Jusin154_Team3D/Engine/Public/Instance_Model.h index 0e8d404c4..cbce89ec7 100644 --- a/Jusin154_Team3D/Engine/Public/Instance_Model.h +++ b/Jusin154_Team3D/Engine/Public/Instance_Model.h @@ -243,10 +243,11 @@ class ENGINE_DLL CInstance_Model final : public CComponent HRESULT Render(_uint iMeshIndx); void Instane_Buffer_ReStruct(); _uint Get_NumMeshes() const { return m_iNumMeshes; } - HRESULT Bind_CS_Output(_uint Index, _uint iBufferIndex); + //HRESULT Bind_Value_Buffer(class CShader* pShader, const _char* pConstantName); HRESULT Bind_OutPut_SRV_VS(_uint Index, _uint iBufferIndex); INSTANCE_DESC Get_EffectValue() { return m_InstanceDesc; } HRESULT Load_InstanceModel(HANDLE hFile); + HRESULT Bind_CS_Output(_uint Index, _uint iBufferIndex); private: bool LoadData(const _char* filename); @@ -264,6 +265,7 @@ class ENGINE_DLL CInstance_Model final : public CComponent HRESULT Create_SubResource_Buffer(); HRESULT Create_CS(); + private: #ifdef EDITOR_PROJECT const aiScene* m_pAIScene = { nullptr }; @@ -293,6 +295,8 @@ class ENGINE_DLL CInstance_Model final : public CComponent ID3D11Buffer* m_pConstantBuffer = { nullptr }; // 컴퓨트 쉐이드 전용 상수버퍼 ID3D11Buffer* m_pParticleValueBuffer = { nullptr }; // 컴퓨트 쉐이드 두번째 버퍼 (스피드, 로테이션) + ID3D11ShaderResourceView* m_pVBInstance_Srv = { nullptr }; + ID3D11ShaderResourceView* m_pParticleValue_Srv = { nullptr }; public: //인스턴싱으로 바꾸기 static CInstance_Model* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex); diff --git a/Jusin154_Team3D/Engine/Public/Model.h b/Jusin154_Team3D/Engine/Public/Model.h index 9e0d8694c..7aa2ece70 100644 --- a/Jusin154_Team3D/Engine/Public/Model.h +++ b/Jusin154_Team3D/Engine/Public/Model.h @@ -182,11 +182,8 @@ class ENGINE_DLL CModel final : public CComponent private: HRESULT Create_ParentVB(); - HRESULT Create_CS(); void Create_Temp(); void Create_LocalPosVB(); - void Create_Con(); - void UpdateAnimationCS(_uint AnimIndex); _uint m_iNumBuffer = {};