230 lines
5.3 KiB
C++
230 lines
5.3 KiB
C++
#include "pch.h"
|
|
#include "Goblin.h"
|
|
|
|
#include "GameInstance.h"
|
|
|
|
#pragma region STATE
|
|
#include "State_Idle.h"
|
|
#include "State_Dodge.h"
|
|
#include "State_Jump.h"
|
|
#include "State_Land.h"
|
|
#include "State_Move.h"
|
|
#include "State_Combat.h"
|
|
#pragma endregion
|
|
|
|
CGoblin::CGoblin(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
|
: CMonster(pDevice, pContext)
|
|
{
|
|
}
|
|
|
|
CGoblin::CGoblin(const CGoblin& Prototype)
|
|
: CMonster(Prototype)
|
|
{
|
|
}
|
|
|
|
HRESULT CGoblin::Initialize_Prototype()
|
|
{
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CGoblin::Initialize(void* pArg)
|
|
{
|
|
if (FAILED(__super::Initialize(pArg)))
|
|
return E_FAIL;
|
|
|
|
if (FAILED(Ready_Components()))
|
|
return E_FAIL;
|
|
|
|
Add_FSM();
|
|
|
|
Set_Anim();
|
|
|
|
{
|
|
CFSM::FSM_DESC FSMDesc{};
|
|
FSMDesc.pStates = &m_States;
|
|
FSMDesc.pStateMask = &m_iStateMask;
|
|
|
|
m_pFSM->Bind_States(FSMDesc);
|
|
m_pFSM->Change_State(FSMSTATE::IDLE);
|
|
}
|
|
|
|
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));
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
void CGoblin::Priority_Update(_float fTimeDelta)
|
|
{
|
|
m_pTransformCom->RewindMomentum();
|
|
}
|
|
|
|
void CGoblin::Update(_float fTimeDelta)
|
|
{
|
|
m_pFSM->Update_State(fTimeDelta);
|
|
|
|
m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom);
|
|
|
|
m_pCharacter_Controller->Move(fTimeDelta);
|
|
|
|
}
|
|
|
|
void CGoblin::Late_Update(_float fTimeDelta)
|
|
{
|
|
__super::Late_Update(fTimeDelta);
|
|
m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position());
|
|
|
|
m_pTransformCom->LookAt(m_pPlayerTransform->Get_State(STATE::POSITION));
|
|
|
|
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this);
|
|
}
|
|
|
|
HRESULT CGoblin::Render()
|
|
{
|
|
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_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(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) {
|
|
return E_FAIL;
|
|
}
|
|
|
|
if (FAILED(m_pModelCom->Render(i))) {
|
|
return E_FAIL;
|
|
}
|
|
}
|
|
|
|
#ifdef _DEBUG
|
|
m_pCharacter_Controller->Render();
|
|
//m_pRigidBody->Render();
|
|
#endif
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CGoblin::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_Model");
|
|
|
|
/* Com_Model */
|
|
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, m_strModelPrototypeTag,
|
|
reinterpret_cast<CComponent**>(&m_pModelCom))))
|
|
return E_FAIL;
|
|
|
|
{ // CCT
|
|
CCharacter_Controller::Character_Controller_DESC Desc{};
|
|
|
|
Desc.iSubKind = ENUM_CLASS(COLLIDABLEOBJECT::MONSTER);
|
|
Desc.pTransform = m_pTransformCom;
|
|
Desc.eBodyType = ACTOR::CAPSULE;
|
|
Desc.fContactOffset = 0.1f;
|
|
Desc.fMaterial = { 0.5f, 0.5f, 0.6f };
|
|
Desc.bAutoStepping = { false };
|
|
Desc.fStepOffset = { 0.05f };
|
|
Desc.fRadius = 0.5f;
|
|
Desc.fHeight = 1.0f;
|
|
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;
|
|
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_CCT_CAPSULE"), (CComponent**)&m_pCharacter_Controller, &Desc))) {
|
|
return E_FAIL;
|
|
}
|
|
}
|
|
m_pCharacter_Controller->Set_Position(m_pTransformCom->Get_State(STATE::POSITION));
|
|
{ // DO
|
|
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
|
|
Desc.iSubKind = ENUM_CLASS(COLLIDABLEOBJECT::MONSTER);
|
|
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());
|
|
}
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CGoblin::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* CGoblin::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
|
{
|
|
CGoblin* pInstance = new CGoblin(pDevice, pContext);
|
|
|
|
if (FAILED(pInstance->Initialize_Prototype()))
|
|
{
|
|
MSG_BOX("Failed to Created : CGoblin");
|
|
SAFE_RELEASE(pInstance);
|
|
}
|
|
return pInstance;
|
|
}
|
|
|
|
CGameObject* CGoblin::Clone(void* pArg, CGameObject* pOwner)
|
|
{
|
|
CGoblin* pInstance = new CGoblin(*this);
|
|
|
|
if (FAILED(pInstance->Initialize(pArg)))
|
|
{
|
|
MSG_BOX("Failed to Cloned : CGoblin");
|
|
SAFE_RELEASE(pInstance);
|
|
}
|
|
return pInstance;
|
|
}
|
|
|
|
void CGoblin::Free()
|
|
{
|
|
__super::Free();
|
|
|
|
if (nullptr != m_pCallBack_Behavior) {
|
|
m_pCallBack_Behavior->Finalize();
|
|
}
|
|
if (nullptr != m_pCallBack_HitReport) {
|
|
m_pCallBack_HitReport->Finalize();
|
|
}
|
|
|
|
SAFE_RELEASE(m_pCharacter_Controller);
|
|
SAFE_RELEASE(m_pRigidBody);
|
|
Safe_Delete(m_pCallBack_Behavior);
|
|
Safe_Delete(m_pCallBack_HitReport);
|
|
}
|
|
|
|
void CGoblin::Describe_Entity()
|
|
{
|
|
}
|