void CBulletHook::Update(float fElapsedTime)
{
	CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
	CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
	CGamePlay *pGP = CGamePlay::GetInstance();
	CPlayerCharacter *pPC = CPlayerCharacter::GetInstance();


	if (GetScoreValue() == 1.0f)
	{
		m_fLifeTime -= fElapsedTime;
		SetPosX(GetPosX() + GetVelX() * fElapsedTime);
		SetPosY(GetPosY() + GetVelY() * fElapsedTime);
	}
	else if (GetScoreValue() == 2.0f)
		m_fLifeTime -= fElapsedTime * 0.25f;
	else  if (GetScoreValue() == 3.0f)
	{
		m_fLifeTime -= fElapsedTime;
		SetPosX(GetPosX() + GetVelX() * fElapsedTime);
		SetPosY(GetPosY() + GetVelY() * fElapsedTime);
		if (GetPosX() < pPC->GetPosX())
			SetVelX(abs(GetVelX()));
		else if (GetPosX() >= pPC->GetPosX())
			SetVelX(-abs(GetVelX()));
		if (GetPosY() < pPC->GetPosY())
			SetVelY(abs(GetVelY()));
		else if (GetPosY() >= pPC->GetPosY())
			SetVelY(-abs(GetVelY()));
	}

	rCollisionRect.top = GetPosY();
	rCollisionRect.left = GetPosX();
	rCollisionRect.bottom = GetPosY() + GetHeight();
	rCollisionRect.right = GetPosX() + GetWidth();

	CBase *player;
	player = CPlayerCharacter::GetInstance();

	RECT cross;

	if (IntersectRect(&cross,&rCollisionRect,&player->GetCollisionRect()))
	{
		pMS->SendMsg(new CCollisionMessage(player,this));
		pMS->SendMsg(new CDestroyMessage(this));
	}

	if (m_fLifeTime <= 0)
		pMS->SendMsg(new CDestroyMessage(this));

}
CEnemyDemon::CEnemyDemon()
{
    COptions *op = COptions::GetInstance();
    CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance();

    SetHP(25 * op->GetDifficulty());
    SetVelX(100.0f * op->GetDifficulty());
    SetVelY(100.0f * op->GetDifficulty());
    SetXFlip(-1);
    SetHeight(64);
    SetWidth(64);
    SetPosX(500);
    SetPosY(500);
    SetType(ACTOR_ENEMY);
    SetPower(5 * op->GetDifficulty());
    SetScoreValue(100 * op->GetDifficulty());
    SetHit(false);

    rEnemyRect.top = 65;
    rEnemyRect.bottom = 123;
    rEnemyRect.left = 0;
    rEnemyRect.right = 60;

    m_nSoundID = CSGD_WaveManager::GetInstance()->LoadWave("Resource/sounds/JoA_Bark.wav");
    CSGD_WaveManager::GetInstance()->SetVolume(m_nSoundID,COptions::GetInstance()->GetSFXVolume()-40);


}
CBase::CBase(void)
{
	SetImageID(-1);
	SetVelX(0.0f);
	SetVelY(0.0f);
	SetWidth(0);
	SetHeight(0);

	m_unRefCount = 1;
}
Exemplo n.º 4
0
CBase::CBase(void)
{
	PROFILE("CBase::CBase()");
	m_unRefCount = 1;	//	Always start with a reference to yourself
	SetPosX( 0.0f );
	SetPosY( 0.0f );
	SetVelX( 1.0f );
	SetVelY( 1.0f );
	STOP("CBase::CBase()");
}
Exemplo n.º 5
0
void Enemy::Move(GameObject *otherObject){
	float dir;
	if(GetAlive()){
		if(otherObject->GetID() == PLAYER){
			if(otherObject->GetX() - x >= 0){
				dir = atan((otherObject->GetY() - y)/(otherObject->GetX() - x));
			}
			else{
				dir = atan((otherObject->GetY() - y)/(otherObject->GetX() - x)) + M_PI;
			}

			SetVelX(vel*cos(dir));
			SetVelY(vel*sin(dir));
		}
	}
}
Exemplo n.º 6
0
CTurtle::CTurtle(void)
{
	m_nType = OBJECT_TURTLE;
	m_nCurrSelectedSkill = -1;
	m_bIsAlive = true;
	SetVelX(100.0f);
	SetVelY(50.0f);
	SetWidth(50);
	SetHeight(80);
	m_nCurrWeapon = 0;
	m_pOwner = NULL;
	m_nNumType = -1;

	m_nPrevLvl = 0;
	m_nPrevStr = 0;
	m_nPrevDef = 0;
	m_nPrevAcc = 0;
	m_nDamageDon = 0;
	m_nDamageRec = 0;
}
CEnemyPsycrow::CEnemyPsycrow()
{
	CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance();
	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();
	COptions *op = COptions::GetInstance();

	pES->RegisterClient("psycrow fire", this);
	pES->RegisterClient("state transition 1", this);
	pES->RegisterClient("state transition 2", this);
	pES->RegisterClient("state transition 3", this);
	pES->RegisterClient("state transition 4", this);

	m_nState = PSYCROW_STATE1;
	m_nSoundID = CSGD_WaveManager::GetInstance()->LoadWave("Resource/sounds/JoA_Squawk.wav");
	CSGD_WaveManager::GetInstance()->SetVolume(m_nSoundID, op->GetSFXVolume() - 40);
	m_fFireReady = 5.0f;
	m_fHitTimer = 0.4f;
	m_nOffset = 0;
	bIsFired = false;
	m_fFiringTimer = 0.5f;
	m_fSineFloat = 3.14f;
	m_nColor = 255;
	m_nScale = 1.5f;

	SetHP(250 * op->GetDifficulty());
	SetVelX(75 * op->GetDifficulty());
	SetVelY(0.0f);
	SetXFlip(-1);
	SetHeight(84);
	SetWidth(70);
	SetPosX(320);
	SetPosY(240);
	SetPower(0);
	SetType(ACTOR_ENEMY);
	SetScoreValue(1000 * op->GetDifficulty());
	SetHit(false);
	pBullet = NULL;

	bIsFiring = false;

}
CEnemyBusiness::CEnemyBusiness()
{
	CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance();
	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();
	COptions *op = COptions::GetInstance();
	CSGD_WaveManager *pWM = CSGD_WaveManager::GetInstance();

	pES->RegisterClient("businessman fire", this);

	SetHP(50 *op->GetDifficulty());
	SetVelX(-50.0f * op->GetDifficulty());
	SetVelY(0.0f);
	SetXFlip(-1);
	SetHeight(63);
	SetWidth(86);
	SetPosX(1000);
	SetPosY(220);
	SetPower(0);
	SetType(ACTOR_ENEMY);
	SetScoreValue(200 * op->GetDifficulty());
	SetHit(false);
	pBullet = NULL;

	bIsFiring = false;

	m_fFireReady = 5.0f;
	m_fHitTimer = 1.0f;
	m_nOffset = 0;
	m_fFiringTimer = 1.0f;

	rEnemyRect.top = 18;
	rEnemyRect.bottom = 61;
	rEnemyRect.left = 2;
	rEnemyRect.right = 54;

	m_nSoundID = pWM->LoadWave("Resource/sounds/JoA_Scream.wav");
	pWM->SetVolume(m_nSoundID,op->GetSFXVolume() - 25);
	

}
Exemplo n.º 9
0
void CBullet::Update(float fElapsedTime)
{
	if(GetIsScrew())
	{
		// Gravity is applied to screws		
		SetVelY(GetVelY() + 100.0f * GAME->GetTimer().GetDeltaTime());

		SetPosX(GetPosX()+(GetVelX() * GAME->GetTimer().GetDeltaTime()));
		SetPosY(GetPosY()+(GetVelY() * GAME->GetTimer().GetDeltaTime()));	

		//if((GetVelY() < 1.0f && GetVelY() > -1.0f) /*|| (GetVelX() < 1.0f && GetVelX() > -1.0f)*/)
		//	MS->SendMsg(new CDestroyBulletMessage(this));
	}

	// Killing the bullet if it gets offscreen
	if(m_fTimer > 10.0f)
		MS->SendMsg(new CDestroyBulletMessage(this));

	m_fTimer += GAME->GetTimer().GetDeltaTime();

	CBase::Update(fElapsedTime);
}
void CEnemyPsycrow::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();
	COptions *op = COptions::GetInstance();

	if (pEvent->GetEventID() == "psycrow fire")
	{
		pBullet = pOF->CreateObject("CBulletHook");

		pBullet->SetImageID(GetImageID());

		if (GetState() == PSYCROW_STATE1)
		{
			if (CPlayerCharacter::GetInstance()->GetPosX() > GetPosX())
				pBullet->SetVelX(op->GetDifficulty() * 150);
			else
				pBullet->SetVelX(op->GetDifficulty() * -150);
			if (CPlayerCharacter::GetInstance()->GetPosY() > GetPosY())
				pBullet->SetVelY(op->GetDifficulty() * 150);
			else
				pBullet->SetVelY(op->GetDifficulty() * -150);
			pBullet->SetScoreValue(1);
		}
		else if (GetState() == PSYCROW_STATE3)
		{
			if (CPlayerCharacter::GetInstance()->GetPosX() > GetPosX())
				pBullet->SetVelX(0);
			else
				pBullet->SetVelX(0);
			if (CPlayerCharacter::GetInstance()->GetPosY() > GetPosY())
				pBullet->SetVelY(0);
			else
				pBullet->SetVelY(0);
			pBullet->SetScoreValue(2);
		}
		else if (GetState() == PSYCROW_STATE5)
		{
			if (CPlayerCharacter::GetInstance()->GetPosX() > GetPosX())
				pBullet->SetVelX(op->GetDifficulty() * 50);
			else
				pBullet->SetVelX(op->GetDifficulty() * -50);
			if (CPlayerCharacter::GetInstance()->GetPosY() > GetPosY())
				pBullet->SetVelY(op->GetDifficulty() * 50);
			else
				pBullet->SetVelY(op->GetDifficulty() * -50);
			pBullet->SetScoreValue(3);
		}


		pBullet->SetPosX(GetPosX() + (GetXFlip() * 64));
		pBullet->SetPosY(GetPosY() + 48);
		pBullet->SetType(ACTOR_BULLET);

		pBullet->SetHeight(12);
		pBullet->SetWidth(28);
		pBullet->SetPower(5 * op->GetDifficulty());

		pOM->AddObject(pBullet);
	}

	else if (pEvent->GetEventID() == "state transition 1")
	{
		m_nState = PSYCROW_STATE2;
		m_nColor = 200;
		m_fHitTimer = 0.4f;
		SetVelX(100 * op->GetDifficulty());
		SetVelY(150 * op->GetDifficulty());
		SetPower(5 * COptions::GetInstance()->GetDifficulty());
		CGamePlay::GetInstance()->SetBridgeVelocity(COptions::GetInstance()->GetDifficulty() * 50);
		if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX())
			SetXFlip(-1);
		else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX())
			SetXFlip(1);
	}
	else if (pEvent->GetEventID() == "state transition 2")
	{
		m_nState = PSYCROW_STATE3;
		m_nColor = 150;
		m_fHitTimer = 0.4f;
		SetPower(0);
		SetVelX(75 * op->GetDifficulty() * m_nState);
		CGamePlay::GetInstance()->SetBridgeVelocity(COptions::GetInstance()->GetDifficulty() * 75);
		if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX())
			SetXFlip(-1);
		else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX())
			SetXFlip(1);
	}
	else if (pEvent->GetEventID() == "state transition 3")
	{
		m_nState = PSYCROW_STATE4;
		m_nColor = 100;
		m_fHitTimer = 0.4f;
		SetVelX(250 * op->GetDifficulty());
		SetVelY(150 * op->GetDifficulty());
		SetPower(5 * COptions::GetInstance()->GetDifficulty());
		CGamePlay::GetInstance()->SetBridgeVelocity(COptions::GetInstance()->GetDifficulty() * 100);
		if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX())
			SetXFlip(-1);
		else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX())
			SetXFlip(1);
	}
	else if (pEvent->GetEventID() == "state transition 4")
	{
		m_nState = PSYCROW_STATE5;
		m_nColor = 50;
		m_fHitTimer = 0.4f;
		SetPower(0);
		SetVelX(75 * op->GetDifficulty() * m_nState);
		CGamePlay::GetInstance()->SetBridgeVelocity(COptions::GetInstance()->GetDifficulty() * 125);
		if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX())
			SetXFlip(-1);
		else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX())
			SetXFlip(1);
	}

}
void CEnemyBusiness::Update(float fElapsedTime)
{

	CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
	CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
	CSGD_EventSystem *pES= CSGD_EventSystem::GetInstance();
	CGame *theGame = CGame::GetInstance();

	SetPosX(GetPosX() + GetVelX() * fElapsedTime);
	SetPosY(GetPosY() + GetVelY() * fElapsedTime);

	rCollisionRect.left = GetPosX();
	rCollisionRect.right = GetPosX() + GetWidth();
	rCollisionRect.top = GetPosY();
	rCollisionRect.bottom = GetPosY() + GetHeight();
	SetCollisionRect(rCollisionRect);

	DWORD timer = GetTickCount();

	if (GetHit())
	{
		m_nOffset = 32;
		m_fHitTimer = 1.0f;
		SetVelX(0);
		rEnemyRect.left = 442;
		rEnemyRect.right = 463;
	}

	else if (!GetHit() && m_fHitTimer <= 0)
	{
		m_nOffset = 0;
		m_fFireReady -= fElapsedTime;
		SetVelX(GetXFlip() * -100);
		if (timer % 700 <= 100)
		{
			rEnemyRect.left = 2;
			rEnemyRect.right = 54;
		}
		else if (timer % 700 > 100 && timer % 700 <= 200)
		{
			rEnemyRect.left = 58;
			rEnemyRect.right = 115;
		}
		else if (timer % 700 > 200 && timer % 700 <= 300)
		{
			rEnemyRect.left = 119;
			rEnemyRect.right = 163;
		}
		else if (timer % 700 > 300 && timer % 700 <= 400)
		{
			rEnemyRect.left = 700;
			rEnemyRect.right = 753;
		}
		else if (timer % 700 > 400 && timer % 700 <= 500)
		{
			rEnemyRect.left = 756;
			rEnemyRect.right = 795;
		}
		else if (timer % 700 > 500 && timer % 700 <= 600)
		{
			rEnemyRect.left = 798;
			rEnemyRect.right = 850;
		}
		else if (timer % 700 > 600)
		{
			rEnemyRect.left = 853;
			rEnemyRect.right = 899;
		}
	}

	if (m_fFireReady <=0 && !GetHit() && GetHP() > 0)
		pES->SendEvent("businessman fire",&fElapsedTime);

	if (bIsFiring)
	{
		rEnemyRect.left = 329;
		rEnemyRect.right = 397;
		m_fFiringTimer -= fElapsedTime;
		SetVelX(0);
	}

	if (m_fFiringTimer <= 0)
	{
		bIsFiring = false;
		m_fFiringTimer = 1.0f;
	}

	if (GetPosX() < -32)
	{
		SetVelX(abs(GetVelX() * -1));
		SetXFlip(-abs(GetXFlip() * -1));
	}
	else if (GetPosX() > 640)
	{
		SetVelX(-abs(GetVelX() * -1));
		SetXFlip(abs(GetXFlip() * -1));
	}
	else if (GetPosY() > 480)
		SetVelY(-abs(GetVelY() * -1));
	else if (GetPosY() < -32)
		SetVelY(abs(GetVelY() * -1));

	m_fHitTimer -= fElapsedTime;

	SetHit(false);

	if (GetHP() <= 0)
	{
		CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);

		CSGD_EventSystem::GetInstance()->SendEvent("spawn powerups", NULL);
		pMS->SendMsg(new CDestroyMessage(this));

	}

}
void CEnemyDemon::Update(float fElapsedTime)
{

    CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
    CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
    CGame *theGame = CGame::GetInstance();

    SetPosX(GetPosX() + GetVelX() * fElapsedTime);
    SetPosY(GetPosY() + GetVelY() * fElapsedTime);

    rCollisionRect.left = GetPosX();
    rCollisionRect.right = GetPosX() + GetWidth();
    rCollisionRect.top = GetPosY();
    rCollisionRect.bottom = GetPosY() + GetWidth();
    SetCollisionRect(rCollisionRect);

    if (GetPosX() < -32)
    {
        SetVelX(abs(GetVelX() * -1));
        SetXFlip(-abs(GetXFlip() * -1));
    }
    else if (GetPosX() > 640)
    {
        SetVelX(-abs(GetVelX() * -1));
        SetXFlip(abs(GetXFlip() * -1));
    }
    else if (GetPosY() > 480)
        SetVelY(-abs(GetVelY() * -1));
    else if (GetPosY() < -32)
        SetVelY(abs(GetVelY() * -1));


    DWORD timer = GetTickCount();

    if (abs(GetPosX() - CPlayerCharacter::GetInstance()->GetPosX()) < 128 && abs(GetPosY() - CPlayerCharacter::GetInstance()->GetPosY()) < 128)
        bIsClose = true;
    else
        bIsClose = false;

    if (!bIsClose)
    {
        if (timer % 525 <= 75)
        {
            rEnemyRect.left = 0;
            rEnemyRect.right = 48;
        }
        else if (timer % 525 > 75 && timer % 525 <= 150)
        {
            rEnemyRect.left = 51;
            rEnemyRect.right = 90;
        }
        else if (timer % 525 > 150 && timer % 525 <= 225)
        {
            rEnemyRect.left = 93;
            rEnemyRect.right = 138;
        }
        else if (timer % 525 > 225 && timer % 525 <= 300)
        {
            rEnemyRect.left = 142;
            rEnemyRect.right = 185;
        }
        else if (timer % 525 > 300 && timer % 525 <= 375)
        {
            rEnemyRect.left = 188;
            rEnemyRect.right = 234;
        }
        else if (timer % 525 > 375 && timer % 525 <= 450)
        {
            rEnemyRect.left = 237;
            rEnemyRect.right = 282;
        }
        else if (timer % 525 > 450)
        {
            rEnemyRect.left = 286;
            rEnemyRect.right = 332;
        }
    }
    else if (bIsClose)
    {
        if (timer % 600 <= 75)
        {
            rEnemyRect.left = 335;
            rEnemyRect.right = 372;
        }
        else if (timer % 600 > 75 && timer % 600 <= 150)
        {
            rEnemyRect.left = 375;
            rEnemyRect.right = 407;
        }
        else if (timer % 600 > 150 && timer % 600 <= 225)
        {
            rEnemyRect.left = 410;
            rEnemyRect.right = 445;
        }
        else if (timer % 600 > 225 && timer % 600 <= 300)
        {
            rEnemyRect.left = 448;
            rEnemyRect.right = 481;
        }
        else if (timer % 600 > 300 && timer % 600 <= 375)
        {
            rEnemyRect.left = 484;
            rEnemyRect.right = 515;
        }
        else if (timer % 600 > 375 && timer % 600 <= 450)
        {
            rEnemyRect.left = 518;
            rEnemyRect.right = 554;
            CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);

        }
        else if (timer % 600 > 450 && timer % 600 <= 525)
        {
            rEnemyRect.left = 558;
            rEnemyRect.right = 592;
        }
        else if (timer % 600 > 525)
        {
            rEnemyRect.left = 595;
            rEnemyRect.right = 636;
        }
    }
    SetHit(false);

    if (GetHP() <= 0)
    {
        CSGD_EventSystem::GetInstance()->SendEvent("spawn powerups", NULL);
        pMS->SendMsg(new CDestroyMessage(this));
    }

}
Exemplo n.º 13
0
void CEarthBoss::Update(float fElapsedTime)
{
	CEnemy::Update(fElapsedTime);

	if (m_pEState->GetState() == EntityState::DEAD)
	{
		return;
	}

	m_fUpdateOldPos += fElapsedTime;
	if(m_nCoolDown > 0)
		m_nCoolDown -= fElapsedTime;

	if( m_fPunchCoolDown > 0.0f  && m_bPunching == true)
		m_fPunchCoolDown -= fElapsedTime;
	else
	{
		m_fPunchCoolDown = 2.5f;
		m_bPunching = false;
	}

	if (m_fSpecialTimer > 0.0f)
		m_fSpecialTimer -= fElapsedTime;
	else
	{
		CCreate_Rock_Fall_Message* pMsg = new CCreate_Rock_Fall_Message();
		CSGD_MessageSystem::GetInstance()->SendMsg(pMsg);
		pMsg = nullptr;

		m_fSpecialTimer = 15.0f;
	}

	//if not rushing do basic path finding to the player
	if(GetTarget() != nullptr)
	{
		float tar_pos_x = GetTarget()->GetPosX();
		float tar_pos_y = GetTarget()->GetPosY();
		if(tar_pos_x > GetPosX())
		{
			//set Grunt's animation's facing to the right
			SetFlipped(true);
		}
		else
		{
			SetFlipped(false);
		}


		if(m_fMoveAway <= 0)
		{

			//	tar_pos_x += (m_bFlipped) ? -236 : 236;

			//Simple Pathing twards the player
			if(tar_pos_y != GetPosY())//Above the Player
			{
				float min_Distance = (float)(GetTarget()->GetWidth()/2 + GetWidth()/2);
				if(GetPosX() + min_Distance > tar_pos_x && GetPosX() - min_Distance < tar_pos_x)
				{
					if( tar_pos_x < GetPosX())

						SetVelX(speed * fElapsedTime);
					else

						SetVelX(-speed * fElapsedTime);
				}
				else
				{
					if( tar_pos_y < GetPosY())

						SetVelY(-speed * fElapsedTime);
					else

						SetVelY(speed * fElapsedTime);
					if( tar_pos_x < GetPosX())

						SetVelX(-speed * fElapsedTime);
					else

						SetVelX(speed * fElapsedTime);

					if( tar_pos_x > (GetPosX() - 64) && tar_pos_x < (GetPosX() + 64) )
					{


						if( tar_pos_y > (GetPosY() - 32) && tar_pos_y < (GetPosY() + 32) && m_bPunching == false)
						{

							GetAnimInfo()->SetAnimationName("Boss1_Attack_Animation");
							m_bPunching = true;
							//dynamic_cast<CPlayer*>(GetTarget())->SetState(CEntityState::KNOCKED_DOWN);
						}
					}
				}
			}
			else
			{
				SetVelY(0);
				if( tar_pos_x < GetPosX())

					SetVelX(-speed * fElapsedTime);
				else

					SetVelX(speed * fElapsedTime);
			}

			//if the player can be shot at.
			if(m_nCoolDown <= 0 && GetPosX() - tar_pos_x < 128 && GetPosX() - tar_pos_x > -128 )
			{
				if(GetPosY() - tar_pos_y < 5 && GetPosY() - tar_pos_y > -5 && m_bPunching == false)
				{

					//GetAnimInfo()->SetAnimationName("Boss1_Shoot_Animation");
					////if in range rushing starts
					//CCreate_Projectile_Message* c_pProjectMSG = new CCreate_Projectile_Message(ENT_ENEMY, IsFlipped());
					//c_pProjectMSG->SetPosX(this->GetPosX());
					//c_pProjectMSG->SetPosY(this->GetPosY());

					//CSGD_MessageSystem::GetInstance()->SendMsg(c_pProjectMSG);
					m_nCoolDown += 5;
				}
			}
			//stop 'bouncing'
			int threshold = 5;
			if(tar_pos_x - GetPosX() < threshold && tar_pos_x - GetPosX() > -1 * threshold)
				SetVelX(0);
			if(tar_pos_y - GetPosY() < threshold && tar_pos_y - GetPosY() > -1 * threshold)
				SetVelY(0);
		}
		else //update move away
		{
			m_fMoveAway -= fElapsedTime;
			if(m_bEvadeUp)
				SetVelY(-speed * fElapsedTime);
			else
				SetVelY(speed * fElapsedTime);
		}
	}

	//Check Colider
	if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), GetVelX(), 0))
	{
		SetPosX(GetPosX() + GetVelX());
		if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, GetVelY()))
		{
			SetPosY(GetPosY() + GetVelY());
		}
	}
	else
	{
		if( GetPosY() >= 600 )
			SetPosY( (GetPosY() - (GetPosY() - 599)) );
		else
			SetPosY(GetPosY() + 1);
		SetVelX(0);
		SetVelY(0);
	}
	if(GetPosX() < 0)
		SetPosX(0);

	//Set/use Move out of the way
	if(m_fUpdateOldPos >= 1.0f)
	{
		if(m_fPosXOld + 5 > GetPosX() && m_fPosXOld - 5 < GetPosX())
		{
			if(m_fPosYOld + 5 > GetPosY() && m_fPosYOld - 5 < GetPosY())
			{
				if(m_nCoolDown <= 0)
				{
					m_bEvadeUp = !m_bEvadeUp;
					if(m_fMoveAway <= 0)
						m_fMoveAway = 4.0f;
				}
			}
		}
		m_fPosXOld = GetPosX();
		m_fPosYOld = GetPosY();
		m_fUpdateOldPos = 0.0f;
	}

}
Exemplo n.º 14
0
void CEntity::SetVelocity( float vx, float vy )
{
	SetVelX(vx);
	SetVelY(vy);
}
void CEnemyPsycrow::Update(float fElapsedTime)
{
	COptions *op = COptions::GetInstance();
	CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
	CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
	CSGD_EventSystem *pES= CSGD_EventSystem::GetInstance();
	CGame *theGame = CGame::GetInstance();

	if (m_nState % 2 == 0)
	{
		SetVelY(sin(m_fSineFloat) * 50 * op->GetDifficulty() * (m_nState + 0.5));
		rEnemyRect.top = 507;
		rEnemyRect.bottom = 561;
		rEnemyRect.left = 584;
		rEnemyRect.right = 650;

		if (!bIsFiring)
			m_fFireReady -= fElapsedTime;
		
		if (m_fFireReady <= 0)
			bIsFiring = true;

		if (bIsFiring)
		{
			m_fFiringTimer -= fElapsedTime;
			if (m_fFiringTimer <= 0.5f && m_fFiringTimer > 0.4f)
			{
				rEnemyRect.top = 507;
				rEnemyRect.bottom = 561;
				rEnemyRect.left = 494;
				rEnemyRect.right = 566;
				if (!bIsFired)
				{
					pES->SendEvent("psycrow fire", NULL);
					bIsFired = true;

				}
			}
			else if (m_fFiringTimer <= 0.4f && m_fFiringTimer > 0.3f)
			{
				rEnemyRect.top = 507;
				rEnemyRect.bottom = 567;
				rEnemyRect.left = 790;
				rEnemyRect.right = 856;
			}
			else if (m_fFiringTimer <= 0.3f && m_fFiringTimer > 0.2f)
			{
				rEnemyRect.top = 511;
				rEnemyRect.bottom = 564;
				rEnemyRect.left = 873;
				rEnemyRect.right = 935;
			}
			else if (m_fFiringTimer <= 0.2f && m_fFiringTimer > 0.1f)
			{
				rEnemyRect.top = 581;
				rEnemyRect.bottom = 641;
				rEnemyRect.left = 502;
				rEnemyRect.right = 573;
			}
			else if (m_fFiringTimer <= 0.1f)
			{
				rEnemyRect.top = 579;
				rEnemyRect.bottom = 639;
				rEnemyRect.left = 601;
				rEnemyRect.right = 673;
				bIsFiring = false;
				bIsFired = false;
				m_fFireReady = 5.0f;
				m_fFiringTimer = 0.5f;
			}

		}
	}
	else if (m_nState % 2 == 1)
	{
		rEnemyRect.top = 666;
		rEnemyRect.bottom = 726;
		DWORD timer = GetTickCount();
		if (timer % 300 <= 100)
		{
			rEnemyRect.left = 494;
			rEnemyRect.right = 533;
		}
		else if (timer % 300 > 100 && timer % 300 <= 200)
		{
			rEnemyRect.left = 542;
			rEnemyRect.right = 581;
		}
		else if (timer % 300 > 200)
		{
			rEnemyRect.left = 591;
			rEnemyRect.right = 630;
		}
	}

	if (GetHP() < op->GetDifficulty() * 200 && m_nState == PSYCROW_STATE1)
	{
		rEnemyRect.top = 674;
		rEnemyRect.bottom = 726;
		m_fHitTimer -= fElapsedTime;
		if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f)
		{
			CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);
			rEnemyRect.left = 649;
			rEnemyRect.right = 708;
		}
		else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f)
		{
			rEnemyRect.left = 719;
			rEnemyRect.right = 772;
		}
		else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f)
		{
			rEnemyRect.left = 787;
			rEnemyRect.right = 844;
		}
		else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f)
		{
			rEnemyRect.left = 861;
			rEnemyRect.right = 912;
		}

		if (m_fHitTimer < 0)
			pES->SendEvent("state transition 1");
	}
	if (GetHP() < op->GetDifficulty() * 150 && m_nState == PSYCROW_STATE2)
	{
		rEnemyRect.top = 674;
		rEnemyRect.bottom = 726;
		m_fHitTimer -= fElapsedTime;
		if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f)
		{
			CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);
			rEnemyRect.left = 649;
			rEnemyRect.right = 708;
		}
		else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f)
		{
			rEnemyRect.left = 719;
			rEnemyRect.right = 772;
		}
		else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f)
		{
			rEnemyRect.left = 787;
			rEnemyRect.right = 844;
		}
		else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f)
		{
			rEnemyRect.left = 861;
			rEnemyRect.right = 912;
		}

		if (m_fHitTimer < 0)
			pES->SendEvent("state transition 2");
	}
	if (GetHP() < op->GetDifficulty() * 100 && m_nState == PSYCROW_STATE3)
	{
		rEnemyRect.top = 674;
		rEnemyRect.bottom = 726;
		m_fHitTimer -= fElapsedTime;
		if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f)
		{
			CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);
			rEnemyRect.left = 649;
			rEnemyRect.right = 708;
		}
		else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f)
		{
			rEnemyRect.left = 719;
			rEnemyRect.right = 772;
		}
		else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f)
		{
			rEnemyRect.left = 787;
			rEnemyRect.right = 844;
		}
		else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f)
		{
			rEnemyRect.left = 861;
			rEnemyRect.right = 912;
		}

		if (m_fHitTimer < 0)
			pES->SendEvent("state transition 3");
	}
	if (GetHP() < op->GetDifficulty() * 50 && m_nState == PSYCROW_STATE4)
	{
		rEnemyRect.top = 674;
		rEnemyRect.bottom = 726;
		m_fHitTimer -= fElapsedTime;
		if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f)
		{
			CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);
			rEnemyRect.left = 649;
			rEnemyRect.right = 708;
		}
		else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f)
		{
			rEnemyRect.left = 719;
			rEnemyRect.right = 772;
		}
		else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f)
		{
			rEnemyRect.left = 787;
			rEnemyRect.right = 844;
		}
		else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f)
		{
			rEnemyRect.left = 861;
			rEnemyRect.right = 912;
		}

		if (m_fHitTimer < 0)
			pES->SendEvent("state transition 4");
	}
	if (GetHP() <= 0 && m_nState == PSYCROW_STATE5)
	{
		pMS->SendMsg(new CDestroyMessage(this));
	}

	if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX())
		SetXFlip(-1);
	else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX())
		SetXFlip(1);

	SetPosX(GetPosX() + GetVelX() * fElapsedTime);
	SetPosY(GetPosY() + GetVelY() * fElapsedTime);

	if (m_fSineFloat <= -3.14f)
		m_fSineFloat = 3.14f;

	m_fSineFloat -= fElapsedTime;

	rCollisionRect.left = GetPosX();
	rCollisionRect.right = GetPosX() + GetWidth();
	rCollisionRect.top = GetPosY();
	rCollisionRect.bottom = GetPosY() + GetHeight();
	SetCollisionRect(rCollisionRect);

	if (GetPosX() < -32)
	{
		SetVelX(-1 * GetVelX());
		SetPosX(-31);
	}
	else if (GetPosX() > 600)
	{
		SetVelX(-1 * GetVelX());
		SetPosX(599);
	}
	if (GetPosY() < 0)
	{
		SetVelY(-1 * GetVelY());
		SetPosY(1);
	}
	else if (GetPosY() > 400)
	{
		SetVelY(-abs(GetVelY()));
		SetPosY(399);
	}

	DWORD timer = GetTickCount();

}
Exemplo n.º 16
0
CEnemy::CEnemy( EleType ElementToBe, float initx, float inity, int boss, CFlock* Flock )
{
	m_nType         = OBJ_ENEMY;
	m_bIsFrozen     = false;
	m_fFrozenSpeed  = 0.5f;
	m_fFreezeTimer  = 0.0f;
	m_fChangeAnimationTimer = 0.76f;
	LastFrame = NULL;
	m_fLastPosition = inity;


	if(!boss)
	{
		switch( ElementToBe )
		{
		case OBJ_EARTH:
			{
				currState = new AIStateEarth( );
				SetHeight( 100 );
				SetWidth( 135 );
				SetPosX(initx);
				SetPosY(inity - GetHeight());
				SetVelX(25.0f);
				SetVelY(0.0f);
				( ( AIStateEarth* )currState )->SetInitPos( int( GetPosX( ) ), int( GetPosY( ) ) );
				SetHeight( 80 );
				SetWidth( 135 );
				m_nHealth      = 80 * CGameplayState::GetInstance()->GetDifficulty() + (CSpellFactory::GetInstance()->GetWindLevel() * 10);
				m_SpellType    = OBJ_EARTH;
				currDirec      = RIGHT;
				m_nAnimation = m_SpellType +1;
				m_fScale = .65f;
				SetAnimation(OBJ_EARTH +1,0);
			} break;
		case OBJ_FIRE:
			{
				currState = new AIStateFire( );
				SetPosX(initx);
				SetPosY(inity - 55);
				SetVelX(75.0f);
				SetVelY(0.0f);
				SetHeight( 54 );
				SetWidth ( 32 );
				m_nHealth      = 50 * CGameplayState::GetInstance()->GetDifficulty() + (CSpellFactory::GetInstance()->GetEarthLevel() * 7);
				m_SpellType    = OBJ_FIRE;
				currDirec      = RIGHT;
				m_fScale = 0.5f;
				m_nAnimation = m_SpellType +1;
				SetAnimation(OBJ_FIRE +1,0);

			} break;
		case OBJ_ICE:
			{
				currState = new AIStateIce( );
				SetPosX(initx);
				SetPosY(inity - 55);
				SetVelX(50.0f);
				SetVelY(0.0f);
				SetHeight( 64 );
				SetWidth ( 64 );
				SetAnimation(1,0);
				m_nHealth      = 50 * CGameplayState::GetInstance()->GetDifficulty() + (CSpellFactory::GetInstance()->GetFireLevel() * 7);
				m_SpellType    = OBJ_ICE;
				m_fScale = 0.5f;
				currDirec      = RIGHT;
				m_nAnimation = m_SpellType +1;
				SetAnimation(OBJ_ICE +1,0);
			} break;
		case OBJ_WIND:
			{
				currState = new AIStateWind();
				SetPosX(initx);
				SetPosY(inity);
				m_fScale = 0.4f;

				((AIStateWind*)currState)->SetFlock((CFlock*)Flock);
				SetVelX((float)(rand()%150));
				SetVelY((float)(rand()%150));
				if(rand()%2)
				{
					SetVelX((float)(rand()%150));
					SetVelY((float)(rand()%150));
				}
				else
				{
					SetVelX(rand()%150 * -1.0f);
					SetVelY(rand()%150 * -1.0f);
				}

				SetHeight(16);
				SetWidth(16);
				m_nHealth = 25 * CGameplayState::GetInstance()->GetDifficulty() + CSpellFactory::GetInstance()->GetIceLevel() * 5;
				m_SpellType = OBJ_WIND;
				currDirec = RIGHT;
				m_nAnimation = m_SpellType +1;
				SetAnimation(OBJ_WIND +1,0);
				currAnimation = NULL;
				break;
			} 
		}
	}


	else if(boss  == 1)
	{
		currState = new AIDocBoss(1500 + (CSpellFactory::GetInstance()->GetIceLevel() + CSpellFactory::GetInstance()->GetWindLevel() + CSpellFactory::GetInstance()->GetEarthLevel() + CSpellFactory::GetInstance()->GetFireLevel()) * 15);

		SetPosX(initx);
		SetPosY(inity);
		SetVelX(0.0f);
		SetVelY(0.0f);
		SetHeight(64);
		SetWidth(40);
		m_nAnimation = 5;
		SetImage(CSGD_TextureManager::GetInstance()->LoadTexture("resource/graphics/Doctorboss.png"));
		m_nHealth = 1500 + (CSpellFactory::GetInstance()->GetIceLevel() + CSpellFactory::GetInstance()->GetWindLevel() + CSpellFactory::GetInstance()->GetEarthLevel() + CSpellFactory::GetInstance()->GetFireLevel()) * 15;
		m_SpellType = OBJ_SHIELD;
		m_fScale = 1.0f;
		currDirec = RIGHT;
		SetAnimation(5,0);
	}
	else if(boss >= 2)
	{
		currState = new AISisBoss;

		SetPosX(initx);
		SetPosY(inity);
		SetVelX(0.0f);
		SetVelY(0.0f);
		SetHeight(60);
		m_fScale = 1.0f;
		SetWidth(50);
		m_nHealth = 1500;
		m_SpellType = OBJ_EARTH;
		currDirec = RIGHT;
		m_nAnimation = 6;
		SetAnimation(6,0);
	}

	m_fShotTimer   = 3.0f;
	m_fWaitTimer   = 0.0f;
	m_nAttackWho   = 0;
	m_fKnockBack   = 0.0f;
	m_bKnockBack   = false;
	m_bBurning     = false;
	m_nBurnDamage  = 0;
	m_fBurnTimer   = 0.0f;
}
Exemplo n.º 17
0
void CFighter::Update(float fElapsedTime)
{
	// Update common properties across all enemies
	CEnemy::Update(fElapsedTime);

	// if this enemy is cc'd don't 
	if (m_pEState->GetTimer() == true)
	{
		m_pEState->CEntityState::Update(fElapsedTime);
		return;
	}

	if (GetAnimInfo()->GetAnimationName() == GetAnimations("Idle") && m_bAttacking == true)
		m_bSecondAttackQueued = m_bAttacking = false;


	if (m_bAttacking == true)
		return;

	m_fUpdateOldPos += fElapsedTime;

	if(GetTarget() != nullptr)
	{
		float tar_pos_x = GetTarget()->GetPosX() - 32;
		float tar_pos_y = GetTarget()->GetPosY();

		if(tar_pos_x > GetPosX())
		{
			//set Grunt's animation's facing to the right
			SetFlipped( true );
		}
		else
		{
			SetFlipped( false );
		}


		if(m_fMoveAway <= 0)
		{

			//Simple Pathing twards the player
			if(tar_pos_y != GetPosY())//Above the Player
			{
				float min_Distance = (float)(GetTarget()->GetWidth()/2 + GetWidth()/2);
				if(GetPosX() + min_Distance > tar_pos_x && GetPosX() - min_Distance < tar_pos_x)
				{
					if( tar_pos_x < GetPosX())
						SetVelX(speed * fElapsedTime);
					else
						SetVelX(-speed * fElapsedTime);
				}
				else
				{
					if( tar_pos_y < GetPosY())
						SetVelY(-speed * fElapsedTime);
					else
						SetVelY(speed * fElapsedTime);
					if( tar_pos_x < GetPosX())
						SetVelX(-speed * fElapsedTime);
					else
						SetVelX(speed * fElapsedTime);
				}
				int threshold = 5;
				if(tar_pos_x - GetPosX() < threshold && tar_pos_x - GetPosX() > -1 * threshold)
					SetVelX(0);
				if(tar_pos_y - GetPosY() < threshold && tar_pos_y - GetPosY() > -1 * threshold)
					SetVelY(0);
			}
			else
			{
				SetVelY(0);
				if( tar_pos_x < GetPosX())
					SetVelX(-speed * fElapsedTime);
				else
					SetVelX(speed * fElapsedTime);
			}

		}
		else
		{
			m_fMoveAway -= fElapsedTime;
			if(m_bEvadeUp)
				SetVelY(-speed * fElapsedTime);
			else
				SetVelY(speed * fElapsedTime);
		}

		//Check Colider
		if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), GetVelX(), 0))
			SetPosX(GetPosX() + GetVelX());
		else if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), -GetVelX(), 0))
			SetPosX(GetPosX() - GetVelX());
		else
		{
			if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, GetVelY()))
				SetPosY(GetPosY() + GetVelY());
			else if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, -GetVelY()))
				SetPosY(GetPosY() - GetVelY());
			else
			{
				SetPosX(m_fStartPosX);
				SetPosY(m_fStartPosY);
			}
		}
		if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, GetVelY()))
			SetPosY(GetPosY() + GetVelY());
		else if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, -GetVelY()))
			SetPosY(GetPosY() - GetVelY());
		if(GetPosX() < 0)
			SetPosX(0);

		if(cooldown <= 0)
		{
			if((GetPosX() - tar_pos_x) < 120 && (GetPosX() - tar_pos_x) > -64 )
			{
				if(GetPosY() - tar_pos_y < 16 && GetPosY() - tar_pos_y > -16)
				{
					GetAnimInfo()->SetAnimationName(m_vAttacks[rand() % 4]);
					m_bAttacking = true;
					cooldown = 3.0f;
				}
			}
		}
		else
			cooldown -= fElapsedTime;

		//Update/use move away
		if(m_fUpdateOldPos >= 0.5f)
		{
			if(m_fPosXOld + 5 > GetPosX() && m_fPosXOld - 5 < GetPosX())
			{
				if(m_fPosYOld + 5 > GetPosY() && m_fPosYOld - 5 < GetPosY())
				{
					//if(!m_bRushing)
					{
						m_bEvadeUp = !m_bEvadeUp;
						if(m_fMoveAway <= 0)
							m_fMoveAway = 3.0f;
					}
				}
			}
			m_fPosXOld = GetPosX();
			m_fPosYOld = GetPosY();
			m_fUpdateOldPos = 0.0f;
		}
	}
}
Exemplo n.º 18
0
void CGrunt::Update(float fElapsedTime)
{
	// Update common properties across all enemies
	CEnemy::Update(fElapsedTime);

	// if this enemy is cc'd don't 
	if (m_pEState->GetTimer() == true)
	{
		m_pEState->CEntityState::Update(fElapsedTime);
		return;
	}

	m_fUpdateOldPos += fElapsedTime;
	if( cooldown <= 0.0f )
		punching = false;

	if( punching == true )
		cooldown -= fElapsedTime;

	if (GetAnimInfo()->GetAnimationName() == "Grunt_Attack_Animation")
		return;

	if(GetTarget() != nullptr)
	{
		float tar_pos_x = GetTarget()->GetPosX();
		float tar_pos_y = GetTarget()->GetPosY();
		if(tar_pos_x > GetPosX())
		{
			//set Grunt's animation's facing to the right
			m_bFlipped = true;
		}
		else
		{
			// Set Grunt's animation to face to the left
			m_bFlipped = false;
		}

		SetFlipped( m_bFlipped );


		if(m_fMoveAway <= 0)
		{
			tar_pos_x += (m_bFlipped) ? -66 : 66;

			//Simple Pathing twards the player
			if(tar_pos_y != GetPosY() )//Above the Player
			{
				float min_Distance = (float)(GetTarget()->GetWidth()/2 + GetWidth()/2);
				if(GetPosX() + min_Distance > tar_pos_x && GetPosX() - min_Distance < tar_pos_x)
				{
					if( tar_pos_x < GetPosX())

						SetVelX(speed * fElapsedTime);
					else

						SetVelX(-speed * fElapsedTime);
				}
				else
				{
					if( tar_pos_y < GetPosY())

						SetVelY(-speed * fElapsedTime);
					else

						SetVelY(speed * fElapsedTime);
					if( tar_pos_x < GetPosX())

						SetVelX(-speed * fElapsedTime);
					else

						SetVelX(speed * fElapsedTime);
				}
			}
			else
			{
				SetVelY(0);
				if( tar_pos_x < GetPosX())

					SetVelX(-speed * fElapsedTime);
				else

					SetVelX(speed * fElapsedTime);
			}

			//stop 'bouncing'
			int threshold = 5;
			if(tar_pos_x - GetPosX() < threshold && tar_pos_x - GetPosX() > -1 * threshold)
				SetVelX(0);
			if(tar_pos_y - GetPosY() < threshold && tar_pos_y - GetPosY() > -1 * threshold)
				SetVelY(0);
		}
		else//update move away
		{
			m_fMoveAway -= fElapsedTime;
			if(m_bEvadeUp)
				SetVelY(-speed * fElapsedTime);
			else
				SetVelY(speed * fElapsedTime);
		}
		//Check Colider
		if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), GetVelX(), 0))
		{
			SetPosX(GetPosX() + GetVelX());
			if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, GetVelY()))
				SetPosY(GetPosY() + GetVelY());
		}
		else
		{
			if( GetPosY() >= 600 )
				SetPosY( (GetPosY() - (GetPosY() - 599)) );
			else
				SetPosY(GetPosY() + 1);
			SetVelX(0);
			SetVelY(0);
		}
		if(GetPosX() < 0)
			SetPosX(0);
		if(punching == false && GetPosX() - tar_pos_x < 10 && GetPosX() - tar_pos_x > - 10 )
		{
			if(GetPosY() - tar_pos_y < 32 && GetPosY() - tar_pos_y > -32)
			{
				GetAnimInfo()->SetAnimationName("Grunt_Attack_Animation");
				punching = true;
				cooldown = 3.0f;
			}
		}
		//Set/use Move out of the way
		if(m_fUpdateOldPos >= 1.0f)
		{
			if(m_fPosXOld + 5 > GetPosX() && m_fPosXOld - 5 < GetPosX())
			{
				if(m_fPosYOld + 5 > GetPosY() && m_fPosYOld - 5 < GetPosY())
				{
					if(cooldown <= 0)
					{
						m_bEvadeUp = !m_bEvadeUp;
						if(m_fMoveAway <= 0)
							m_fMoveAway = 4.0f;
					}
				}
			}
			m_fPosXOld = GetPosX();
			m_fPosYOld = GetPosY();
			m_fUpdateOldPos = 0.0f;
		}
	}

	
}