1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Add multiplayer lobby countdown SFX

This commit is contained in:
Jamie Taylor 2022-04-01 21:33:57 +09:00
parent 9d93cffbb2
commit 0f4b75ab15
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C

View File

@ -5,6 +5,8 @@ using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Localisation;
using osu.Framework.Threading;
using osu.Game.Graphics;
@ -27,6 +29,17 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
[CanBeNull]
private MultiplayerRoom room => multiplayerClient.Room;
private Sample countdownTickSample;
private Sample countdownTickFinalSample;
private int? lastTickPlayed;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
countdownTickSample = audio.Samples.Get(@"Multiplayer/countdown-tick");
countdownTickFinalSample = audio.Samples.Get(@"Multiplayer/countdown-tick-final");
}
protected override void LoadComplete()
{
base.LoadComplete();
@ -83,6 +96,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
else
countdownRemaining = countdown.TimeRemaining - timeElapsed;
if (countdownRemaining.Seconds <= 10 && (lastTickPlayed == null || lastTickPlayed != countdownRemaining.Seconds))
{
countdownTickSample?.Play();
if (countdownRemaining.Seconds <= 3)
countdownTickFinalSample?.Play();
lastTickPlayed = countdownRemaining.Seconds;
}
string countdownText = $"Starting in {countdownRemaining:mm\\:ss}";
switch (localUser?.State)