mirror of https://github.com/ppy/osu
parent
5026c7a95e
commit
9ca03c0209
|
@ -62,7 +62,7 @@ public class TaikoPlayfield : ScrollingPlayfield, IKeyBindingHandler<TaikoAction
|
|||
private readonly Box background;
|
||||
|
||||
private readonly ControlPointInfo controlPointInfo;
|
||||
private Dictionary<double, Tuple<SampleChannel, SampleChannel>> allSamples;
|
||||
private Dictionary<SampleControlPoint, Tuple<SampleChannel, SampleChannel>> drumSampleMappings;
|
||||
|
||||
public TaikoPlayfield(ControlPointInfo controlPointInfo)
|
||||
: base(Axes.X)
|
||||
|
@ -207,12 +207,12 @@ public TaikoPlayfield(ControlPointInfo controlPointInfo)
|
|||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, AudioManager audio)
|
||||
{
|
||||
allSamples = new Dictionary<double, Tuple<SampleChannel, SampleChannel>>();
|
||||
drumSampleMappings = new Dictionary<SampleControlPoint, Tuple<SampleChannel, SampleChannel>>();
|
||||
foreach (var s in controlPointInfo.SamplePoints)
|
||||
{
|
||||
var normalSample = SampleInfo.FromSoundPoint(s).GetChannel(audio.Sample);
|
||||
var clapSample = SampleInfo.FromSoundPoint(s, SampleInfo.HIT_CLAP).GetChannel(audio.Sample);
|
||||
allSamples.Add(s.Time, new Tuple<SampleChannel, SampleChannel>(normalSample, clapSample));
|
||||
var normalSample = s.GetSampleInfo().GetChannel(audio.Sample);
|
||||
var clapSample = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample);
|
||||
drumSampleMappings.Add(s, new Tuple<SampleChannel, SampleChannel>(normalSample, clapSample));
|
||||
}
|
||||
|
||||
overlayBackgroundContainer.BorderColour = colours.Gray0;
|
||||
|
@ -268,7 +268,9 @@ public override void OnJudgement(DrawableHitObject judgedObject, Judgement judge
|
|||
{
|
||||
topLevelHitContainer.Add(judgedObject.CreateProxy());
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));
|
||||
|
@ -280,10 +282,9 @@ public override void OnJudgement(DrawableHitObject judgedObject, Judgement judge
|
|||
|
||||
public bool OnPressed(TaikoAction action)
|
||||
{
|
||||
var currentTime = Clock.CurrentTime;
|
||||
var soundPoint = currentTime < controlPointInfo.SamplePoints[0].Time ? controlPointInfo.SamplePoints[0] : controlPointInfo.SamplePointAt(currentTime);
|
||||
var samplePoint = controlPointInfo.SamplePointAt(Clock.CurrentTime);
|
||||
|
||||
if (!allSamples.TryGetValue(soundPoint.Time, out Tuple<SampleChannel, SampleChannel> samples))
|
||||
if (!drumSampleMappings.TryGetValue(samplePoint, out var samples))
|
||||
throw new InvalidOperationException("Current sample set not found.");
|
||||
|
||||
if (action == TaikoAction.LeftCentre || action == TaikoAction.RightCentre)
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Audio
|
||||
{
|
||||
|
@ -17,16 +16,6 @@ public class SampleInfo
|
|||
public const string HIT_NORMAL = @"hitnormal";
|
||||
public const string HIT_CLAP = @"hitclap";
|
||||
|
||||
public static SampleInfo FromSoundPoint(SampleControlPoint samplePoint, string sampleName = HIT_NORMAL)
|
||||
{
|
||||
return new SampleInfo
|
||||
{
|
||||
Bank = samplePoint.SampleBank,
|
||||
Name = sampleName,
|
||||
Volume = samplePoint.SampleVolume,
|
||||
};
|
||||
}
|
||||
|
||||
public SampleChannel GetChannel(SampleManager manager)
|
||||
{
|
||||
var channel = manager.Get($"Gameplay/{Bank}-{Name}");
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ControlPointInfo
|
|||
/// </summary>
|
||||
/// <param name="time">The time to find the sound control point at.</param>
|
||||
/// <returns>The sound control point.</returns>
|
||||
public SampleControlPoint SamplePointAt(double time) => binarySearch(SamplePoints, time);
|
||||
public SampleControlPoint SamplePointAt(double time) => binarySearch(SamplePoints, time, SamplePoints.FirstOrDefault());
|
||||
|
||||
/// <summary>
|
||||
/// Finds the timing control point that is active at <paramref name="time"/>.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Audio;
|
||||
|
||||
namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
public class SampleControlPoint : ControlPoint
|
||||
|
@ -16,5 +18,17 @@ public class SampleControlPoint : ControlPoint
|
|||
/// The default sample volume at this control point.
|
||||
/// </summary>
|
||||
public int SampleVolume;
|
||||
|
||||
/// <summary>
|
||||
/// Create a SampleInfo based on the sample settings in this control point.
|
||||
/// </summary>
|
||||
/// <param name="sampleName">The name of the same.</param>
|
||||
/// <returns>A populated <see cref="SampleInfo"/>.</returns>
|
||||
public SampleInfo GetSampleInfo(string sampleName = SampleInfo.HIT_NORMAL) => new SampleInfo
|
||||
{
|
||||
Bank = SampleBank,
|
||||
Name = sampleName,
|
||||
Volume = SampleVolume,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue