diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs index bc96fd5877..4f22857579 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/PickScreen.cs @@ -24,7 +24,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay public partial class PickScreen : RankedPlaySubScreen { // When the 'time running out' warning sample starts to play (in remaining seconds) - private const int warning_time_threshold = 10; + private const int warning_time_threshold = 11; public CardFlow CenterRow { get; private set; } = null!; @@ -46,6 +46,12 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay private Sample? timeRunningOutSample; private SampleChannel? timeRunningOutSampleChannel; + private Sample? finalCountdownSample; + private double? lastFinalCountdownSamplePlayback; + + private Sample? timeUpSample; + private bool finalBuzzerPlayed; + private DateTimeOffset stageEndTime; private TimeSpan stageDuration; @@ -106,6 +112,8 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay cardPlaySamples[i] = audio.Samples.Get($@"Multiplayer/Matchmaking/Ranked/card-play-{1 + i}"); timeRunningOutSample = audio.Samples.Get(@"Multiplayer/Matchmaking/Ranked/time-running-out"); + finalCountdownSample = audio.Samples.Get(@"Multiplayer/Matchmaking/Ranked/time-running-out-final"); + timeUpSample = audio.Samples.Get(@"Multiplayer/Matchmaking/Ranked/time-up"); } protected override void LoadComplete() @@ -124,16 +132,42 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay } } - private bool shouldPlayWarningSample + private bool warningSamplesEnabled => matchInfo.Stage.Value == RankedPlayStage.CardPlay && stageDuration > TimeSpan.FromSeconds(warning_time_threshold) - && stageEndTime - DateTimeOffset.Now < TimeSpan.FromSeconds(warning_time_threshold) && !hasPlayedCard; + private bool shouldPlayWarningSample + => warningSamplesEnabled + && stageEndTime - DateTimeOffset.Now > TimeSpan.FromSeconds(0) + && stageEndTime - DateTimeOffset.Now <= TimeSpan.FromSeconds(warning_time_threshold); + + private bool shouldPlayFinalWarningSamples + => warningSamplesEnabled + && stageEndTime - DateTimeOffset.Now > TimeSpan.FromSeconds(0) + && stageEndTime - DateTimeOffset.Now < TimeSpan.FromSeconds(4); + + private bool shouldPlayFinalBuzzer + => warningSamplesEnabled + && !finalBuzzerPlayed + && stageEndTime - DateTimeOffset.Now <= TimeSpan.FromSeconds(0); + protected override void Update() { base.Update(); + if (shouldPlayFinalWarningSamples && (lastFinalCountdownSamplePlayback == null || Time.Current - lastFinalCountdownSamplePlayback > 1000)) + { + finalCountdownSample?.Play(); + lastFinalCountdownSamplePlayback = Time.Current; + } + + if (shouldPlayFinalBuzzer) + { + timeUpSample?.Play(); + finalBuzzerPlayed = true; + } + if (shouldPlayWarningSample) { timeRunningOutSampleChannel ??= timeRunningOutSample?.GetChannel(); @@ -207,6 +241,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay stageEndTime = DateTimeOffset.Now + countdown.TimeRemaining; stageDuration = countdown.TimeRemaining; + finalBuzzerPlayed = false; }); private void onCountdownStopped(MultiplayerCountdown countdown) => Scheduler.Add(() => diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 44fed4026c..6b8a3352ff 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -40,7 +40,7 @@ - +