// 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); }
// 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); }
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--; }
void TowerFlyweight::Unload() { // Unload sounds SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance(); pAudio->UnloadAudio(m_hSellSound); pAudio->UnloadAudio(m_hInvalidSound); pAudio->UnloadAudio(m_hMachineGunShotSound); pAudio->UnloadAudio(m_hMapleSyrupShotSound); pAudio->UnloadAudio(m_hHockeyStickSlashSound); }
void FlameThrower::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) { CreateFlameBullet* pMsg = new CreateFlameBullet(this); pMsg->QueueMessage(); pMsg = nullptr; if (pAudio->IsAudioPlaying(*fire_sound) == false) 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); } }
// Exit /*virtual*/ void IntroState::Exit(void) { SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance(); SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance(); // Unload assets pGraphics->UnloadTexture(m_hBackgroundImage); //pAudio->UnloadAudio(m_hBackgroundMusic); pAudio->UnloadAudio(m_hEmergency); }
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; } }
// Exit /*virtual*/ void IntroState::Exit(void) { SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance(); SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance(); // Unload assets pGraphics->UnloadTexture(m_hBackgroundImage); pGraphics->UnloadTexture(m_hinstruct); //pAudio->UnloadAudio(m_hBackgroundMusic); pAudio->UnloadAudio(m_hEmergency); pAudio->SetVoiceVolume(Game::GetInstance()->m_hMainVoice, 100); }
// Input /*virtual*/ bool IntroState::Input(void) { SGD::InputManager* pInput = SGD::InputManager::GetInstance(); SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance(); // Press Escape to quit if (pInput->IsKeyPressed(SGD::Key::Escape) == true || pInput->IsButtonPressed(0, 9) == true || pInput->IsButtonPressed(0, 2) == true) { //COMMENT IN WHEN AUDIO ADDED pAudio->StopAudio(m_hEmergency); Game::GetInstance()->RemoveState(); Game::GetInstance()->AddState(GameplayState::GetInstance()); return true; } // keep playing return true; }
void TowerFlyweight::Load(string fileName) { // Create a TinyXML document TiXmlDocument doc; // Attempt to load from the file doc.LoadFile(fileName.c_str()); // Access the 'root' TinyXML Element TiXmlElement* pRoot = doc.RootElement(); // Double for temp storage double temp; #pragma region Machine Gun Tower // Machine Gun Tower TiXmlElement* machineGun = pRoot->FirstChildElement("machine_gun"); // Starting Values machineGun->FirstChildElement("damage")->Attribute("value", &m_nMachineGunDamage[0]); machineGun->FirstChildElement("fire_rate")->Attribute("value", &temp); m_fMachineGunFireRate[0] = (float)temp; machineGun->FirstChildElement("range")->Attribute("value", &m_nMachineGunRange[0]); // Power Upgrade Values TiXmlElement* machineGunPower = machineGun->FirstChildElement("power_upgrade"); // Tier 1 TiXmlElement* machineGunPowerOne = machineGunPower->FirstChildElement("tier_one"); machineGunPowerOne->FirstChildElement("cost")->Attribute("value", &m_nMachineGunPowerUpgradeCost[0]); machineGunPowerOne->FirstChildElement("damage")->Attribute("value", &m_nMachineGunDamage[1]); machineGunPowerOne->FirstChildElement("fire_rate")->Attribute("value", &temp); m_fMachineGunFireRate[1] = (float)temp; // Tier 2 TiXmlElement* machineGunPowerTwo = machineGunPower->FirstChildElement("tier_two"); machineGunPowerTwo->FirstChildElement("cost")->Attribute("value", &m_nMachineGunPowerUpgradeCost[1]); machineGunPowerTwo->FirstChildElement("damage")->Attribute("value", &m_nMachineGunDamage[2]); machineGunPowerTwo->FirstChildElement("fire_rate")->Attribute("value", &temp); m_fMachineGunFireRate[2] = (float)temp; // Tier 3 TiXmlElement* machineGunPowerThree = machineGunPower->FirstChildElement("tier_three"); machineGunPowerThree->FirstChildElement("cost")->Attribute("value", &m_nMachineGunPowerUpgradeCost[2]); machineGunPowerThree->FirstChildElement("damage")->Attribute("value", &m_nMachineGunDamage[3]); machineGunPowerThree->FirstChildElement("fire_rate")->Attribute("value", &temp); m_fMachineGunFireRate[3] = (float)temp; // Range Upgrade Values TiXmlElement* machineGunRange = machineGun->FirstChildElement("range_upgrade"); // Tier 1 TiXmlElement* machineGunRangeOne = machineGunRange->FirstChildElement("tier_one"); machineGunRangeOne->FirstChildElement("cost")->Attribute("value", &m_nMachineGunRangeUpgradeCost[0]); machineGunRangeOne->FirstChildElement("range")->Attribute("value", &m_nMachineGunRange[1]); // Tier 2 TiXmlElement* machineGunRangeTwo = machineGunRange->FirstChildElement("tier_two"); machineGunRangeTwo->FirstChildElement("cost")->Attribute("value", &m_nMachineGunRangeUpgradeCost[1]); machineGunRangeTwo->FirstChildElement("range")->Attribute("value", &m_nMachineGunRange[2]); // Tier 3 TiXmlElement* machineGunRangeThree = machineGunRange->FirstChildElement("tier_three"); machineGunRangeThree->FirstChildElement("cost")->Attribute("value", &m_nMachineGunRangeUpgradeCost[2]); machineGunRangeThree->FirstChildElement("range")->Attribute("value", &m_nMachineGunRange[3]); #pragma endregion #pragma region Maple Syrup Tower // Maple Syrup Tower TiXmlElement* mapleSyrup = pRoot->FirstChildElement("maple_syrup"); // Starting Values mapleSyrup->FirstChildElement("effect_duration")->Attribute("value", &temp); m_fMapleSyrupEffectDuration[0] = (float)temp; mapleSyrup->FirstChildElement("fire_rate")->Attribute("value", &temp); m_fMapleSyrupFireRate[0] = (float)temp; mapleSyrup->FirstChildElement("range")->Attribute("value", &m_nMapleSyrupRange[0]); // Power Upgrade Values TiXmlElement* mapleSyrupPower = mapleSyrup->FirstChildElement("power_upgrade"); // Tier 1 TiXmlElement* mapleSyrupPowerOne = mapleSyrupPower->FirstChildElement("tier_one"); mapleSyrupPowerOne->FirstChildElement("cost")->Attribute("value", &m_nMapleSyrupPowerUpgradeCost[0]); mapleSyrupPowerOne->FirstChildElement("effect_duration")->Attribute("value", &temp); m_fMapleSyrupEffectDuration[1] = (float)temp; mapleSyrupPowerOne->FirstChildElement("fire_rate")->Attribute("value", &temp); m_fMapleSyrupFireRate[1] = (float)temp; // Tier 2 TiXmlElement* mapleSyrupPowerTwo = mapleSyrupPower->FirstChildElement("tier_two"); mapleSyrupPowerTwo->FirstChildElement("cost")->Attribute("value", &m_nMapleSyrupPowerUpgradeCost[1]); mapleSyrupPowerTwo->FirstChildElement("effect_duration")->Attribute("value", &temp); m_fMapleSyrupEffectDuration[2] = (float)temp; mapleSyrupPowerTwo->FirstChildElement("fire_rate")->Attribute("value", &temp); m_fMapleSyrupFireRate[2] = (float)temp; // Tier 3 TiXmlElement* mapleSyrupPowerThree = mapleSyrupPower->FirstChildElement("tier_three"); mapleSyrupPowerThree->FirstChildElement("cost")->Attribute("value", &m_nMapleSyrupPowerUpgradeCost[2]); mapleSyrupPowerThree->FirstChildElement("effect_duration")->Attribute("value", &temp); m_fMapleSyrupEffectDuration[3] = (float)temp; mapleSyrupPowerThree->FirstChildElement("fire_rate")->Attribute("value", &temp); m_fMapleSyrupFireRate[3] = (float)temp; // Range Upgrade Values TiXmlElement* mapleSyrupRange = mapleSyrup->FirstChildElement("range_upgrade"); // Tier 1 TiXmlElement* mapleSyrupRangeOne = mapleSyrupRange->FirstChildElement("tier_one"); mapleSyrupRangeOne->FirstChildElement("cost")->Attribute("value", &m_nMapleSyrupRangeUpgradeCost[0]); mapleSyrupRangeOne->FirstChildElement("range")->Attribute("value", &m_nMapleSyrupRange[1]); // Tier 2 TiXmlElement* mapleSyrupRangeTwo = mapleSyrupRange->FirstChildElement("tier_two"); mapleSyrupRangeTwo->FirstChildElement("cost")->Attribute("value", &m_nMapleSyrupRangeUpgradeCost[1]); mapleSyrupRangeTwo->FirstChildElement("range")->Attribute("value", &m_nMapleSyrupRange[2]); // Tier 3 TiXmlElement* mapleSyrupRangeThree = mapleSyrupRange->FirstChildElement("tier_three"); mapleSyrupRangeThree->FirstChildElement("cost")->Attribute("value", &m_nMapleSyrupRangeUpgradeCost[2]); mapleSyrupRangeThree->FirstChildElement("range")->Attribute("value", &m_nMapleSyrupRange[3]); #pragma endregion #pragma region Hockey Stick Tower // Hockey Stick Tower TiXmlElement* hockeyStick = pRoot->FirstChildElement("hockey_stick"); // Starting Values hockeyStick->FirstChildElement("damage")->Attribute("value", &temp); m_fHockeyStickDamage[0] = (float)temp; hockeyStick->FirstChildElement("spin_rate")->Attribute("value", &temp); m_fHockeyStickSpinRate[0] = (float)temp; // Damage Upgrade Values TiXmlElement* hockeyStickDamage = hockeyStick->FirstChildElement("damage_upgrade"); // Tier 1 TiXmlElement* hockeyStickDamageOne = hockeyStickDamage->FirstChildElement("tier_one"); hockeyStickDamageOne->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickDamageUpgradeCost[0]); hockeyStickDamageOne->FirstChildElement("damage")->Attribute("value", &temp); m_fHockeyStickDamage[1] = (float)temp; // Tier 2 TiXmlElement* hockeyStickDamageTwo = hockeyStickDamage->FirstChildElement("tier_two"); hockeyStickDamageTwo->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickDamageUpgradeCost[1]); hockeyStickDamageTwo->FirstChildElement("damage")->Attribute("value", &temp); m_fHockeyStickDamage[2] = (float)temp; // Tier 3 TiXmlElement* hockeyStickDamageThree = hockeyStickDamage->FirstChildElement("tier_three"); hockeyStickDamageThree->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickDamageUpgradeCost[2]); hockeyStickDamageThree->FirstChildElement("damage")->Attribute("value", &temp); m_fHockeyStickDamage[3] = (float)temp; // Spin Rate Upgrade Values TiXmlElement* hockeyStickSpinRate = hockeyStick->FirstChildElement("spin_rate_upgrade"); // Tier 1 TiXmlElement* hockeyStickSpinRateOne = hockeyStickSpinRate->FirstChildElement("tier_one"); hockeyStickSpinRateOne->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickSpinRateUpgradeCost[0]); hockeyStickSpinRateOne->FirstChildElement("spin_rate")->Attribute("value", &temp); m_fHockeyStickSpinRate[1] = (float)temp; // Tier 2 TiXmlElement* hockeyStickSpinRateTwo = hockeyStickSpinRate->FirstChildElement("tier_two"); hockeyStickSpinRateTwo->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickSpinRateUpgradeCost[1]); hockeyStickSpinRateTwo->FirstChildElement("spin_rate")->Attribute("value", &temp); m_fHockeyStickSpinRate[2] = (float)temp; // Tier 3 TiXmlElement* hockeyStickSpinRateThree = hockeyStickSpinRate->FirstChildElement("tier_three"); hockeyStickSpinRateThree->FirstChildElement("cost")->Attribute("value", &m_nHockeyStickSpinRateUpgradeCost[2]); hockeyStickSpinRateThree->FirstChildElement("spin_rate")->Attribute("value", &temp); m_fHockeyStickSpinRate[3] = (float)temp; #pragma endregion #pragma region Laser Tower // Laser Tower TiXmlElement* laser = pRoot->FirstChildElement("laser"); // Starting Values laser->FirstChildElement("damage")->Attribute("value", &m_nLaserDamage[0]); laser->FirstChildElement("range")->Attribute("value", &m_nLaserRange[0]); // Damage Upgrade Values TiXmlElement* laserDamage = laser->FirstChildElement("damage_upgrade"); // Tier 1 TiXmlElement* laserDamageOne = laserDamage->FirstChildElement("tier_one"); laserDamageOne->FirstChildElement("cost")->Attribute("value", &m_nLaserDamageUpgradeCost[0]); laserDamageOne->FirstChildElement("damage")->Attribute("value", &m_nLaserDamage[1]); // Tier 2 TiXmlElement* laserDamageTwo = laserDamage->FirstChildElement("tier_two"); laserDamageTwo->FirstChildElement("cost")->Attribute("value", &m_nLaserDamageUpgradeCost[1]); laserDamageTwo->FirstChildElement("damage")->Attribute("value", &m_nLaserDamage[2]); // Tier 3 TiXmlElement* laserDamageThree = laserDamage->FirstChildElement("tier_three"); laserDamageThree->FirstChildElement("cost")->Attribute("value", &m_nLaserDamageUpgradeCost[2]); laserDamageThree->FirstChildElement("damage")->Attribute("value", &m_nLaserDamage[3]); // Range Upgrade Values TiXmlElement* laserRange = laser->FirstChildElement("range_upgrade"); // Tier 1 TiXmlElement* laserRangeOne = laserRange->FirstChildElement("tier_one"); laserRangeOne->FirstChildElement("cost")->Attribute("value", &m_nLaserRangeUpgradeCost[0]); laserRangeOne->FirstChildElement("range")->Attribute("value", &m_nLaserRange[1]); // Tier 2 TiXmlElement* laserRangeTwo = laserRange->FirstChildElement("tier_two"); laserRangeTwo->FirstChildElement("cost")->Attribute("value", &m_nLaserRangeUpgradeCost[1]); laserRangeTwo->FirstChildElement("range")->Attribute("value", &m_nLaserRange[2]); // Tier 3 TiXmlElement* laserRangeThree = laserRange->FirstChildElement("tier_three"); laserRangeThree->FirstChildElement("cost")->Attribute("value", &m_nLaserRangeUpgradeCost[2]); laserRangeThree->FirstChildElement("range")->Attribute("value", &m_nLaserRange[3]); #pragma endregion // Load Sounds SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance(); m_hSellSound = pAudio->LoadAudio("resource/audio/doorClose.wav"); m_hInvalidSound = pAudio->LoadAudio("resource/audio/invalidPurchase.wav"); m_hMachineGunShotSound = pAudio->LoadAudio("resource/audio/machineGunShot.wav"); m_hMapleSyrupShotSound = pAudio->LoadAudio("resource/audio/mapleSyrupShot.wav"); m_hHockeyStickSlashSound = pAudio->LoadAudio("resource/audio/hockeyStickSlash.wav"); }
/*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); }
// Update /*virtual*/ void IntroState::Update(float elapsedTime) { SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance(); if (IntroTimer.GetTime() < 0.0f) { pAudio->StopAudio(m_hEmergency); Game::GetInstance()->RemoveState(); Game::GetInstance()->AddState(GameplayState::GetInstance()); } if (IntroTimer.GetTime() < 25.0f) { if (ScreenTimer.GetTime() <= 0.0f && IntroTimer.GetTime() > 12.0f) { transBack -= 5; transTextFirst += 5; ScreenTimer.AddTime(.1f); } else if (IntroTimer.GetTime() < 12.0f) { if (ScreenTimer.GetTime() < 0.0f) { transText += 5; transTextFirst -= 5; ScreenTimer.AddTime(.1f); } //ScreenTimer.Update(elapsedTime); } ScreenTimer.Update(elapsedTime); } if (transBack <= 0) { transBack = 0; } if (transText >= 255) { transText = 255; } if (transTextFirst >= 255) { transTextFirst = 255; } if (transTextFirst < 0) { transTextFirst = 0; } IntroTimer.Update(elapsedTime); /* AnimationManager::GetInstance()->Update(animation, elapsedTime); if (starting_y == 120.0f) { Game::GetInstance()->RemoveState(); Game::GetInstance()->AddState(GameplayState::GetInstance()); } starting_y -= SCROLL_SPEED * elapsedTime; if (starting_y < 120.0f) starting_y = 120.0f; */ }
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()); } }
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; } } }