void AssaultRifle::Fire(float dt)
{
	SGD::AudioManager*	pAudio		= SGD::AudioManager::GetInstance();
	Game*		pGame	= Game::GetInstance();

	if (currAmmo > 0 && reloadTimer.GetTime() == 0)
	{
		//create bullet message
		if (recoilTimer.GetTime() == 0 && pAudio->IsAudioPlaying(pGame->reload_finish) == false)
		{
			CreatePistolBullet* pMsg = new CreatePistolBullet(this);
			pMsg->QueueMessage();
			pMsg = nullptr;

			//if (pAudio->IsAudioPlaying(*fire_sound) == false)
			voice = pAudio->PlayAudio(*fire_sound, false);

			recoilTimer.AddTime(recoilTime);
			currAmmo--;
			if (currAmmo == 0)
			{
				reloadTimer.AddTime(reloadTime);
				reloading = true;
			}
		}
	}
	else
	{
		if (pAudio->IsAudioPlaying(pGame->out_of_ammo) == false && pAudio->IsAudioPlaying(*fire_sound) == false
			&& pAudio->IsAudioPlaying(pGame->reload_begin) == false
			&& pAudio->IsAudioPlaying(pGame->reload_finish) == false)
			pAudio->PlayAudio(pGame->out_of_ammo, false);
	}
}
예제 #2
0
void Player::SpawnTurret(void)
{
    SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
    Game* pGame = Game::GetInstance();


    if (profile.numTurrets == 0 || GoodTurretPosition() == false)
    {
        if (pAudio->IsAudioPlaying(pGame->turret_bad) == false)
            pAudio->PlayAudio(pGame->turret_bad, false);
        return;
    }


    if (pAudio->IsAudioPlaying(pGame->turret_good) == false)
        pAudio->PlayAudio(pGame->turret_good, false);


    // create turret message
    CreateTurretMessage* pMsg = new CreateTurretMessage(this);
    pMsg->QueueMessage();
    pMsg = nullptr;

    profile.numTurrets--;
}
예제 #3
0
void Player::CheckDamage(void)
{
    SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
    Game* pGame = Game::GetInstance();


    // dead, !hurt
    if (profile.health <= 0.0f)
    {
        profile.health = 0.0f;

        if (m_hHurt != nullptr && pAudio->IsAudioPlaying(*m_hHurt) == true)
            pAudio->StopAudio(*m_hHurt);

        if (pAudio->IsAudioPlaying(*m_hDeath) == false)
            voice = pAudio->PlayAudio(*m_hDeath, false);
        pAudio->SetVoiceVolume(voice);

        m_bIsAlive = false;

        SetVelocity({ 0, 0 });
    }

    // hurt, !dead
    else
    {
        int sound = rand() % 3;

        switch (sound)
        {
        case 0:
            m_hHurt = &pGame->playerHurt1;
            break;
        case 1:
            m_hHurt = &pGame->playerHurt2;
            break;
        case 2:
            m_hHurt = &pGame->playerHurt3;
            break;
        default:
            break;
        }

        if (pAudio->IsAudioPlaying(pGame->playerHurt1) == false &&
                pAudio->IsAudioPlaying(pGame->playerHurt2) == false &&
                pAudio->IsAudioPlaying(pGame->playerHurt3) == false)
            voice = pAudio->PlayAudio(*m_hHurt, false);
        pAudio->SetVoiceVolume(voice);

        m_hHurt = nullptr;
    }
}
예제 #4
0
/*virtual*/ void Zombie::HandleCollision(const IBase* pOther)
{
	SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();

	if (pOther->GetType() == OBJ_BULLET)
	{
		const Bullet* bullet = dynamic_cast<const Bullet*>(pOther);

		health -= bullet->GetDamage();
		if (health <= 0.0f)
		{
			pAudio->PlayAudio(Game::GetInstance()->zombie_death, false);

			this->SetAnimation(this->animation.m_strCurrAnimation + "Death");
			this->RetrieveBehavior("wait");
			//isAlive = false;
		}
		else
		{
			if (pAudio->IsAudioPlaying(Game::GetInstance()->zombie_pain) == false)
				pAudio->PlayAudio(Game::GetInstance()->zombie_pain, false);
		}

		CreateBloodMsg* msg = new CreateBloodMsg(m_ptPosition);
		msg->QueueMessage();
		msg = nullptr;

		
	}
	if (pOther->GetType() == OBJ_EXPLODING_ZOMBIE)
	{
		const BaseObject* ptr = dynamic_cast<const BaseObject*>(pOther);

		if (ptr->GetAnimation() == "bloodExplosion")
		{
			pAudio->PlayAudio(Game::GetInstance()->zombie_death, false);

			this->SetAnimation(this->animation.m_strCurrAnimation + "Death");
			this->RetrieveBehavior("wait");
			//isAlive = false;
		}
	}
	if (pOther->GetType() == OBJ_BARBEDWIRE_V || pOther->GetType() == OBJ_BARBEDWIRE_H)
	{
		const BarbedWire* barbWire = dynamic_cast<const BarbedWire*>(pOther);
		if (barbWire->IsActive())
		{
			health -= barbWire->GetDamage() * Game::GetInstance()->DeltaTime();
			if (health <= 0)
			{
				pAudio->PlayAudio(Game::GetInstance()->zombie_death, false);

				this->SetAnimation(this->animation.m_strCurrAnimation + "Death");
				this->RetrieveBehavior("wait");
				//isAlive = false;
			}
			MovingObject::HandleCollision(pOther);
		}
	}
	if (pOther->GetType() == OBJ_SANDBAG || pOther->GetType() == OBJ_SANDBAG_L || pOther->GetType() == OBJ_SANDBAG_R)
	{
		const SandBag* sandbag = dynamic_cast<const SandBag*>(pOther);
		if (sandbag->IsActive())
			MovingObject::HandleCollision(pOther);
	}

	if (pOther->GetType() == OBJ_LANDMINE)
	{
		const LandMine* landMine = dynamic_cast<const LandMine*>(pOther);
		if (landMine->IsActive())
		{
			pAudio->PlayAudio(Game::GetInstance()->zombie_death, false);

			this->SetAnimation(this->animation.m_strCurrAnimation + "Death");
			this->RetrieveBehavior("wait");
			//isAlive = false;
		}
	}

	else if (pOther->GetType() == OBJ_WALL)
	{
		const House* house = dynamic_cast<const House*>(pOther);

		if (house->IsActive() == true)
			MovingObject::HandleCollision(pOther);
	}
	else if (pOther->GetType() == OBJ_BASE)
			MovingObject::HandleCollision(pOther);
	

}
예제 #5
0
void WeaponManager::Input()
{
	SGD::InputManager * pInput = SGD::InputManager::GetInstance();
	SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance();

	if (pInput->IsKeyPressed(SGD::Key::Q) == true || pInput->IsButtonPressed(0, 4) == true || mousewheel < 0)
	{
		curIndex--;

		if (curIndex < 0)
		{
			curIndex = m_vWeapons.size() - 1;
		}


		if (pAudio->IsAudioPlaying(m_hWpnSwitch) == false)
		{
			pAudio->PlayAudio(m_hWpnSwitch, false);
		}

		while (m_vWeapons[curIndex]->GetEquipped() != true)
		{
			curIndex--;

			if (curIndex < 0)
			{
				curIndex = m_vWeapons.size() - 1;
			}
		}

		mousewheel = 0;
	}

	if (pInput->IsKeyPressed(SGD::Key::E) == true || pInput->IsButtonPressed(0, 5) == true || mousewheel > 0)
	{
		curIndex++;


		if (curIndex > (int)m_vWeapons.size() - 1)
		{
			curIndex = 0;
		}

		if (pAudio->IsAudioPlaying(m_hWpnSwitch) == false)
		{
			pAudio->PlayAudio(m_hWpnSwitch, false);
		}

		while (m_vWeapons[curIndex]->GetEquipped() != true)
		{
			curIndex++;

			if (curIndex > (int)m_vWeapons.size() - 1)
			{
				curIndex = 0;
			}
		}

		mousewheel = 0;
	}

	if (pInput->IsKeyPressed(SGD::Key::R) == true && m_vWeapons[curIndex]->GetCurrAmmo() < m_vWeapons[curIndex]->GetMagSize())
	{
		//GetSelected()->SetCurrAmmo(0);
		GetSelected()->GetReloadTimer().AddTime(GetSelected()->GetReloadTime());
		//m_vWeapons[curIndex]->SetCurrAmmo(0);
		//m_vWeapons[curIndex]->GetReloadTimer().AddTime(m_vWeapons[curIndex]->GetReloadTime());
	}
}