public void Fanfare(string newSE) { if (DataManager.Instance.Loading != DataManager.LoadMode.None) { return; } if (Song == "" || NextSong == "") { SE(newSE); return; } if (String.IsNullOrEmpty(QueuedFanfare)) //assume no fanfares happen within the same period { if (CurrentFanfarePhase == FanfarePhase.None) //begin the brief fade out if playing music as normal { CurrentFanfarePhase = FanfarePhase.PhaseOut; FanfareTime = FrameTick.FromFrames(FANFARE_FADE_START); QueuedFanfare = newSE; } else if (CurrentFanfarePhase == FanfarePhase.PhaseIn)//fade from the partial progress { CurrentFanfarePhase = FanfarePhase.PhaseOut; FanfareTime = FrameTick.FromFrames((FANFARE_FADE_END - FanfareTime.DivOf(FANFARE_FADE_END)) * FANFARE_FADE_START / FANFARE_FADE_END); QueuedFanfare = newSE; } } }
public void Update(FrameTick elapsedTime) { GraphicsManager.TotalFrameTick += (ulong)elapsedTime.Ticks; //update music float musicFadeFraction = 1; if (NextSong != null) { MusicFadeTime -= elapsedTime; if (MusicFadeTime <= FrameTick.Zero) { if (System.IO.File.Exists(DataManager.MUSIC_PATH + NextSong)) { Song = NextSong; NextSong = null; SoundManager.PlayBGM(DataManager.MUSIC_PATH + Song); } else { Song = ""; SoundManager.PlayBGM(Song); } } else { musicFadeFraction *= MusicFadeTime.FractionOf(MUSIC_FADE_TOTAL); } } if (CurrentFanfarePhase != FanfarePhase.None) { FanfareTime -= elapsedTime; if (CurrentFanfarePhase == FanfarePhase.PhaseOut) { musicFadeFraction *= FanfareTime.FractionOf(FANFARE_FADE_START); if (FanfareTime <= FrameTick.Zero) { int pauseFrames = 0; if (!String.IsNullOrEmpty(QueuedFanfare) && System.IO.File.Exists(DataManager.SOUND_PATH + QueuedFanfare + ".ogg")) { pauseFrames = SoundManager.PlaySound(DataManager.SOUND_PATH + QueuedFanfare + ".ogg", 1) + FANFARE_WAIT_EXTRA; } CurrentFanfarePhase = FanfarePhase.Wait; if (FanfareTime < pauseFrames) { FanfareTime = FrameTick.FromFrames(pauseFrames); } QueuedFanfare = null; } } else if (CurrentFanfarePhase == FanfarePhase.Wait) { musicFadeFraction *= 0; if (FanfareTime <= FrameTick.Zero) { CurrentFanfarePhase = FanfarePhase.PhaseIn; FanfareTime = FrameTick.FromFrames(FANFARE_FADE_END); } } else if (CurrentFanfarePhase == FanfarePhase.PhaseIn) { musicFadeFraction *= (1f - FanfareTime.FractionOf(FANFARE_FADE_END)); if (FanfareTime <= FrameTick.Zero) { CurrentFanfarePhase = FanfarePhase.None; } } } SoundManager.SetBGMVolume(musicFadeFraction); if (timeSinceError > 0) { timeSinceError--; } MenuManager.Instance.ProcessActions(elapsedTime); //keep border flash off by default MenuBase.BorderFlash = 0; CurrentScene.Update(elapsedTime); }