void GameState_BasePlayable::OnGameFinished (bool successful) { finished = true; SoundEffect* finishSFX; finishSFX = successful ? new SoundEffect("Content/Audio/congrats.wav") : new SoundEffect("Content/Audio/caught.wav"); finishSFX->oneShot = true; Sounds->RefreshVol_Effect_Of(finishSFX); finishSFX->Play(); }
void Coin::OnIntersect (ColliderBase* other) { GameState_BasePlayable* playableState = dynamic_cast<GameState_BasePlayable*>(Game->GetGameStateMachine()->Top()); if (playableState && other->entityType == ID_PLAYER) { playableState->PickedUpGold(MyMagicNumbers::goldValue_coin, this); GameObjects->Delete(this); SoundEffect* coinJingle = new SoundEffect("Content/Audio/coin.wav"); coinJingle->oneShot = true; Sounds->RefreshVol_Effect_Of(coinJingle); coinJingle->Play(); } }
void InterfaceSounds::PlaySelect() { static SoundEffect selectSound(LocateResource("sounds/select.wav")); selectSound.Play(); }
void InterfaceSounds::PlayBleep() { static SoundEffect bleepSound(LocateResource("sounds/bleep.wav")); bleepSound.Play(); }
void GameState_BasePlayable::HandleSFEvents(std::list<sf::Event>& sfEvents) { mMenuStateMachine->RefreshStack(); if (inoutFader != 0) { if (cancelNavMapGenBtn) cancelNavMapGenBtn->HandleSFEvents(sfEvents); std::list<sf::Event>::iterator itSfEvent = sfEvents.begin(); while (itSfEvent != sfEvents.end()) { switch (itSfEvent->Type) { case sf::Event::Closed: Game->GetRenderWindow()->Close(); break; default: break; } ++itSfEvent; } return; } if (!mMenuStateMachine->IsEmpty()) mMenuStateMachine->HandleSFEvents(sfEvents); std::list<sf::Event>::iterator itSfEvent = sfEvents.begin(); while (itSfEvent != sfEvents.end()) { switch (itSfEvent->Type) { case sf::Event::Closed: Game->GetRenderWindow()->Close(); break; case sf::Event::KeyPressed: switch (itSfEvent->Key.Code) { case sf::Key::Escape: if (!finished) { if (!mMenuStateMachine->IsEmpty()) OnPause(false); else OnPause(true); } break; case sf::Key::Space: if (HUD) { GameObject* interactee = HUD->GetInteractee(); if (interactee) { if (interactee == chest && chest) { goldPickedUp += MyMagicNumbers::goldValue_chest; for (unsigned int i = 0; i != 2; ++i) { if (objectives[i] == chest) { OnObjectiveCompleted(i); objectives[i] = 0; } } PopWorldSpace(chest); delete chest; chest = 0; SoundEffect* coinJingle = new SoundEffect("Content/Audio/coin.wav"); coinJingle->oneShot = true; Sounds->RefreshVol_Effect_Of(coinJingle); coinJingle->Play(); HUD->SetAmountGold(goldPickedUp); HUD->SetInteractContextNote(0); } else if (/*interactee == princess && */princess) { princess->StartFollowing(princess->IsFollowingAnyone() ? 0 : player); HUD->SetInteractContextNote(0); // if following than it's considered completed.. if (princess->IsFollowingAnyone()) { for (unsigned int i = 0; i != 2; ++i) { // if it was the active objective if (objectives[i] == princess && objectives[i]->objectiveState == ACTIVE) { OnObjectiveCompleted(i); } } } else { // However.. for (unsigned int i = 0; i != 2; ++i) { // if the active objective is a goal if (objectives[i] && objectives[i]->objectiveState == ACTIVE && objectives[i]->entityType == ID_GOAL) { // looking backwards for (int j = i - 1; j >= 0; --j) { // j represents the last objective // if it was this princess if (objectives[j] == princess) { // then that princess should have been brought here // so we set the current goal state to inactive, and hide it objectives[i]->objectiveState = INACTIVE; PopWorldSpace(dynamic_cast<Goal*>(objectives[i])); // and reactivate the former princess objective objectives[j]->objectiveState = ACTIVE; HUD->SetObjective("Content/Textures/princess_thumbnail.png"); } } } } } } } } break; default: break; } break; default: break; } ++itSfEvent; } if (finished) { if (player) player->PauseAudio(); if (princess) princess->PauseAudio(); const EntityMap& guards = (*GameObjects)[ID_GUARD]; for (EntityMap::const_iterator itG = guards.begin(); itG != guards.end(); itG++) { dynamic_cast<Guard*>(itG->second)->PauseAudio(); } } }