Example #1
0
void CMinotaurSpawn::AddColliders()
{
	for (size_t currMesh = 0; currMesh < meshes.size(); currMesh++)
	{
		CMesh* mesh = meshes[currMesh];
		XMFLOAT3 posOffset = XMFLOAT3(meshLocalMatricies[currMesh]._41, meshLocalMatricies[currMesh]._42, meshLocalMatricies[currMesh]._43);

		int startIndex = 0;
		if (mesh->IsPlane())
		{
			int index = 0;

			for (index = 0; index < (int)mesh->GetAABBs().size(); index++)
			{
				CMesh::TAABB aabb = mesh->GetAABBs()[index];
				aabb.center.x += posOffset.x;
				aabb.center.y += posOffset.y;
				aabb.center.z += posOffset.z;

				AddCollider(new CCollider(false, new CAABB(aabb.center, aabb.extents)));
			}
			index = 0;
			if (m_pvColliders[0]->GetType() == Bounds::Plane)
				index = 1;
			for (index; index < mesh->GetPlanes().size(); index++)
			{
				CMesh::TPlane plane = mesh->GetPlanes()[index];
				plane.center.x += posOffset.x;
				plane.center.y += posOffset.y;
				plane.center.z += posOffset.z;
				AddCollider(new CCollider(false, new CPlane(plane.distance, plane.normal, plane.center, plane.extents)));
			}
		}
		else
		{
			int index = 0;
			if (m_pvColliders[0]->GetType() == Bounds::AABB)
				index = 1;

			for (index; index < mesh->GetAABBs().size(); index++)
			{
				CMesh::TAABB aabb = mesh->GetAABBs()[index];
				aabb.center.x += posOffset.x;
				aabb.center.y += posOffset.y;
				aabb.center.z += posOffset.z;
				AddCollider(new CCollider(false, new CAABB(aabb.center, aabb.extents)));
			}
			for (index = 0; index < mesh->GetPlanes().size(); index++)
			{
				CMesh::TPlane plane = mesh->GetPlanes()[index];
				plane.center.x += posOffset.x;
				plane.center.y += posOffset.y;
				plane.center.z += posOffset.z;
				AddCollider(new CCollider(false, new CPlane(plane.distance, plane.normal, plane.center, plane.extents)));
			}
		}
	}
}
Example #2
0
void CCrackedWall::SetBombPosition()
{

	XMFLOAT3 vExtents = ( (CAABB*)( GetColliders()[0] )->GetBounds() )->GetExtents();

	float fNewOffsetPosX = GetPosition()->x + ( vExtents.x + OFFSET );
	float fNewOffsetNegX = GetPosition()->x - ( vExtents.x + OFFSET );
	float fNewOffsetPosZ = GetPosition()->z + ( vExtents.z + OFFSET );
	float fNewOffsetNegZ = GetPosition()->z - ( vExtents.z + OFFSET );

	m_cpIndicatorBomb[0]->GetTransformMatrix()._41 = fNewOffsetPosX;

	vExtents = XMFLOAT3{ 50.0f, 50.0f, 50.0f };
	XMFLOAT3 vCenter;

	vCenter.x = m_cpIndicatorBomb[0]->GetTransformMatrix()._41;
	vCenter.y = m_cpIndicatorBomb[0]->GetTransformMatrix()._42;
	vCenter.z = m_cpIndicatorBomb[0]->GetTransformMatrix()._43;

	CAABB* posX = new CAABB( vCenter, vExtents );
	AddCollider( new CCollider( false, posX, true, false ) );


	m_cpIndicatorBomb[1]->GetTransformMatrix()._41 = fNewOffsetNegX;
	vCenter.x = m_cpIndicatorBomb[1]->GetTransformMatrix()._41;
	vCenter.y = m_cpIndicatorBomb[1]->GetTransformMatrix()._42;
	vCenter.z = m_cpIndicatorBomb[1]->GetTransformMatrix()._43;

	CAABB* negX = new CAABB( vCenter, vExtents );
	AddCollider( new CCollider( false, negX, true, false ) );


	m_cpIndicatorBomb[2]->GetTransformMatrix()._43 = fNewOffsetPosZ;
	vCenter.x = m_cpIndicatorBomb[2]->GetTransformMatrix()._41;
	vCenter.y = m_cpIndicatorBomb[2]->GetTransformMatrix()._42;
	vCenter.z = m_cpIndicatorBomb[2]->GetTransformMatrix()._43;

	CAABB* posZ = new CAABB( vCenter, vExtents );
	AddCollider( new CCollider( false, posZ, true, false ) );


	m_cpIndicatorBomb[3]->GetTransformMatrix()._43 = fNewOffsetNegZ;
	vCenter.x = m_cpIndicatorBomb[3]->GetTransformMatrix()._41;
	vCenter.y = m_cpIndicatorBomb[3]->GetTransformMatrix()._42;
	vCenter.z = m_cpIndicatorBomb[3]->GetTransformMatrix()._43;

	CAABB* negZ = new CAABB( vCenter, vExtents );
	AddCollider( new CCollider( false, negZ, true, false ) );
}
Example #3
0
CPressurePlate::CPressurePlate( XMFLOAT3 _location, bool _used ) : IObject( "PressurePlate" )
{
	AudioSystemWwise::Get()->RegisterEntity( this, "PressurePlate" );
	XMFLOAT3 newLocation = _location;
	newLocation.y = 1;
	SetPosition( newLocation );

	CMesh* vPressureMesh = CAssetManager::GetInstance()->GetPrefabMesh("PressurePlate");

	SetRenderMesh( new CRenderMesh( vPressureMesh, GRAPHICS->GetVertexShader(), GRAPHICS->GetNormalMapPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Bricks.dds" ) );
	m_cpRenderMesh->SetNormals(L"../Game/Assets/Art/2D/Normal Maps/Bricks.dds");
	m_cpRenderMesh->GetSpecular() = 1.5f;
	GRAPHICS->AddRenderMesh( m_cpRenderMesh );

	//tempFloor->SetRenderMesh( new CRenderMesh( tempMesh->GetIndices(), tempMesh->GetVertices(), GRAPHICS->GetVertexShader(), GRAPHICS->GetNormalMapPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Maze_Ground.dds" ) );
	//tempFloor->GetRenderMesh()->SetNormals( L"../Game/Assets/Art/2D/Normal Maps/Rocky.dds" );
	//tempFloor->GetRenderMesh()->GetSpecular() = 1.5f;

	//if (_used)
	{
		AddCollider( new CCollider( false, Bounds::AABB, vPressureMesh->GetVertices(), _used,false ) );

		for( size_t i = 0; i < m_pvColliders.size(); i++ )
		{
			( (CAABB*)m_pvColliders[i]->GetBounds() )->SetCenter( { m_mWorld._41, m_mWorld._42, m_mWorld._43 } );
		}

	}

	CAddObjectMessage* addObj = new CAddObjectMessage( this, CObjectManager::Static );
	addObj->Send();
}
Example #4
0
//-----------------------------------------------------------------------------------------------------------------------------------
void BaseObject::Create()
{
	m_alive = true;
	
	Show();
	AddCollider();
}
Example #5
0
CSkeletonSpawner::CSkeletonSpawner(CSkeletonController* controller, XMFLOAT3 position) : IObject("SkeletonSpawn")
{
    color = float3(0.0f, 1.0f, 0.0f);
    m_vPosition = position;
    //m_vPosition.y = 500.0f;
    m_cpRenderMesh = nullptr;
    m_cpSpawnController = controller;
    XMStoreFloat4x4(&m_mWorld, XMMatrixTranslation(m_vPosition.x, m_vPosition.y, m_vPosition.z));
    m_vPosition = position;
    XMFLOAT3 center = m_vPosition;
    center.y = 500.0f;
    XMFLOAT3 extents(1000.0f, 500.0f, 1000.0f);
    AddCollider(new CCollider(false, new CAABB(center, extents), true, false));


}
Example #6
0
CBone::CBone( CObjectManager* _objManager, IObject* _parent ) : IObject( "Bone" )
{
    m_cpParent = _parent;
    m_bActive = false;
    m_fDespawnTime = DESPAWN_TIME;

    XMFLOAT3 newPos = { m_cpParent->GetPosition()->x, 50, m_cpParent->GetPosition()->z };
    SetPosition( newPos );

    //SetPosition( {500,100,0} );

    CMesh* theMesh = CAssetManager::GetInstance()->GetPrefabMesh("BonePile");
    m_cpRenderMesh = new CRenderMesh( theMesh,
                                      GRAPHICS->GetVertexShader(), GRAPHICS->GetPixelShader(),
                                      nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Failbot_BoneLoot.dds" );
    m_cpRenderMesh->SetNormals( L"../Game/Assets/Art/2D/Normal Maps/Failbot_BoneLoot.dds" );

    m_cpRenderMesh->GetTransparent() = true;
    m_cpRenderMesh->GetTransparencyOverride() = 0.0f;
    GRAPHICS->AddRenderMesh( m_cpRenderMesh );

    XMFLOAT3 extents = XMFLOAT3{ 40, 100, 40 };
    AddCollider( new CCollider( true, new CAABB( *GetPosition(), extents ), false ) );

    _objManager->AddObject( this, CObjectManager::Dynamic );

    TPointLight tempLight;
    tempLight.m_fPosition[0] = GetPosition()->x;
    tempLight.m_fPosition[1] = GetPosition()->y;
    tempLight.m_fPosition[2] = GetPosition()->z;
    tempLight.m_fColor[0] = 0.3f;
    tempLight.m_fColor[1] = 0.3f;
    tempLight.m_fColor[2] = 0.3f;
    tempLight.m_fRadius = 500.0f;
    tempLight.m_fBrightness = 10.0f;
    AddLight(tempLight);

    //set up particles
    m_cpParticleManager = new CParticleManager( _objManager );
    m_unParticle = m_cpParticleManager->LoadEmitter( "DroppedItemParticle.xml" );
    m_cpParticleManager->GetEmitter( m_unParticle )->GetPosition( 0 ) = newPos.x;
    m_cpParticleManager->GetEmitter( m_unParticle )->GetPosition( 1 ) = newPos.y;
    m_cpParticleManager->GetEmitter( m_unParticle )->GetPosition( 2 ) = newPos.z;

    m_cpParticleManager->GetEmitter( m_unParticle )->Stop();
}
Example #7
0
/*****************************************************************
* CSkeleton()			Skeleton Constructor that initializes the data members
*
* Ins:					CObjectManager*
*						CAnimationManager*
*
* Outs:					None
*
* Returns:				void
*
* Mod. Date:		    08/20/2015
* Mod. Initials:	    NS
*****************************************************************/
CSkeleton::CSkeleton(CObjectManager* _manager, CAnimationManager* _animManager, CDayNight* _dayNight, CSkeletonController* skeletonController) : CBoid(10.0f, 500.0f, "Skeleton")
{
	// Drop Shadow Creation //
	CMesh cDropShadow;

	cDropShadow.GetIndices().push_back(0);
	cDropShadow.GetIndices().push_back(1);
	cDropShadow.GetIndices().push_back(2);

	cDropShadow.GetIndices().push_back(0);
	cDropShadow.GetIndices().push_back(2);
	cDropShadow.GetIndices().push_back(3);

	cDropShadow.GetVertices().push_back
		({
			{ -100.0f, 3.0f, 100.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 0, 0 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ 100.0f, 3.0f, 100.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 1, 0 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ 100.0f, 3.0f, -100.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 1, 1 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ -100.0f, 3.0f, -100.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 0, 1 }
	});

	m_cDropShadow = new CRenderMesh(&cDropShadow, GRAPHICS->GetStandardVS(), GRAPHICS->GetStandardPS());
	m_cDropShadow->SetTexture(L"../Game/Assets/Art/2D/Textures/Shadow.dds");
	m_cDropShadow->GetTransparent() = true;
	m_cDropShadow->GetRender() = false;

	GRAPHICS->AddRenderMesh(m_cDropShadow);

	// Initilize Managers
#if _DEBUG
	m_pPathPlanner = new CPathFinding("SkeletonNavGraph", _manager, false);

#else
	m_pPathPlanner = new CPathFinding("SkeletonNavGraph", _manager, false);

#endif

	m_pDayNight = _dayNight;
	m_fScale = 1.0f;
	
	m_pAssetManager = CAssetManager::GetInstance();
	m_bPoweringUp = false;
	//Set the Animation Manager
	m_cpAnimationManager = _animManager;
	m_cpAnimations = new CAnimation[eAnimCount];

	m_cpSkeletonController = skeletonController;
	// Set the object manager
	m_cpObjectManager = _manager;
	m_bBuffed = false;

	TPointLight tempLight;
	tempLight.m_fRadius = 0.0f;
	tempLight.m_fColor[0] = 1.0f;
	tempLight.m_fColor[1] = 0.0f;
	tempLight.m_fColor[2] = 0.0f;
	tempLight.m_fBrightness = 2.5f;
	tempLight.m_fPosition[0] = 0.0f;
	tempLight.m_fPosition[1] = 0.0f;
	tempLight.m_fPosition[2] = 0.0f;
	tempLight.m_fPosition[3] = 1.0f;
	AddLight(tempLight);

	m_bHit = false;

	// Load the asset
	/*CMesh* m_cShieldMesh = m_pAssetManager->GetMesh(CAssetManager::eMeshType::SkeletonShield)[0];
	m_cShieldRender[0] = new CRenderMesh(m_cShieldMesh, GRAPHICS->GetStandardVS(), GRAPHICS->GetStandardPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Shield2_Diffuse.dds");
	m_cShieldRender[1] = new CRenderMesh(m_cShieldMesh, GRAPHICS->GetStandardVS(), GRAPHICS->GetStandardPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Shield2_Diffuse.dds");*/

	CMesh* m_cMesh = CAssetManager::GetInstance()->GetPrefabMesh("RemnantMesh");
	// Create a render mesh for the object

	m_cpRenderMesh = new CAnimationMesh(m_cMesh, GRAPHICS->GetSkinningVS(), GRAPHICS->GetNormalMapPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/RemnantDiffuse.dds");
	m_cpRenderMesh->SetNormals(L"../Game/Assets/Art/2D/Normal Maps/RemnantNormal.dds");
	// Set the animation mesh
	m_cpSword = new CSkeletonSword;

	XMMATRIX mSkele = XMMatrixIdentity();
	XMStoreFloat4x4(&m_mSkeleLocal, mSkele);

	//	AttachToJoint(m_cpSword->S(), LEFT_HAND);
	m_cpRenderMesh->GetRender() = false;

	m_cpAnimations[eRunAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantRun");
	m_cpAnimations[eRunAnim].SetLooping(true);

	

	m_cpAnimations[eBlockWalkAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantRun");
	m_cpAnimations[eBlockWalkAnim].SetLooping(true);

	m_cpAnimations[eAttackAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantLightAttack1");
	m_cpAnimations[eAttackAnim].SetLooping(false);
	m_cpAnimations[eAttackAnim].SetScale(1.33f);

	m_cpAnimations[eDeathAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantDeath1");
	m_cpAnimations[eDeathAnim].SetLooping(false);

	m_cpAnimations[eHurtAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantHurt");
	m_cpAnimations[eHurtAnim].SetLooping(false);
	m_cpAnimations[eHurtAnim].SetScale(1.0f);

	m_cpAnimations[eHurt2Anim] = CAssetManager::GetInstance()->GetAnimation("RemnantHurt");
	m_cpAnimations[eHurt2Anim].SetLooping(false);

	m_cpAnimations[eSpawnAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantSpawn1");
	m_cpAnimations[eSpawnAnim].SetLooping(false);
	m_cpAnimations[eSpawnAnim].SetScale(0.0f);

	m_pParticleManager = new CParticleManager(_manager);
	m_unParticleEmitters[eBoneParticle] = m_pParticleManager->LoadEmitter("BoneFragment.xml");
	m_unParticleEmitters[eDustParticle] = m_pParticleManager->LoadEmitter("BoneDust.xml");
	m_unParticleEmitters[eFadeAway] = m_pParticleManager->LoadEmitter("EnemyFadeAway.xml");

	for (unsigned int animation = 0; animation < eAnimCount; animation++)
	{
		m_cpAnimations[animation].SetAnimMesh((CAnimationMesh*)m_cpRenderMesh);
		m_cpAnimations[animation].IntializeAnimation();
	}

	// Add the starting animation
	m_cpAnimationManager->AddAnimation(&m_cpAnimations[eSpawnAnim]);

	// Set the current animaton
	m_unCurrAnim = eSpawnAnim;

	// Add collision box
	AddCollider(new CCollider(true, new CAABB(XMFLOAT3(m_mWorld._41, 55.0f, m_mWorld._43), XMFLOAT3(90.0f, 90.f, 90.f)), false));
	CCapsule* theCapsule = new CCapsule({ m_mWorld._41, 45.0f, m_mWorld._43 }, { m_mWorld._41, 240.0f, m_mWorld._43 }, 45.0f);
	AddCollider(new CCollider(true, theCapsule));

	((CAABB*)m_pvColliders[0]->GetBounds())->SetCenter({ m_mWorld._41, m_mWorld._42, m_mWorld._43 });


	// Create the attack instance
	AttachToJoint(m_cpSword->GetRenderMesh(), "RightHand");
	GRAPHICS->AddRenderMesh(m_cpSword->GetRenderMesh());
	m_cpAttack = new CAttack(this, CAssetManager::GetInstance()->GetPrefabMesh("OrcDagger"), &m_cpSword->GetRenderMesh()->GetPositionMatrix(), 20, "SkeletonAttack");
	m_cpAttack->SetParent(this);

	// Add the object to start attacking.
	CAddObjectMessage* addObj = new CAddObjectMessage(m_cpAttack, CObjectManager::Dynamic);

	// Send the message
	addObj->Send();

	SetWorldVelocity(XMFLOAT3(0.0f, 0.0f, 0.0f));

	
	GRAPHICS->AddRenderMesh(m_cpRenderMesh);
	GRAPHICS->AddLight(&m_vtPointLights[0]);


	m_ipCurrentState = SPAWN;
	EnterSubState();

	m_cpTheLoot = new CBone(m_cpObjectManager, this);
	m_cpThePowder = new CGunpowder(m_cpObjectManager, this);
}
Example #8
0
CMinotaur::CMinotaur(const XMFLOAT3& spawnPosition, CObjectManager* _manager, CAnimationManager* _animManager) : CBoid(15.0f, 300.0f, "Minotaur")
{
	// Drop Shadow Creation //
	CMesh cDropShadow;

	cDropShadow.GetIndices().push_back(0);
	cDropShadow.GetIndices().push_back(1);
	cDropShadow.GetIndices().push_back(2);

	cDropShadow.GetIndices().push_back(0);
	cDropShadow.GetIndices().push_back(2);
	cDropShadow.GetIndices().push_back(3);

	cDropShadow.GetVertices().push_back
		({
			{ -400.0f, 3.0f, 400.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 0, 0 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ 400.0f, 3.0f, 400.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 1, 0 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ 400.0f, 3.0f, -400.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 1, 1 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ -400.0f, 3.0f, -400.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 0, 1 }
	});

	m_cDropShadow = new CRenderMesh(&cDropShadow, GRAPHICS->GetStandardVS(), GRAPHICS->GetStandardPS());
	m_cDropShadow->SetTexture(L"../Game/Assets/Art/2D/Textures/Shadow.dds");
	m_cDropShadow->GetTransparent() = true;
	m_cDropShadow->GetRender() = false;
	GRAPHICS->AddRenderMesh(m_cDropShadow);

	XMStoreFloat4x4(&m_mWorld, XMMatrixTranslation(spawnPosition.x, spawnPosition.y, spawnPosition.z));
	m_tSpawnPosition = spawnPosition;
	m_pPathPlanner = new CPathFinding("MinotaurNavGraph", _manager, false);

	CNavGraph* cNavGraph = CNavGraphManager::GetReference().GetNavGraph("MinotaurNavGraph");

	int unNodes[2];
	unNodes[0] = rand() % cNavGraph->GetNodes().size();
	unNodes[1] = rand() % cNavGraph->GetNodes().size();
	if (unNodes[1] == unNodes[0])
	{
		unNodes[1]++;
	}

	m_vWaypoints.push_back(unNodes[0]);
	m_vWaypoints.push_back(unNodes[1]);



	//m_pSteering = new CSteeringManager(this);

	m_pAssetManager = CAssetManager::GetInstance();
	m_cpAnimationManager = _animManager;
	m_cpObjectManager = _manager;
	m_pPlayer = m_cpObjectManager->GetPlayer();
	CMesh* m_cMesh = m_pAssetManager->GetPrefabMesh("minotaur");
	m_cpRenderMesh = new CAnimationMesh(m_cMesh, GRAPHICS->GetSkinningVS(), GRAPHICS->GetStandardPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Minotaur.dds");
	m_cpRenderMesh->GetRender() = false;
	GRAPHICS->AddRenderMesh(m_cpRenderMesh);

	enum EMinotaurAnimation{ eIdleAnim, eRunAnim, eTellAnim, eChargeAnim, eStompAnim, eDeathAnim, eEnrageAnim, eStunnedAnim, eAnimCount };

	m_cpAnimations[eIdleAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurIdle");
	m_cpAnimations[eRunAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurRun");
	m_cpAnimations[eTellAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurTell");
	m_cpAnimations[eChargeAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurCharge");
	m_cpAnimations[eStompAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurStomp");
	m_cpAnimations[eDeathAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurDeath");
	m_cpAnimations[eEnrageAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurEnrage");
	m_cpAnimations[eStunnedAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurHurt");





	for (unsigned int animation = 0; animation < eAnimCount; animation++)
	{
		m_cpAnimations[animation].SetAnimMesh((CAnimationMesh*)m_cpRenderMesh);

	}
	//m_cpAnimationManager->AddAnimation(&m_cpAnimations[eRunAnim]);
	/*m_cpAnimationManager->AddAnimation(&m_cpAnimations[eWalkAnim]);
	m_cpAnimationManager->AddAnimation(&m_cpAnimations[eRunAnim]);
	m_cpAnimationManager->AddAnimation(&m_cpAnimations[eStompAnim]);*/




	CCapsule*  pCapsule = new CCapsule(XMFLOAT3(spawnPosition.x, 90.0f, spawnPosition.z), XMFLOAT3(spawnPosition.x, 250.0f, spawnPosition.z), 90.0f);
	CCollider* pCapCollider = new CCollider(true, pCapsule, true, false);
	CCollider* pBoxCollider = new CCollider(true, new CAABB(float3(spawnPosition.x, 250.0f, spawnPosition.z), float3(250.0f, 250.0f, 250.0f)), false, false);

	CCollider* pZoneCollider = new CCollider(true, new CAABB(float3(spawnPosition.x, 250.0f, spawnPosition.z), float3(2500.0f, 250.0f, 2500.0f)), true, false);

	


	m_pMinotaurZone = new CMinotaurZone();

	m_pMinotaurZone->AddCollider(pZoneCollider);
	pBoxCollider->GetBounds()->UpdatePosition(spawnPosition);
	AddCollider(pBoxCollider);
	AddCollider(pCapCollider);



	m_pParticleManager = new CParticleManager(_manager);
	m_unParticleEmitters[eBloodParticle] = m_pParticleManager->LoadEmitter("BloodDrop.xml");
	m_unParticleEmitters[eBloodString] = m_pParticleManager->LoadEmitter("BloodString.xml");
	m_unParticleEmitters[eBloodMist] = m_pParticleManager->LoadEmitter("BloodMist.xml");
	m_unParticleEmitters[eBloodMist2] = m_pParticleManager->LoadEmitter("BloodMist.xml");
	m_unParticleEmitters[eStompDustOut] = m_pParticleManager->LoadEmitter("MinotaurStompDust1.xml");
	m_unParticleEmitters[eStompDustUp] = m_pParticleManager->LoadEmitter("MinotaurStompDust2.xml");
	m_unParticleEmitters[eStepDust] = m_pParticleManager->LoadEmitter("MinoStepDust.xml");
	m_unParticleEmitters[eChargeParticle] = m_pParticleManager->LoadEmitter("MinoCharge.xml");
	m_pParticleManager->GetEmitter(m_unParticleEmitters[eChargeParticle])->GetParent() = this;
	m_pParticleManager->GetEmitter(m_unParticleEmitters[eChargeParticle])->Stop();

	m_pStates[ePatrolState] = new CMinotaurPatrol;
	m_pStates[eHostileState] = new CMinotaurHostile;
	m_pStates[eDeadState] = new CMinotaurDead;


	m_unCurrAnim = -1;
	m_nCurrState = ePatrolState;
	//Activate();

}
Example #9
0
int main()
{
    // Initialization
    //--------------------------------------------------------------------------------------
    int screenWidth = 800;
    int screenHeight = 450;
    
    InitWindow(screenWidth, screenHeight, "raylib [physics] example - basic rigidbody");

    InitPhysics(3);      // Initialize physics system with maximum physic objects
    
    // Object initialization
    Transform player = (Transform){(Vector2){(screenWidth - OBJECT_SIZE) / 2, (screenHeight - OBJECT_SIZE) / 2}, 0.0f, (Vector2){OBJECT_SIZE, OBJECT_SIZE}};
    AddCollider(PLAYER_INDEX, (Collider){true, COLLIDER_RECTANGLE, (Rectangle){player.position.x, player.position.y, player.scale.x, player.scale.y}, 0});
    AddRigidbody(PLAYER_INDEX, (Rigidbody){true, 1.0f, (Vector2){0, 0}, (Vector2){0, 0}, false, false, true, 0.5f, 1.0f});
    
    // Floor initialization 
    // NOTE: floor doesn't need a rigidbody because it's a static physic object, just a collider to collide with other dynamic colliders (with rigidbody)
    Transform floor = (Transform){(Vector2){0, screenHeight * 0.8f}, 0.0f, (Vector2){screenWidth, screenHeight * 0.2f}};
    AddCollider(PLAYER_INDEX + 1, (Collider){true, COLLIDER_RECTANGLE, (Rectangle){floor.position.x, floor.position.y, floor.scale.x, floor.scale.y}, 0});
    
    // Object properties initialization
    float moveSpeed = 6.0f;
    float jumpForce = 5.0f;
    
    bool physicsDebug = false;
    
    SetTargetFPS(60);
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------
        
        // Update object physics 
        // NOTE: all physics detections and reactions are calculated in ApplyPhysics() function (You will live happier :D)
        ApplyPhysics(PLAYER_INDEX, &player.position);
        
        // Check jump button input
        if (IsKeyDown(KEY_SPACE) && GetRigidbody(PLAYER_INDEX).isGrounded)
        {
            // Reset object Y velocity to avoid double jumping cases but keep the same X velocity that it already has
            SetRigidbodyVelocity(PLAYER_INDEX, (Vector2){GetRigidbody(PLAYER_INDEX).velocity.x, 0});
            
            // Add jumping force in Y axis
            AddRigidbodyForce(PLAYER_INDEX, (Vector2){0, jumpForce});
        }
        
        // Check movement buttons input
        if (IsKeyDown(KEY_RIGHT) || IsKeyDown(KEY_D))
        {
            // Set rigidbody velocity in X based on moveSpeed value and apply the same Y velocity that it already has
            SetRigidbodyVelocity(PLAYER_INDEX, (Vector2){moveSpeed, GetRigidbody(PLAYER_INDEX).velocity.y});
        }
        else if (IsKeyDown(KEY_LEFT) || IsKeyDown(KEY_A))
        {
            // Set rigidbody velocity in X based on moveSpeed negative value and apply the same Y velocity that it already has
            SetRigidbodyVelocity(PLAYER_INDEX, (Vector2){-moveSpeed, GetRigidbody(PLAYER_INDEX).velocity.y});
        }
        
        // Check debug mode toggle button input
        if (IsKeyPressed(KEY_P)) physicsDebug = !physicsDebug;
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

            ClearBackground(RAYWHITE);
            
            // Draw information
            DrawText("Use LEFT / RIGHT to MOVE and SPACE to JUMP", (screenWidth - MeasureText("Use LEFT / RIGHT to MOVE and SPACE to JUMP", 20)) / 2, screenHeight * 0.20f, 20, LIGHTGRAY);
            DrawText("Use P to switch DEBUG MODE", (screenWidth - MeasureText("Use P to switch DEBUG MODE", 20)) / 2, screenHeight * 0.3f, 20, LIGHTGRAY);
            
            // Check if debug mode is enabled
            if (physicsDebug)
            {
                // Draw every internal physics stored collider if it is active
                for (int i = 0; i < 2; i++)
                {
                    if (GetCollider(i).enabled)
                    {
                        DrawRectangleLines(GetCollider(i).bounds.x, GetCollider(i).bounds.y, GetCollider(i).bounds.width, GetCollider(i).bounds.height, GREEN);
                    }
                }
            }
            else
            {
                // Draw player and floor
                DrawRectangleRec((Rectangle){player.position.x, player.position.y, player.scale.x, player.scale.y}, GRAY);
                DrawRectangleRec((Rectangle){floor.position.x, floor.position.y, floor.scale.x, floor.scale.y}, BLACK);
            }

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    UnloadPhysics();      // Unload physic objects
    
    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}