예제 #1
0
EnemyObject::EnemyObject(vector<int> p, SoundClass* snd, float x, float y, float z, float s) : GameObject(x, y, z)
{
	m_model = new EnemyModel(x, y, z, s);
	renderVal = true;
	destination = XMINT2((int)x, (int)z);
	prevDestination = XMINT2(0, 0);
	direction = NORTH;
	prevDirection = NORTH;
	actionComplete = true;
	currentPathAction = 12;
	for (unsigned int i = 0; i < p.size(); i++)
	{
		path.push_back(p[i]);
	}
	currentPath = path;
	giveSoundObject(snd);
	enemyState = PATROLLING;
	patrolLight = 0;
	playerSpotted = false;
}
예제 #2
0
void EnemyObject::MoveForward(int spaces)
{
	if (direction == NORTH)
	{
		destination = XMINT2((int)xLocation, (int)zLocation + spaces * 10);
	}
	else if (direction == EAST)
	{
		destination = XMINT2((int)xLocation + spaces * 10, (int)zLocation);
	}
	else if (direction == SOUTH)
	{
		destination = XMINT2((int)xLocation, (int)zLocation - spaces * 10);
	}
	else if (direction == WEST)
	{
		destination = XMINT2((int)xLocation - spaces * 10, (int)zLocation);
	}
	actionComplete = false;
}
예제 #3
0
void EnemyObject::setPrevDestination(int x, int y)
{
	prevDestination = XMINT2(x, y);
}
예제 #4
0
IActor *CreateObject(XMVECTOR const &xvPos, XMCOLOR const &Color, 
	E_ACTOR_TYPE const eActorType, E_RIGID_BODY_FLAG const eBodyFlag)
{
	const float fBoxSize = 0.4f;

	if (!g_pWireBoxModelRenderer)
	{
		g_pWireBoxModelRenderer = CDistributedObjectCreator::GetInstance()->CreateModelRenderer();
		g_pWireBoxModelRenderer->SetRenderMethod(E_RENDERMETHOD::WIREFRAMED);
		g_pWireBoxModelRenderer->SetRigidBodyFlag(E_RIGID_BODY_FLAG::DYNAMIC);

		CRawModel RawModel;
		RawModel.m_eRidigBodyFlag = E_RIGID_BODY_FLAG::DYNAMIC;
		RawModel.m_vScale = XMFLOAT3(fBoxSize, fBoxSize, fBoxSize);
		ContructBoxVertexBuffer(&RawModel);

		for (auto iMesh : RawModel.m_RawMeshes)
			g_pWireBoxModelRenderer->VAddMesh(iMesh, iMesh);
	}

	if (!g_pSolidBoxModelRenderer)
	{
		g_pSolidBoxModelRenderer = CDistributedObjectCreator::GetInstance()->CreateModelRenderer();
		g_pSolidBoxModelRenderer->SetRenderMethod(E_RENDERMETHOD::SOLID);
		g_pSolidBoxModelRenderer->SetRigidBodyFlag(E_RIGID_BODY_FLAG::DYNAMIC);

		CRawModel RawModel;
		RawModel.m_eRidigBodyFlag = E_RIGID_BODY_FLAG::DYNAMIC;
		RawModel.m_vScale = XMFLOAT3(fBoxSize, fBoxSize, fBoxSize);
		ContructBoxVertexBuffer(&RawModel);

		for (auto iMesh : RawModel.m_RawMeshes)
			g_pSolidBoxModelRenderer->VAddMesh(iMesh, iMesh);
	}

	if (!g_pWireSphereModelRenderer)
	{
		g_pWireSphereModelRenderer = CDistributedObjectCreator::GetInstance()->CreateModelRenderer();
		g_pWireSphereModelRenderer->SetRenderMethod(E_RENDERMETHOD::WIREFRAMED);
		g_pWireSphereModelRenderer->SetRigidBodyFlag(E_RIGID_BODY_FLAG::DYNAMIC);

		CRawModel RawModel;
		RawModel.m_eRidigBodyFlag = E_RIGID_BODY_FLAG::DYNAMIC;
		RawModel.m_vScale = XMFLOAT3(fBoxSize, fBoxSize, fBoxSize);
		ContructSphereVertexBuffer(&RawModel);

		for (auto iMesh : RawModel.m_RawMeshes)
			g_pWireSphereModelRenderer->VAddMesh(iMesh, iMesh);
	}

	if (!g_pSolidSphereModelRenderer)
	{
		g_pSolidSphereModelRenderer = CDistributedObjectCreator::GetInstance()->CreateModelRenderer();
		g_pSolidSphereModelRenderer->SetRenderMethod(E_RENDERMETHOD::SOLID);
		g_pSolidSphereModelRenderer->SetRigidBodyFlag(E_RIGID_BODY_FLAG::DYNAMIC);

		CRawModel RawModel;
		RawModel.m_eRidigBodyFlag = E_RIGID_BODY_FLAG::DYNAMIC;
		RawModel.m_vScale = XMFLOAT3(fBoxSize, fBoxSize, fBoxSize);
		ContructSphereVertexBuffer(&RawModel);

		for (auto iMesh : RawModel.m_RawMeshes)
			g_pSolidSphereModelRenderer->VAddMesh(iMesh, iMesh);
	}

	if (!g_pWirePlaneModelRenderer)
	{
		g_pWirePlaneModelRenderer = CDistributedObjectCreator::GetInstance()->CreateModelRenderer();
		g_pWirePlaneModelRenderer->SetRenderMethod(E_RENDERMETHOD::WIREFRAMED);

		CRawModel RawModel;
		RawModel.m_vScale = XMFLOAT3(500.0f, 500.0f, 500.0f);
		ContructRegularGrid(XMINT2(5, 5), &RawModel);

		for (auto iMesh : RawModel.m_RawMeshes)
			g_pWirePlaneModelRenderer->VAddMesh(iMesh, iMesh);
	}

	if (!g_pSolidPlaneModelRenderer)
	{
		g_pSolidPlaneModelRenderer = CDistributedObjectCreator::GetInstance()->CreateModelRenderer();
		g_pSolidPlaneModelRenderer->SetRenderMethod(E_RENDERMETHOD::SOLID);

		CRawModel RawModel;
		RawModel.m_vScale = XMFLOAT3(500.0f, 500.0f, 500.0f);
		ContructRegularGrid(XMINT2(5, 5), &RawModel);

		for (auto iMesh : RawModel.m_RawMeshes)
			g_pSolidPlaneModelRenderer->VAddMesh(iMesh, iMesh);
	}

	IActor *pActor = nullptr;

	//CObject *pObject;

	switch (eActorType)
	{
	case E_ACTOR_TYPE::CUBE:
		{
			// g_pWireBoxModelRenderer g_pSolidBoxModelRenderer

		pActor = new CBox(xvPos - XMVectorReplicate(fBoxSize / 2), xvPos + XMVectorReplicate(fBoxSize / 2),
			g_pWireBoxModelRenderer);
		}
		break;
	case E_ACTOR_TYPE::SPHERE:
	{
		XMFLOAT3 vPos;
		XMStoreFloat3(&vPos, xvPos);

		pActor = new CSphere(vPos, 1.0f, g_pWireSphereModelRenderer);
	}
		break;
	case E_ACTOR_TYPE::PLANE:
		pActor = new CPlane(g_pSolidPlaneModelRenderer);
		((CPlane *)pActor)->GetPlane().x = XMVectorGetX(xvPos);
		((CPlane *)pActor)->GetPlane().y = XMVectorGetY(xvPos);
		((CPlane *)pActor)->GetPlane().z = XMVectorGetZ(xvPos);
		((CPlane *)pActor)->GetPlane().w = XMVectorGetW(xvPos);
		
		break;
	}

	pActor->VInit();

	for (auto iObject : pActor->GetObjects())
	{
		iObject->SetColor(Color);
	}

	return pActor;
}