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


C++ Entity::GetShouldRotateX方法代码示例

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


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

示例1: CopyEntity

void EntityFactory::CopyEntity(Entity* aTargetEntity, const std::string& aEntityTag)
{
	if (myEntities.find(aEntityTag) == myEntities.end())
	{
		//#ifdef _DEBUG
		//		if (myEntityTags.find(aEntityTag) == myEntityTags.end())
		//		{
		//			std::string error = "[EntityFactory] No entity with name " + aEntityTag;
		//			DL_ASSERT(error);
		//		}
		//		
		//		LoadEntity(myEntityTags[aEntityTag], myDifficultScale);
		//#else
		std::string error = "[EntityFactory] No entity with name " + aEntityTag;
		DL_ASSERT(error);
		//#endif
	}
	auto it = myEntities.find(aEntityTag);
	Entity* sourceEntity = it->second.myEntity;

	aTargetEntity->SetName(sourceEntity->GetName());

	if (aEntityTag.rfind("Asteroid") != std::string::npos 
		|| aEntityTag.rfind("asteroid") != std::string::npos 
		|| aEntityTag.rfind("Junk") != std::string::npos
		|| aEntityTag.rfind("junk") != std::string::npos)
	{
		int value = CU::Math::RandomRange(1, 6);
		aTargetEntity->SetShouldRotate(true);
		if (value == 1)
			aTargetEntity->SetShouldRotateX(true);
		else if (value == 2)
			aTargetEntity->SetShouldRotateY(true);
		else if (value == 3)
			aTargetEntity->SetShouldRotateZ(true);
		else if (value == 4)
		{
			aTargetEntity->SetShouldRotateX(true);
			aTargetEntity->SetShouldRotateY(true);
		}
		else if (value == 5)
		{
			aTargetEntity->SetShouldRotateY(true);
			aTargetEntity->SetShouldRotateZ(true);
		}
		else if (value == 6)
		{
			aTargetEntity->SetShouldRotateZ(true);
			aTargetEntity->SetShouldRotateX(true);
		}
	}
	else
	{
		aTargetEntity->SetShouldRotate(sourceEntity->GetShouldRotate());
		aTargetEntity->SetShouldRotateX(sourceEntity->GetShouldRotateX());
		aTargetEntity->SetShouldRotateY(sourceEntity->GetShouldRotateY());
		aTargetEntity->SetShouldRotateZ(sourceEntity->GetShouldRotateZ());
	}







	if (sourceEntity->GetComponent<CollisionComponent>() != nullptr)
	{
		eCollisionType collisionType = sourceEntity->GetComponent<CollisionComponent>()->GetCollisionType();

		if (collisionType == eCollisionType::NORMAL)
		{
			aTargetEntity->AddComponent<CollisionComponent>();
		}
		else if (collisionType == eCollisionType::PLANET)
		{
			aTargetEntity->AddComponent<PlanetCollisionComponent>();
		}

		aTargetEntity->GetComponent<CollisionComponent>()->Init(it->second.myCollisionSphereRadius);
	}
	if (sourceEntity->GetComponent<GraphicsComponent>() != nullptr)
	{
		aTargetEntity->AddComponent<GraphicsComponent>();
		switch (it->second.myGraphicsType)
		{
		case eEntityDataGraphicsType::MODEL:
			aTargetEntity->GetComponent<GraphicsComponent>()->Init(it->second.myModelFile.c_str(),
				it->second.myEffectFile.c_str());
			break;
		case eEntityDataGraphicsType::CUBE:
			aTargetEntity->GetComponent<GraphicsComponent>()->InitCube(it->second.myWidth,
				it->second.myHeight, it->second.myDepth);
			break;
		default:
			break;
		}
		if (it->second.myScale != CU::Vector3f())
		{
			aTargetEntity->GetComponent<GraphicsComponent>()->SetScale(it->second.myScale);
			if (aTargetEntity->GetComponent<CollisionComponent>() != nullptr)
//.........这里部分代码省略.........
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:101,代码来源:EntityFactory.cpp


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