1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 14:12:55 +08:00

Add drawable spinner ticks implementation

This commit is contained in:
iiSaLMaN 2019-08-20 21:17:27 +03:00
parent ee1c3d42d8
commit bb4178fa03
4 changed files with 80 additions and 1 deletions

View File

@ -0,0 +1,49 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
public class DrawableSpinnerTick : DrawableOsuHitObject
{
private readonly BindableDouble bonusSampleVolume = new BindableDouble();
private bool hasBonusPoints;
/// <summary>
/// Whether this judgement has a bonus of 1,000 points additional to the numeric result.
/// Should be set when a spin occured after the spinner has completed.
/// </summary>
public bool HasBonusPoints
{
get => hasBonusPoints;
internal set
{
hasBonusPoints = value;
bonusSampleVolume.Value = value ? 1 : 0;
((OsuSpinnerTickJudgement)Result.Judgement).HasBonusPoints = value;
}
}
public override bool DisplayResult => false;
public DrawableSpinnerTick(SpinnerTick spinnerTick)
: base(spinnerTick)
{
}
protected override void LoadComplete()
{
base.LoadComplete();
Samples.AddAdjustment(AdjustableProperty.Volume, bonusSampleVolume);
}
public void TriggerResult(HitResult result) => ApplyResult(r => r.Type = result);
}
}

View File

@ -7,6 +7,8 @@ using osu.Game.Rulesets.Objects.Types;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Replays;
using osuTK;
namespace osu.Game.Rulesets.Osu.Objects
{
@ -30,6 +32,15 @@ namespace osu.Game.Rulesets.Osu.Objects
SpinsRequired = (int)Math.Max(1, SpinsRequired * 0.6);
}
protected override void CreateNestedHitObjects()
{
base.CreateNestedHitObjects();
var maximumSpins = OsuAutoGeneratorBase.SPIN_RADIUS * (Duration / 1000) / MathHelper.TwoPi;
for (int i = 0; i < maximumSpins; i++)
AddNested(new SpinnerTick());
}
public override Judgement CreateJudgement() => new OsuJudgement();
}
}

View File

@ -0,0 +1,19 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Audio;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements;
namespace osu.Game.Rulesets.Osu.Objects
{
public class SpinnerTick : OsuHitObject
{
public SpinnerTick()
{
Samples.Add(new HitSampleInfo { Name = "spinnerbonus" });
}
public override Judgement CreateJudgement() => new OsuSpinnerTickJudgement();
}
}

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Replays
/// </summary>
protected static readonly Vector2 SPINNER_CENTRE = OsuPlayfield.BASE_SIZE / 2;
protected const float SPIN_RADIUS = 50;
public const float SPIN_RADIUS = 50;
/// <summary>
/// The time in ms between each ReplayFrame.