void FieldCutscene::UpdateCharacters(int delta, vector<HeightMap *> *pHeightMapList) { vector<PositionalSound> soundsToPlayList; if (GetIsFinished() || (pCurrentPhase != NULL && pCurrentPhase->GetAllowsCharacterUpdates())) { for (map<string, FieldCharacter *>::iterator iter = idToCharacterMap.begin(); iter != idToCharacterMap.end(); ++iter) { iter->second->UpdateAnimation(delta); iter->second->SetExtraHeightFromHeightMaps(pHeightMapList); AnimationSound *pSoundToPlay = iter->second->GetSoundToPlay(); if (pSoundToPlay != NULL) { soundsToPlayList.push_back(PositionalSound(pSoundToPlay, iter->second->GetMidPoint())); } } } for (unsigned int i = 0; i < soundsToPlayList.size(); i++) { AnimationSound *pSoundToPlay = soundsToPlayList[i].pSound; Vector2 soundOriginPosition = soundsToPlayList[i].location; double distanceToOrigin = (soundOriginPosition - currentCameraPosition).Length(); double zeroDistance = max(gScreenWidth, gScreenHeight);//sqrt(gScreenWidth * gScreenWidth + gScreenHeight * gScreenHeight); double volume = max(0.0, 1.0 - distanceToOrigin / zeroDistance); pSoundToPlay->Play(volume); } }
void Video::Frame::Update(int delta) { AnimationSound *pSoundToPlay = GetSoundToPlay(); if (pSoundToPlay != NULL) { pSoundToPlay->Play(gSoundEffectsVolume); } elapsedDuration += delta; }
void Button::Update(int delta) { isMouseOver = false; isMouseDown = false; if (pOutEase->GetIsStarted() && !pOutEase->GetIsFinished()) { pOutEase->Update(delta); animationOffset = (int)pOutEase->GetCurrentValue(); } else if (pOutEase->GetIsFinished()) { SetIsHidden(true); } else if (pInEase->GetIsStarted() && !pInEase->GetIsFinished()) { pInEase->Update(delta); animationOffset = (int)pInEase->GetCurrentValue(); } else { if (GetUnlockedLockCount() > 0 && !pUnlockingAnimation->IsFinished()) { pUnlockingAnimation->Update(delta); AnimationSound * pSoundToPlay = pUnlockingAnimation->GetSoundToPlay(); if (pSoundToPlay != NULL) { pSoundToPlay->Play(gSoundEffectsVolume); } } else if (!GetIsDisabled()) { RectangleWH positionRect = RectangleWH(GetXPosition(), GetYPosition(), pTextFont->GetWidth(GetText()), TextHeight); bool isPressed = MouseHelper::PressedAndHeldAnywhere() || MouseHelper::DoublePressedAndHeldAnywhere(); if (MouseHelper::ClickedOnRect(positionRect)) { OnClicked(); } if (MouseHelper::MouseDownOnRect(positionRect) && !isPressed) { isMouseDown = true; } else if (MouseHelper::MouseOverRect(positionRect) && !isPressed) { isMouseOver = true; } } } }