mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Merge pull request #25343 from peppy/spinner-max-sample
Continue to play spinner bonus sounds when MAX display occurs
This commit is contained in:
commit
5180fa669b
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -36,6 +37,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddSliderStep("Spin rate", 0.5, 5, 1, val => spinRate.Value = val);
|
AddSliderStep("Spin rate", 0.5, 5, 1, val => spinRate.Value = val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("Reset rate", () => spinRate.Value = 1);
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase(true)]
|
[TestCase(true)]
|
||||||
[TestCase(false)]
|
[TestCase(false)]
|
||||||
public void TestVariousSpinners(bool autoplay)
|
public void TestVariousSpinners(bool autoplay)
|
||||||
@ -46,6 +53,36 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddStep($"{term} Small", () => SetContents(_ => testSingle(7, autoplay)));
|
AddStep($"{term} Small", () => SetContents(_ => testSingle(7, autoplay)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSpinnerNoBonus()
|
||||||
|
{
|
||||||
|
AddStep("Set high spin rate", () => spinRate.Value = 5);
|
||||||
|
|
||||||
|
Spinner spinner;
|
||||||
|
|
||||||
|
AddStep("add spinner", () => SetContents(_ =>
|
||||||
|
{
|
||||||
|
spinner = new Spinner
|
||||||
|
{
|
||||||
|
StartTime = Time.Current,
|
||||||
|
EndTime = Time.Current + 750,
|
||||||
|
Samples = new List<HitSampleInfo>
|
||||||
|
{
|
||||||
|
new HitSampleInfo(HitSampleInfo.HIT_NORMAL)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { OverallDifficulty = 0 });
|
||||||
|
|
||||||
|
return drawableSpinner = new TestDrawableSpinner(spinner, true, spinRate)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Depth = depthIndex++,
|
||||||
|
Scale = new Vector2(0.75f)
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSpinningSamplePitchShift()
|
public void TestSpinningSamplePitchShift()
|
||||||
{
|
{
|
||||||
@ -153,7 +190,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
if (auto)
|
if (auto)
|
||||||
RotationTracker.AddRotation((float)(Clock.ElapsedFrameTime * spinRate.Value));
|
RotationTracker.AddRotation((float)Math.Min(180, Clock.ElapsedFrameTime * spinRate.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -45,6 +46,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
private const float spinning_sample_initial_frequency = 1.0f;
|
private const float spinning_sample_initial_frequency = 1.0f;
|
||||||
private const float spinning_sample_modulated_base_frequency = 0.5f;
|
private const float spinning_sample_modulated_base_frequency = 0.5f;
|
||||||
|
|
||||||
|
private SkinnableSound maxBonusSample;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of bonus score gained from spinning after the required number of spins, for display purposes.
|
/// The amount of bonus score gained from spinning after the required number of spins, for display purposes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -109,6 +112,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
||||||
Looping = true,
|
Looping = true,
|
||||||
Frequency = { Value = spinning_sample_initial_frequency }
|
Frequency = { Value = spinning_sample_initial_frequency }
|
||||||
|
},
|
||||||
|
maxBonusSample = new SkinnableSound
|
||||||
|
{
|
||||||
|
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -128,6 +135,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
base.OnFree();
|
base.OnFree();
|
||||||
|
|
||||||
spinningSample.ClearSamples();
|
spinningSample.ClearSamples();
|
||||||
|
maxBonusSample.ClearSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadSamples()
|
protected override void LoadSamples()
|
||||||
@ -136,6 +144,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
spinningSample.Samples = HitObject.CreateSpinningSamples().Cast<ISampleInfo>().ToArray();
|
spinningSample.Samples = HitObject.CreateSpinningSamples().Cast<ISampleInfo>().ToArray();
|
||||||
spinningSample.Frequency.Value = spinning_sample_initial_frequency;
|
spinningSample.Frequency.Value = spinning_sample_initial_frequency;
|
||||||
|
|
||||||
|
maxBonusSample.Samples = new ISampleInfo[] { new SpinnerBonusMaxSampleInfo(HitObject.CreateHitSampleInfo()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSpinningSample(ValueChangedEvent<bool> tracking)
|
private void updateSpinningSample(ValueChangedEvent<bool> tracking)
|
||||||
@ -157,6 +167,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
base.StopAllSamples();
|
base.StopAllSamples();
|
||||||
spinningSample?.Stop();
|
spinningSample?.Stop();
|
||||||
|
maxBonusSample?.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
@ -322,10 +333,38 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
var tick = ticks.FirstOrDefault(t => !t.Result.HasResult);
|
var tick = ticks.FirstOrDefault(t => !t.Result.HasResult);
|
||||||
|
|
||||||
// tick may be null if we've hit the spin limit.
|
// tick may be null if we've hit the spin limit.
|
||||||
tick?.TriggerResult(true);
|
if (tick == null)
|
||||||
|
{
|
||||||
|
// we still want to play a sound. this will probably be a new sound in the future, but for now let's continue playing the bonus sound.
|
||||||
|
// TODO: this doesn't concurrency. i can't figure out how to make it concurrency. samples are bad and need a refactor.
|
||||||
|
maxBonusSample.Play();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tick.TriggerResult(true);
|
||||||
|
|
||||||
completedFullSpins.Value++;
|
completedFullSpins.Value++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SpinnerBonusMaxSampleInfo : HitSampleInfo
|
||||||
|
{
|
||||||
|
public override IEnumerable<string> LookupNames
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
foreach (string name in base.LookupNames)
|
||||||
|
yield return name;
|
||||||
|
|
||||||
|
foreach (string name in base.LookupNames)
|
||||||
|
yield return name.Replace("-max", string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpinnerBonusMaxSampleInfo(HitSampleInfo sampleInfo)
|
||||||
|
: base("spinnerbonus-max", sampleInfo.Bank, sampleInfo.Suffix, sampleInfo.Volume)
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user