Exemplo n.º 1
0
void CGate::HandleEvent(CEvent* pEvent)
{
	if( pEvent->GetEventID() == "generator.destroyed" )
	{
		CBase* generator = (CBase*)pEvent->GetParam();

		tVector2D toGenerator;

		toGenerator.fX = generator->GetPosX() - GetPosX();
		toGenerator.fY = generator->GetPosY() - GetPosY();

		if( Vector2DLength(toGenerator) < 700 )
		{
			CMessageSystem::GetInstance()->SendMsg( new CDestroyBase(this));
		}
	}
}
Exemplo n.º 2
0
void UpdateRollAway( float elapsedTime, CSkill* skill, CParticleSystem* ps )
{
	CPlayer* pPlayer		= CPlayer::GetInstance();
	CBattleMap* pBattleMap	= CBattleMap::GetInstance();
	CBase* character		= pBattleMap->GetCurrChar();
	CBase* target			= pBattleMap->GetCurrEnemyTarget();
	//	if the skill consists of more than one animation, this needs to happen when each one is finished
	if (skill->Trigger()) 
	{
		ps[NINJA_BLOOD].Emit(target->GetPosX(), target->GetPosY());
		ps[NINJA_BLOOD].m_bActive = true; ps[NINJA_BLOOD].m_bLoop = false;

		// FORMULA: str - def + dmg + accuracy * 1.5 + random(-5 to 5) + (QTE amt successful * 5)
		skill->DmgToRender( (int)((float)(character->GetStrength() - target->GetDefense() + 
			skill->GetDmg() + character->GetAccuracy()) * 1.5f + rand() % (5 + 4) - 5) + (skill->GetCurrAmtSuccessful() * 5) );
		target->SetHealth(target->GetHealth() - skill->DmgToRender());
		ps[NINJA_BLOOD].m_bActive = false;
		skill->Trigger(false);
	}
	/*ps[BLOOD].UpdateParticle(elapsedTime);
	ps[BLOOD].DrawParticle(CAssets::GetInstance()->aBloodParticle);*/
}
Exemplo n.º 3
0
void CCamera::Update( float fElapsedTime )
{
	int width( int( theCamera->GetWidth( )-theCamera->GetXOffset( ) ) );
	int height( int( theCamera->GetHeight( )-theCamera->GetYOffset( ) ) );

	RECT rCamera;
	rCamera.left    = LONG( GetXOffset() );
	rCamera.right   = LONG( rCamera.left + GetWidth() );
	rCamera.top     = LONG( GetYOffset() );
	rCamera.bottom  = LONG( rCamera.top + GetHeight() );

	CBase* pCurPlayer;

	RECT rPlayer;
	if( !((CPlayer*)thePlayer)->GetFainted() || thePlayer2 == NULL )
	{
		pCurPlayer = thePlayer;
	 rPlayer    = thePlayer->GetCollisionRect( fElapsedTime );
	}
	else if( thePlayer2 )
	{
		pCurPlayer = thePlayer2;

	 rPlayer    = thePlayer2->GetCollisionRect( fElapsedTime );
	}



	int CenterOfScreenX( int( theCamera->GetXOffset( ) + width / 2 ) );
	int CenterOfScreenY( int( theCamera->GetYOffset( ) + height / 2 ) );

	RECT rHook, r;
	int x          = thePlayer->GetWidth( );
	rHook.left     = CenterOfScreenX - ( thePlayer->GetWidth( ) << 1 );
	rHook.top      = CenterOfScreenY - ( thePlayer->GetHeight( ) );
	rHook.right    = CenterOfScreenX + ( thePlayer->GetWidth( ) << 1 );
	rHook.bottom   = CenterOfScreenY + ( thePlayer->GetHeight( ) );

	if( !IntersectRect( &r, &rPlayer, &rCamera ) )
	{
		theCamera->SetCameraXOffset( pCurPlayer->GetPosX( ) - width / 2 );
		theCamera->SetCameraYOffset( pCurPlayer->GetPosY( ) - height / 2 );
	}

	if (IntersectRect( &r, &rHook, &rPlayer ) )
	{
		theCamera->SetVelocityX( theCamera->GetVelocityX( ) * 0.95f );
		theCamera->SetVelocityY( theCamera->GetVelocityY( ) * 0.95f );
	}

	{
		if( rPlayer.left < rHook.left && pCurPlayer->GetVelX() < -110)
			theCamera->SetVelocityX( pCurPlayer->GetVelX());
		else if( rPlayer.left < rHook.left )
			theCamera->SetVelocityX( -100 );
		else if( rPlayer.right > rHook.right && pCurPlayer->GetVelX() > 110)
			theCamera->SetVelocityX( pCurPlayer->GetVelX() );
		else if( rPlayer.right > rHook.right )
			theCamera->SetVelocityX( 100 );

		if( rPlayer.top < rHook.top )
			theCamera->SetVelocityY( -100 );
		else if( rPlayer.bottom > rHook.bottom && pCurPlayer->GetVelY() > 200)
			theCamera->SetVelocityY( pCurPlayer->GetVelY() );
		else if(rPlayer.bottom > rHook.bottom)
			theCamera->SetVelocityY( 200 );
		
	}

	theCamera->SetCameraXOffset( theCamera->GetXOffset( ) + theCamera->GetVelocityX( ) * fElapsedTime );
	theCamera->SetCameraYOffset( theCamera->GetYOffset( ) + theCamera->GetVelocityY( ) * fElapsedTime );
}
void CGamePlay::HandleEvent(CEvent *pEvent)
{
	CSGD_ObjectFactory<string, CBase> *pOF		= CSGD_ObjectFactory<string, CBase>::GetInstance();
	CSGD_ObjectManager *pOM						= CSGD_ObjectManager::GetInstance();
 	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();

	if (pEvent->GetEventID() == "spawn powerups")
	{
		CBase *tempPowerup;
		int nRandomPowerup = rand() % 100 + 1;

		if (nRandomPowerup <= 30)
			tempPowerup = pOF->CreateObject("CPowerupHealth");
		else if (nRandomPowerup > 30 && nRandomPowerup <= 60)
			tempPowerup = pOF->CreateObject("CPowerupRapidFire");
		else if (nRandomPowerup > 60 && nRandomPowerup <= 90)
			tempPowerup = pOF->CreateObject("CPowerupThreeWay");
		else if (nRandomPowerup > 90)
			tempPowerup = pOF->CreateObject("CPowerup1up");

		tempPowerup ->SetImageID(m_nImageID[3]);
		tempPowerup->SetPosX(CPlayerCharacter::GetInstance()->GetPosX() + 128);
		if (tempPowerup->GetPosX() > 640)
			tempPowerup->SetPosX(640);
		tempPowerup->SetPosY(CPlayerCharacter::GetInstance()->GetPosY() + 32);
		pOM->AddObject(tempPowerup );
		tempPowerup ->Release();
	}

	else if (pEvent->GetEventID() == "scroll right")
	{
		if (GetBridgeOffset() > -100)
		{
			SetBridgeOffset(GetBridgeOffset() - (5 * CGame::GetInstance()->GetSpeed()));
			SetSpaceOffset(GetSpaceOffset() - (15 * CGame::GetInstance()->GetSpeed()));
			for (int i = 0; i < enemies.size(); ++i)
			{
				enemies[i]->SetPosX(enemies[i]->GetPosX() - (5 * CGame::GetInstance()->GetSpeed()));
			}
		}
	}

	else if (pEvent->GetEventID() == "scroll left")
	{
		if (GetBridgeOffset() < 0)
		{
			SetBridgeOffset(GetBridgeOffset() + (5 * CGame::GetInstance()->GetSpeed()));
			SetSpaceOffset(GetSpaceOffset() + (15 * CGame::GetInstance()->GetSpeed()));
			for (int i = 0; i < enemies.size(); ++i)
			{
				enemies[i]->SetPosX(enemies[i]->GetPosX() + (5 * CGame::GetInstance()->GetSpeed()));
			}
		}
	}

	else if (pEvent->GetEventID() == "spawn enemies")
	{
		CBase *tempEnemy;
		if (GetLevel() == 1 && m_nRemainingEnemies > 0 && m_nTotalSpawns < 10)
		{
			m_nEnemyCounter += 1;
			m_nTotalSpawns += 1;

			if (m_nTotalSpawns % 2 == 1)
			{
				tempEnemy = pOF->CreateObject("CEnemyDemon");
				tempEnemy ->SetImageID(m_nImageID[1]);
				pOM->AddObject(tempEnemy );
				tempEnemy ->Release();
				enemies.push_back(tempEnemy);
			}
			else
			{
				tempEnemy = pOF->CreateObject("CEnemyBusiness");
				tempEnemy ->SetImageID(m_nImageID[1]);
				pOM->AddObject(tempEnemy );
				tempEnemy ->Release();
				enemies.push_back(tempEnemy);
			}
	   }
	if (GetLevel() == 2 && m_nRemainingEnemies > 0 && m_nTotalSpawns < 10)
	{
		m_nEnemyCounter += 1;
		m_nTotalSpawns += 1;

		if (m_nTotalSpawns % 2 == 1)
		{
			tempEnemy = pOF->CreateObject("CEnemyMeat");
			tempEnemy ->SetImageID(m_nImageID[2]);
			pOM->AddObject(tempEnemy );
			tempEnemy ->Release();
			enemies.push_back(tempEnemy);
		}
		else
		{
			tempEnemy = pOF->CreateObject("CEnemyBooger");
			tempEnemy ->SetImageID(m_nImageID[2]);
			pOM->AddObject(tempEnemy );
			tempEnemy ->Release();
			enemies.push_back(tempEnemy);
		}
	}
	if (GetLevel() == 3)
	{
		tempEnemy = pOF->CreateObject("CEnemyPsycrow");
		tempEnemy->SetImageID(m_nBGID);
		pOM->AddObject(tempEnemy);
		tempEnemy->Release();
		enemies.push_back(tempEnemy);
	}
	}
}