当前位置: 首页>>代码示例>>C++>>正文


C++ CGameObject::Translate方法代码示例

本文整理汇总了C++中CGameObject::Translate方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameObject::Translate方法的具体用法?C++ CGameObject::Translate怎么用?C++ CGameObject::Translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGameObject的用法示例。


在下文中一共展示了CGameObject::Translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Activate

void CActivatable::Activate()
{
	if (m_fTimer >= m_fCoolDown)
	{
		if (m_ID == 0)
		{
			XMMATRIX spawnMatrix = m_Owner->GetWorldMatrix();
			spawnMatrix;
			XMFLOAT4X4 spawn;
			XMFLOAT3 trans = m_Owner->GetAxis(2);
			XMMATRIX translation = XMMatrixTranslation(trans.x * -400, trans.y * -400, trans.z * -400);
			XMStoreFloat4x4(&spawn, spawnMatrix * translation);
			spawnedObject = m_Owner->GetObjMan()->CreateObject("FallenTree", spawn, m_Owner->GetEventSystem());
			CSphereTrigger* trigger = (CSphereTrigger*)(spawnedObject->GetComponent("SphereTrigger"));
			trigger->eTriggerType = TriggerType::eTreeWall;
			CCollisionManager* manager = CManager::GetInstance()->m_ColManager;
			vector<CGameObject*> explosionVec = manager->OverlapSphere(spawnedObject->GetPosition(), 240, CapsuleType::eCapEnemy);
			for (CGameObject* explodeOBj : explosionVec)
			{
				CUnitStats* someStats = ((CUnitStats*)explodeOBj->GetComponent("UnitStats"));
				if (someStats != nullptr)
				{
					someStats->TakeDamage((float)-170);
					int statusInt = 0;
					//float slowAmt = 80;
					//if (slowAmt > 0.0f)
					//{
					//	((CEnemyController*)explodeOBj->GetComponent("EnemyController"))->SetSlowedStatus(slowAmt);
					//}
				}
			}
	}
	else if (m_ID == 1)
	{
		XMMATRIX bulletMat = m_Owner->GetWorldMatrix();
		XMFLOAT4X4 m;
		XMStoreFloat4x4(&m, bulletMat);
		CGameObject* pBullet = m_Owner->GetObjMan()->CreateObject("Bolt", m, m_Owner->GetEventSystem());
		pBullet->Translate(XMFLOAT3(0, 122, 0));
		auto bulletTrigger = (CSphereTrigger*)pBullet->GetComponent("SphereTrigger");
		bulletTrigger->eTriggerType = TriggerType::eBullet;
		CBulletController* bull = (CBulletController*)pBullet->GetComponent("BulletController");
		bull->SetWhoShotMe(m_Owner);
		bull->SetPiercing(true);
		bull->SetLifeTime(2.5f);
		bull->SetBouncing(false);
		m_animation = 1;
	}
	else if (m_ID == 2)
	{
		XMMATRIX bulletMat = m_Owner->GetWorldMatrix();
		XMFLOAT4X4 m;
		XMStoreFloat4x4(&m, bulletMat);
		CGameObject* pBullet = m_Owner->GetObjMan()->CreateObject("FallingStalactite", m, m_Owner->GetEventSystem());
		pBullet->Rotate(-90, 0, 0);
		auto bulletTrigger = (CSphereTrigger*)pBullet->GetComponent("SphereTrigger");
		bulletTrigger->eTriggerType = TriggerType::eBullet;
		CBulletController* bull = (CBulletController*)pBullet->GetComponent("BulletController");
		bull->SetWhoShotMe(m_Owner);
		bull->SetPiercing(true);
		float height = m_Owner->GetPosition().y;
		bull->SetLifeTime(1.0f * height / 1950.0f);
		bull->SetBouncing(false);
		bull->SetExploding(1);
	}
	else if (m_ID = 3)
	{
		float pushbackZ = -1350;
		CCollisionManager* manager = CManager::GetInstance()->m_ColManager;
		XMFLOAT3 collisionPos = XMFLOAT3(2900.0f, 25.0f, -3500.0f);
		vector<CGameObject*> pushVec = manager->OverlapSphere(collisionPos, 4000, CapsuleType::eCapEnemy);
		for (CGameObject* pushOBj : pushVec)
		{
			if (pushOBj->GetPosition().z < pushbackZ)
			{
				CUnitStats* someStats = ((CUnitStats*)pushOBj->GetComponent("UnitStats"));
				if (someStats != nullptr)
				{
					someStats->TakeDamage((float)-170);
					int statusInt = 0;
					float slowAmt = .80f;
					if (slowAmt > 0.0f)
					{
						((CEnemyController*)pushOBj->GetComponent("EnemyController"))->SetSlowedStatus(slowAmt,6.0f);
					}
				}
				((CEnemyController*)pushOBj->GetComponent("EnemyController"))->pushbackTimer = 4.5f;
			}
		}
		XMFLOAT4X4 t;
		XMMATRIX tMat = XMMatrixTranslation(-1500.0f, 250.0f, -2500.0f);
		XMStoreFloat4x4(&t, tMat);
		CGameObject* pWater = m_Owner->GetObjMan()->CreateObject("WaterWave", t, m_Owner->GetEventSystem());

		tMat = XMMatrixTranslation(-1500.0f, 250.0f, -3000.0f);
		XMStoreFloat4x4(&t, tMat);
		pWater = m_Owner->GetObjMan()->CreateObject("WaterWave", t, m_Owner->GetEventSystem());

		tMat = XMMatrixTranslation(-1500.0f, 250.0f, -3750.0f);
		XMStoreFloat4x4(&t, tMat);
//.........这里部分代码省略.........
开发者ID:GrantAviex,项目名称:Draconomy,代码行数:101,代码来源:Activatable.cpp


注:本文中的CGameObject::Translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。