mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Make Swells play samples while they're being hit
This commit is contained in:
parent
8529eb1d3a
commit
844e39a9f6
@ -14,6 +14,7 @@ using OpenTK;
|
|||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Rulesets.Taiko.Judgements;
|
using osu.Game.Rulesets.Taiko.Judgements;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -34,10 +35,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
private readonly CircularContainer targetRing;
|
private readonly CircularContainer targetRing;
|
||||||
private readonly CircularContainer expandingRing;
|
private readonly CircularContainer expandingRing;
|
||||||
|
|
||||||
private readonly TaikoAction[] rimActions = { TaikoAction.LeftRim, TaikoAction.RightRim };
|
|
||||||
private readonly TaikoAction[] centreActions = { TaikoAction.LeftCentre, TaikoAction.RightCentre };
|
|
||||||
private TaikoAction[] lastAction;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of times the user has hit this swell.
|
/// The amount of times the user has hit this swell.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -120,11 +117,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours, AudioManager audio)
|
||||||
{
|
{
|
||||||
MainPiece.AccentColour = colours.YellowDark;
|
MainPiece.AccentColour = colours.YellowDark;
|
||||||
expandingRing.Colour = colours.YellowLight;
|
expandingRing.Colour = colours.YellowLight;
|
||||||
targetRing.BorderColour = colours.YellowDark.Opacity(0.25f);
|
targetRing.BorderColour = colours.YellowDark.Opacity(0.25f);
|
||||||
|
|
||||||
|
foreach (var mapping in HitObject.ProgressionSamples)
|
||||||
|
mapping.RetrieveChannels(audio);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -205,22 +205,39 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool? lastWasCentre;
|
||||||
|
|
||||||
public override bool OnPressed(TaikoAction action)
|
public override bool OnPressed(TaikoAction action)
|
||||||
{
|
{
|
||||||
// Don't handle keys before the swell starts
|
// Don't handle keys before the swell starts
|
||||||
if (Time.Current < HitObject.StartTime)
|
if (Time.Current < HitObject.StartTime)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Find the keyset which this key corresponds to
|
var isCentre = action == TaikoAction.LeftCentre || action == TaikoAction.RightCentre;
|
||||||
var keySet = rimActions.Contains(action) ? rimActions : centreActions;
|
|
||||||
|
|
||||||
// Ensure alternating keysets
|
// Ensure alternating centre and rim hits
|
||||||
if (keySet == lastAction)
|
if (lastWasCentre == isCentre)
|
||||||
return false;
|
return false;
|
||||||
lastAction = keySet;
|
lastWasCentre = isCentre;
|
||||||
|
|
||||||
UpdateJudgement(true);
|
UpdateJudgement(true);
|
||||||
|
|
||||||
|
if (AllJudged)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// While the swell hasn't been fully judged, input is still blocked so it doesn't fall through to other hitobjects
|
||||||
|
// This causes the playfield to not play sounds, so they need to be handled locally
|
||||||
|
|
||||||
|
var mappingIndex = HitObject.ProgressionSamples.BinarySearch(new SwellSampleMapping { Time = Time.Current });
|
||||||
|
if (mappingIndex < 0)
|
||||||
|
mappingIndex = ~mappingIndex - 1;
|
||||||
|
|
||||||
|
var mapping = HitObject.ProgressionSamples[mappingIndex];
|
||||||
|
if (isCentre)
|
||||||
|
mapping.CentreChannel.Play();
|
||||||
|
else
|
||||||
|
mapping.RimChannel.Play();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects
|
namespace osu.Game.Rulesets.Taiko.Objects
|
||||||
@ -15,5 +20,26 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
/// The number of hits required to complete the swell successfully.
|
/// The number of hits required to complete the swell successfully.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int RequiredHits = 10;
|
public int RequiredHits = 10;
|
||||||
|
|
||||||
|
public List<SwellSampleMapping> ProgressionSamples = new List<SwellSampleMapping>();
|
||||||
|
|
||||||
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
|
{
|
||||||
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||||
|
|
||||||
|
var progressionSamplePoints =
|
||||||
|
new[] { controlPointInfo.SamplePointAt(StartTime) }
|
||||||
|
.Concat(controlPointInfo.SamplePoints.Where(p => p.Time > StartTime && p.Time <= EndTime));
|
||||||
|
|
||||||
|
foreach (var point in progressionSamplePoints)
|
||||||
|
{
|
||||||
|
ProgressionSamples.Add(new SwellSampleMapping
|
||||||
|
{
|
||||||
|
Time = point.Time,
|
||||||
|
Centre = point.GetSampleInfo(),
|
||||||
|
Rim = point.GetSampleInfo(SampleInfo.HIT_CLAP)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
28
osu.Game.Rulesets.Taiko/Objects/SwellSampleMapping.cs
Normal file
28
osu.Game.Rulesets.Taiko/Objects/SwellSampleMapping.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Objects
|
||||||
|
{
|
||||||
|
public class SwellSampleMapping : IComparable<SwellSampleMapping>
|
||||||
|
{
|
||||||
|
public double Time;
|
||||||
|
public SampleInfo Centre;
|
||||||
|
public SampleInfo Rim;
|
||||||
|
|
||||||
|
public SampleChannel CentreChannel { get; private set; }
|
||||||
|
public SampleChannel RimChannel { get; private set; }
|
||||||
|
|
||||||
|
public void RetrieveChannels(AudioManager audio)
|
||||||
|
{
|
||||||
|
CentreChannel = Centre.GetChannel(audio.Sample);
|
||||||
|
RimChannel = Rim.GetChannel(audio.Sample);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(SwellSampleMapping other) => Time.CompareTo(other.Time);
|
||||||
|
}
|
||||||
|
}
|
@ -74,6 +74,7 @@
|
|||||||
<Compile Include="Objects\Hit.cs" />
|
<Compile Include="Objects\Hit.cs" />
|
||||||
<Compile Include="Objects\RimHit.cs" />
|
<Compile Include="Objects\RimHit.cs" />
|
||||||
<Compile Include="Objects\Swell.cs" />
|
<Compile Include="Objects\Swell.cs" />
|
||||||
|
<Compile Include="Objects\SwellSampleMapping.cs" />
|
||||||
<Compile Include="Replays\TaikoFramedReplayInputHandler.cs" />
|
<Compile Include="Replays\TaikoFramedReplayInputHandler.cs" />
|
||||||
<Compile Include="Replays\TaikoAutoGenerator.cs" />
|
<Compile Include="Replays\TaikoAutoGenerator.cs" />
|
||||||
<Compile Include="Objects\TaikoHitObject.cs" />
|
<Compile Include="Objects\TaikoHitObject.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user