Ejemplo n.º 1
0
void CObject_Bg_Stage1_2::Update()
{
	SetBoundBox(1160-SrcX, 180-SrcY, 1100, 380);
	if(CCollision::GetCollision()->Box_n_Box(
		Hero->GetBoundX(), Hero->GetBoundY(), Hero->GetBoundX()+Hero->GetBoundWidth(), Hero->GetBoundY()+Hero->GetBoundHeight(),
		GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()))
	{
		b_Forest = TRUE;
	}
	else
	{
		b_Forest = FALSE;
	}
	
	SetBoundBox(1450-SrcX, 200-SrcY, 200, 500);
	// 1450 ╨нем 200
	if(CCollision::GetCollision()->Box_n_Box(
		Hero->GetBoundX(), Hero->GetBoundY(), Hero->GetBoundX()+Hero->GetBoundWidth(), Hero->GetBoundY()+Hero->GetBoundHeight(),
		GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()))
	{
		if(!b_Hide)
		{

		}
	}

	if(Hero->GetWorldX() < 1200 || Hero->GetWorldX() > 1625) {
		
		Hero->SetOpacity(255);
	}
}
Ejemplo n.º 2
0
bool GBoneObj::Load(ID3D11Device* pDevice,const TCHAR* szLoadName,const TCHAR* pLoadShaderFile,bool bThread)
{
	FILE	*fp;
	fp = _tfopen(szLoadName, _T("rb"));
	if (!fp) return false;

	char szBuffer[MAX_PATH] = { 0, };
	size_t convertedChars = 0;

	tm newtime;
	fread(&newtime, sizeof(tm), 1, fp);
	T_STR today = _tasctime(&newtime);	// The date string has a \n appended.
	today[today.size() - 1] = 0;
	fread(&m_Scene, sizeof(TScene), 1, fp);

	// 시작 프레임이 0일 아닐 경우가 있기 때문에 무조건 
	// 시작 프레임을 0으로 맞춘다.( 해당 프레임 만큼만 배열 할당 된다.)
	m_iStartFrame = 0;//m_Scene.iFirstFrame;
	m_iLastFrame = m_Scene.iLastFrame - m_Scene.iFirstFrame;
	m_fElapseTime = (float)m_iStartFrame;
	m_Scene.iFirstFrame = 0;
	m_Scene.iLastFrame = m_iLastFrame;

	SAFE_NEW_ARRAY_CLEAR(m_pMatrix, D3DXMATRIX, m_Scene.iNumMesh);
	SAFE_NEW_ARRAY_CLEAR(m_ppAniMatrix, LPD3DXMATRIX, m_Scene.iNumMesh);
	SAFE_NEW_ARRAY_CLEAR(m_ppAniQuater, LPD3DXQUATERNION, m_Scene.iNumMesh);
	SAFE_NEW_ARRAY_CLEAR(m_ppScaleVector, LPD3DXVECTOR3, m_Scene.iNumMesh);
	SAFE_NEW_ARRAY_CLEAR(m_ppTransVector, LPD3DXVECTOR3, m_Scene.iNumMesh);

	int iNumFrame = m_iLastFrame - m_iStartFrame;
	for (int i = 0; i < m_Scene.iNumMesh; i++)
	{
		SAFE_NEW_ARRAY(m_ppAniMatrix[i], D3DXMATRIX, iNumFrame);
		SAFE_NEW_ARRAY(m_ppAniQuater[i], D3DXQUATERNION, iNumFrame);
		SAFE_NEW_ARRAY(m_ppScaleVector[i], D3DXVECTOR3, iNumFrame);
		SAFE_NEW_ARRAY(m_ppTransVector[i], D3DXVECTOR3, iNumFrame);
	}

	D3DXQUATERNION qRotate;
	D3DXVECTOR3 vScale, vTrans;
	D3DXMATRIX matFrameWorld;

	for (int ibip = 0; ibip < m_Scene.iNumMesh; ibip++)
	{
		for (int iFrame = 0; iFrame < iNumFrame; iFrame++)
		{
			fread(&m_ppAniMatrix[ibip][iFrame], sizeof(D3DXMATRIX), 1, fp);
		}
	}

	for (int ibip = 0; ibip < m_Scene.iNumMesh; ibip++)
	{
		shared_ptr<tMatMesh> pData = make_shared<tMatMesh>();
		shared_ptr<GMesh> pMesh = make_shared<GMesh>();
		int iCount;

		TCHAR szBuffer[256] = { 0, };
		TCHAR szName[256] = { 0, };
		fread(&pMesh->m_ClassType, sizeof(int), 1, fp);
		fread(&iCount, sizeof(int), 1, fp);
		fread(szName, sizeof(TCHAR) * iCount, 1, fp);

		pMesh->m_strNodeName = szName;
		fread(&pMesh->m_matWorld, sizeof(D3DXMATRIX), 1, fp);
		D3DXMatrixInverse(&pData->m_matInverse, 0, &pMesh->m_matWorld);

		fread(&iCount, sizeof(int), 1, fp);
		// 메쉬 버텍스 리스트
		if (iCount == 2)
		{
			pData->m_VertexArray.resize(36);
			m_iMaxVertex += 36;
		}
		else
		{
			pData->m_VertexArray.resize(iCount);
			m_iMaxVertex += iCount;
		}

		for (int iVertex = 0; iVertex < iCount; iVertex++)
		{
			fread(&pData->m_VertexArray[iVertex], sizeof(PNC_VERTEX), 1, fp);
			if (m_Scene.iBindPose)
			{
				D3DXVec3TransformCoord(&pData->m_VertexArray[iVertex].p,
					&pData->m_VertexArray[iVertex].p,
					&pData->m_matInverse);
			}
		}

		// 본과 더미 오브젝트( 최대 및 최소값 2개 출력되어 있음 )
		if (iCount == 2)
		{
			D3DXVECTOR3 Quad[8];
			D3DXVECTOR3 vMax = pData->m_VertexArray[0].p;
			D3DXVECTOR3 vMin = pData->m_VertexArray[1].p;

			Quad[0] = D3DXVECTOR3(vMin.x, vMin.y, vMin.z);
			Quad[1] = D3DXVECTOR3(vMin.x, vMax.y, vMin.z);
			Quad[2] = D3DXVECTOR3(vMax.x, vMax.y, vMin.z);
			Quad[3] = D3DXVECTOR3(vMax.x, vMin.y, vMin.z);

			Quad[4] = D3DXVECTOR3(vMin.x, vMin.y, vMax.z);
			Quad[5] = D3DXVECTOR3(vMin.x, vMax.y, vMax.z);
			Quad[6] = D3DXVECTOR3(vMax.x, vMax.y, vMax.z);
			Quad[7] = D3DXVECTOR3(vMax.x, vMin.y, vMax.z);
			SetBoundBox(Quad, pData.get());
		}
		pMesh->m_iNumFace = pData->m_VertexArray.size() / 3;
		m_pMesh.push_back(pMesh);
		m_pData.push_back(pData);
	}

	for (int ibip = 0; ibip < m_Scene.iNumMesh; ibip++)
	{
		for (int jFrame = 0; jFrame < m_iLastFrame - m_iStartFrame; jFrame++)
		{
			if (m_Scene.iBindPose)
			{
				//m_ppAniMatrix[ibip][jFrame] = m_pData[ibip]->m_matWorld * m_ppAniMatrix[ibip][jFrame];
			}
			if (SUCCEEDED(D3DXMatrixDecompose(&vScale, &qRotate, &vTrans, &m_ppAniMatrix[ibip][jFrame])))
			{
				m_ppAniQuater[ibip][jFrame] = qRotate;
				m_ppScaleVector[ibip][jFrame] = vScale;
				m_ppTransVector[ibip][jFrame] = vTrans;
			}
			else
			{
				D3DXQuaternionRotationMatrix(&m_ppAniQuater[ibip][jFrame], &m_ppAniMatrix[ibip][jFrame]);
			}
		}
	}

	fclose(fp);

	m_dxobj.m_iNumVertex = m_iMaxVertex;
	m_dxobj.m_iNumIndex = m_iMaxIndex;
	m_dxobj.m_iVertexSize = sizeof(PNC_VERTEX);

	if (!bThread && !Create(pDevice, pLoadShaderFile))
	{
		return false;
	}
	return true;
}
Ejemplo n.º 3
0
void CObject_Appletree::Update()
{
	Center = WorldX + GetWidth()/2;
	SetAttackBox(0, 0, 0, 0);

	if(HeroForEnemy->GetWorldX()+100 < Center && !b_Attack)	// Hero가 왼쪽에 있을 때
	{
		b_left = true;
		b_right = false;
	}
	else if(HeroForEnemy->GetWorldX()+100 > Center && !b_Attack)
	{
		b_left = false;
		b_right = true;
	}

	// 인식범위 설정
	int RcnzX = Center;
	if(b_left) {
		RcnzX -= RecognizeRange;
	}
	else if(b_right) {
		RcnzX += RecognizeRange;
	}
	
	// 공격범위 설정
	int AtkX = Center;
	if(b_left) {
		AtkX -= AttackRange;
	}
	else if(b_right) {
		AtkX += AttackRange;
	}

	// 인식범위 내에서의 행동따윈 필요없다.

	// 공격범위 내에서의 행동
	if(GetHP() > 0)
	{
		if(HeroForEnemy->GetWorldX()+100 > AtkX && b_left)
		{
			if(AttackCount == -1 ) {
				SetAttack(true);
				AttackCount = 0;
			}
			if(Poison->GetCount() >= 1 && Poison->GetCount() <= 2) {
				SetAttackBox((int)GetDrawX()+30, (int)GetDrawY()+250, 191, 220);
			}

			for(int i=0; i<2; i++)
			{
				if(Break[i]->GetCount() >=1 && Break[i]->GetCount() <= 3) {
					SetAttackBox((int)GetDrawX()+25, (int)GetDrawY()+400, 180, 100);
				}
			}

			b_apple[0] = true;
		}
		else if(HeroForEnemy->GetWorldX()+100 < AtkX && b_right)
		{
			if(AttackCount == -1 ) {
				SetAttack(true);
				AttackCount = 0;
			}
			if(Poison->GetCount() >= 1 && Poison->GetCount() <= 2) {
				SetAttackBox((int)GetDrawX()+30, (int)GetDrawY()+250, 250, 220);
			}
			
		}

		if(AttackCount != -1) {
			AttackCount++;
		}
		
		if(Poison->GetCount() >= 6) {
			Poison->SetCount(0);
			SetAttack(false);
		}
		

		if(AttackCount > AttackDelay) {
			AttackCount = -1;
			Poison->SetCount(0);
			SetAttack(false);
		}
	}



	
	// 충돌박스 설정
	SetBoundBox((int)GetDrawX()+100, (int)GetDrawY()+50, 158, 400);
	
	// Hero와의 충돌판정
	if(GetHP() > 0)
	{
		if(CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetBoundX()-1, HeroForEnemy->GetBoundY(), HeroForEnemy->GetBoundX()+HeroForEnemy->GetBoundWidth()+1, HeroForEnemy->GetBoundY()+HeroForEnemy->GetBoundHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()))
		{
			if(HeroForEnemy->GetWorldX()+100 < Center)	// Hero가 왼쪽에 있을 때
			{
				//HeroForEnemy->MoveTo(GetWorldX() + (int)((GetWidth()-GetBoundWidth())/2) - HeroForEnemy->GetWidth() + (int)((HeroForEnemy->GetWidth() - HeroForEnemy->GetBoundWidth())/2), HeroForEnemy->GetWorldY());
				HeroForEnemy->MoveTo(GetWorldX() + (int)((GetWidth()-GetBoundWidth())/2) - 115, HeroForEnemy->GetWorldY());
			}
			
			else if(HeroForEnemy->GetWorldX()+100 >= Center)	// Hero가 오른쪽에 있을 때
			{
				HeroForEnemy->MoveTo(GetWorldX() + GetWidth() - (int)((GetWidth()-GetBoundWidth())/2) - (int)((HeroForEnemy->GetWidth()-HeroForEnemy->GetBoundWidth())/2), HeroForEnemy->GetWorldY());
			}
			
		}
	}

	
	// Hero에게 공격판정
	if(CCollision::GetCollision()->Box_n_Box(
		HeroForEnemy->GetBoundX(), HeroForEnemy->GetBoundY(), HeroForEnemy->GetBoundX()+HeroForEnemy->GetBoundWidth(), HeroForEnemy->GetBoundY()+HeroForEnemy->GetBoundHeight(),
		GetAttackX(), GetAttackY(), GetAttackX()+GetAttackWidth(), GetAttackY()+GetAttackHeight()))
	{
		if(!HeroForEnemy->GetHit())
		{
			int dmg = (int)GetDmg();
			if(b_left)
			{
				if(HeroForEnemy->GetWay() == 1 && HeroForEnemy->GetGuard()) {
					dmg = (int)(dmg * 0.3f);
					HeroForEnemy->SetGuardHit(TRUE);
				}
			}
			else if(b_right)
			{
				if(HeroForEnemy->GetWay() == 0 && HeroForEnemy->GetGuard()) {
					dmg = (int)(dmg * 0.3f);
					HeroForEnemy->SetGuardHit(TRUE);
				}
			}
			HeroForEnemy->SetHP(HeroForEnemy->GetHP() - dmg);
			HeroForEnemy->SetHit(true);
			//SetAttack(false);
			if(HeroKnockbackCount == -1)
			{
				HeroKnockbackCount = 0;
			}
		}
	}
	
	// 넉백
	if(HeroKnockbackCount != -1)
	{
		if(HeroForEnemy->GetWorldX()+100 < Center)		// Hero가 왼쪽에 있을 때
		{
			if(HeroForEnemy->GetGuard()) {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()-2, HeroForEnemy->GetWorldY());
			}
			else {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()-3, HeroForEnemy->GetWorldY());
			}
		}
		else if(HeroForEnemy->GetWorldX()+100 > Center)	// Hero가 오른쪽에 있을 때
		{
			if(HeroForEnemy->GetGuard()) {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()+2, HeroForEnemy->GetWorldY());
			}
			else {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()+3, HeroForEnemy->GetWorldY());
			}
		}

		if(HeroKnockbackCount >= 15) {
			HeroKnockbackCount = -1;
			Hit->SetCount(0);
		}
		else {
			HeroKnockbackCount++;
		}
	}
	
	// Hero에게 피격판정
	if(GetHP() > 0)
	{
		if(CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetAttackX(), HeroForEnemy->GetAttackY(), HeroForEnemy->GetAttackX()+HeroForEnemy->GetAttackWidth(), HeroForEnemy->GetAttackY()+HeroForEnemy->GetAttackHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()) ||
			CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetSkillX(), HeroForEnemy->GetSkillY(), HeroForEnemy->GetSkillX()+HeroForEnemy->GetSkillWidth(), HeroForEnemy->GetSkillY()+HeroForEnemy->GetSkillHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()) )
		{
			b_apple[1] = true;
			Poison->SetCount(0);
			SetHit(true);
			if(HitCount == -1) {
				HitCount = 0;

				SetHP(GetHP() - HeroForEnemy->GetDmg());
			}

			if(KnockbackCount == -1) {
				KnockbackCount = 0;
			}
		}
		/*
		if(KnockbackCount != -1)
		{
			if(HeroForEnemy->GetWorldX()+100 < Center)		// Hero가 왼쪽에 있을 때
			{
				MoveTo(GetWorldX()+2, GetWorldY());

			}
			else if(HeroForEnemy->GetWorldX()+100 > Center)	// Hero가 오른쪽에 있을 때
			{
				MoveTo(GetWorldX()-2, GetWorldY());
			}

			if(KnockbackCount >= 10) {
				KnockbackCount = -1;
			}
			else {
				KnockbackCount++;
			}
		}

		if(GetHP() <= 0)
		{
			HeroForEnemy->SetExp(HeroForEnemy->GetExp() + GetExp());
		}
		*/
		if(HitCount >= 0)
		{
			HitCount++;
			if(HitCount >= 20) {
				HitCount = -1;
				SetHit(false);
				//HitEffect->SetCount(0);
			}
		}
	}
	/*
	// 벽
	if(GetWorldX() < -76)
	{
		WorldX = -76;
	}
	*/
	if(GetHP() < 0)
	{
		Opacity -= 6;
		b_Move = false;
		b_Attack = false;
	}
}