コード例 #1
0
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
ファイル: Player.cpp プロジェクト: CMcLaine92/Zombie-Strike
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
ファイル: Player.cpp プロジェクト: CMcLaine92/Zombie-Strike
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
// Enter
/*virtual*/ void IntroState::Enter(void)
{
	// Set background color
	SGD::GraphicsManager::GetInstance()->SetClearColor({ 0, 0, 0 });	// black


	//starting_y = Game::GetInstance()->GetScreenHeight() + 20.0F;// * 15.0F;// + 170.0F;



	// Load assets
	SGD::GraphicsManager*	pGraphics			= SGD::GraphicsManager::GetInstance();
	SGD::AudioManager*		pAudio				= SGD::AudioManager::GetInstance();
	AnimationManager*		pAnimationManager	= AnimationManager::GetInstance();

	//pAnimationManager->Load("resource/config/animations/Zombie_Animation_New.xml", "zombie");
	//animation.m_strCurrAnimation = "zombie";

	m_hBackgroundImage = pGraphics->LoadTexture("resource/graphics/MenuImages/emergencybroadcast.png");

	m_hEmergency = pAudio->LoadAudio("resource/audio/zombieemergency.wav");

	IntroTimer.AddTime(60);
	ScreenTimer.AddTime(.1f);

	pAudio->PlayAudio(m_hEmergency, false);

	//m_hBackgroundImage	= pGraphics->LoadTexture("resource/graphics/youLose.png");

	//m_hBackgroundMusic = pAudio->LoadAudio("resource/audio/JNB_Credits_PinballGroove.xwm");
	//pAudio->PlayAudio(m_hBackgroundMusic);

}
コード例 #5
0
// Enter
/*virtual*/ void IntroState::Enter(void)
{
	// Set background color
	SGD::GraphicsManager::GetInstance()->SetClearColor({ 0, 0, 0 });	// black


	//starting_y = Game::GetInstance()->GetScreenHeight() + 20.0F;// * 15.0F;// + 170.0F;



	// Load assets
	SGD::GraphicsManager*	pGraphics			= SGD::GraphicsManager::GetInstance();
	SGD::AudioManager*		pAudio				= SGD::AudioManager::GetInstance();
	AnimationManager*		pAnimationManager	= AnimationManager::GetInstance();

	//pAnimationManager->Load("resource/config/animations/Zombie_Animation_New.xml", "zombie");
	//animation.m_strCurrAnimation = "zombie";

	pAudio->SetVoiceVolume(Game::GetInstance()->m_hMainVoice, 35);

	m_hBackgroundImage = pGraphics->LoadTexture("resource/graphics/MenuImages/emergencybroadcast.png");
	m_hinstruct = SGD::GraphicsManager::GetInstance()->LoadTexture("resource/graphics/MenuImages/ArcadeControlsIcons.png");

	m_hEmergency = pAudio->LoadAudio("resource/audio/zombieemergency.wav");

	if (IntroTimer.GetTime() < 45.0f)
	{
		float newTime = 45.0f - IntroTimer.GetTime();

		IntroTimer.AddTime(newTime);
	}

	else if (IntroTimer.GetTime() <= 0.0f)
		IntroTimer.AddTime(45.0f);

	if (ScreenTimer.GetTime() < .1f)
	{
		float newTime = .1f - ScreenTimer.GetTime();

		ScreenTimer.AddTime(newTime);
	}

	else if (ScreenTimer.GetTime() <= 0.0f)
		ScreenTimer.AddTime(.1f);

	transBack = 255;
	transTextFirst = 0;
	transText = 0;

	//IntroTimer.AddTime(45.0f - IntroTimer.GetTime());
	//ScreenTimer.AddTime(.1f - ScreenTimer.GetTime());

	pAudio->PlayAudio(m_hEmergency, false);

	//m_hBackgroundImage	= pGraphics->LoadTexture("resource/graphics/youLose.png");

	//m_hBackgroundMusic = pAudio->LoadAudio("resource/audio/JNB_Credits_PinballGroove.xwm");
	//pAudio->PlayAudio(m_hBackgroundMusic);

}
コード例 #6
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);
	

}
コード例 #7
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());
	}
}
コード例 #8
0
ファイル: Tower.cpp プロジェクト: MatthewSalow/soorry
void Tower::Update(float dt)
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();
	SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();

	if (m_bSelected)
	{
		SGD::Point pos = SGD::Point(m_ptPosition.x - 96 - Camera::x, m_ptPosition.y - 128 - Camera::y);
		SGD::Point pos2 = pos + SGD::Vector(224, 128);

		SGD::Rectangle upgradeOneRect;
		upgradeOneRect.left = pos.x + 8;
		upgradeOneRect.top = pos.y + 8;
		upgradeOneRect.right = pos.x + 108;
		upgradeOneRect.bottom = pos.y + 72;

		SGD::Rectangle upgradeTwoRect;
		upgradeTwoRect.left = pos.x + 116;
		upgradeTwoRect.top = pos.y + 8;
		upgradeTwoRect.right = pos.x + 216;
		upgradeTwoRect.bottom = pos.y + 72;

		SGD::Rectangle sellButton;
		sellButton.right = pos2.x - 8;
		sellButton.bottom = pos2.y - 8;
		sellButton.left = pos2.x - 80;
		sellButton.top = pos2.y - 32;

		if (pInput->GetMousePosition().IsWithinRectangle(upgradeOneRect))
		{
			if (!m_bHoverOne)
				pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());

			m_bHoverOne = true;
		}
		else
		{
			m_bHoverOne = false;
		}

		if (pInput->GetMousePosition().IsWithinRectangle(upgradeTwoRect))
		{
			if (!m_bHoverTwo)
				pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());

			m_bHoverTwo = true;
		}
		else
		{
			m_bHoverTwo = false;
		}

		if (pInput->GetMousePosition().IsWithinRectangle(sellButton))
		{
			if (!m_bHoverSell)
				pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());

			m_bHoverSell = true;
		}
		else
		{
			m_bHoverSell = false;
		}
	}
}