1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 13:07:24 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs

105 lines
3.6 KiB
C#
Raw Normal View History

2017-03-20 17:24:28 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-04-04 11:38:55 +08:00
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Judgements;
2017-04-04 11:38:55 +08:00
using OpenTK;
using OpenTK.Graphics;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Judgements;
2017-04-18 15:05:58 +08:00
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
public class DrawableDrumRoll : DrawableTaikoHitObject<DrumRoll>
{
/// <summary>
2017-04-01 15:32:31 +08:00
/// Number of rolling hits required to reach the dark/final accent colour.
/// </summary>
2017-04-01 15:32:31 +08:00
private const int rolling_hits_for_dark_accent = 5;
private Color4 accentDarkColour;
/// <summary>
2017-04-01 15:34:30 +08:00
/// Rolling number of tick hits. This increases for hits and decreases for misses.
/// </summary>
2017-04-01 15:32:31 +08:00
private int rollingHits;
public DrawableDrumRoll(DrumRoll drumRoll)
: base(drumRoll)
{
Width = (float)HitObject.Duration;
Container<DrawableDrumRollTick> tickContainer;
MainPiece.Add(tickContainer = new Container<DrawableDrumRollTick>
{
RelativeSizeAxes = Axes.Both,
RelativeChildOffset = new Vector2((float)HitObject.StartTime, 0),
RelativeChildSize = new Vector2((float)HitObject.Duration, 1)
});
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
{
2017-08-09 15:19:31 +08:00
var newTick = new DrawableDrumRollTick(tick);
newTick.OnJudgement += onTickJudgement;
AddNested(newTick);
tickContainer.Add(newTick);
}
}
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
2017-08-20 20:18:21 +08:00
public override bool OnPressed(TaikoAction action) => false;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
MainPiece.AccentColour = AccentColour = colours.YellowDark;
accentDarkColour = colours.YellowDarker;
}
private void onTickJudgement(DrawableHitObject obj, Judgement judgement)
{
if (judgement.Result > HitResult.Miss)
2017-04-01 15:32:31 +08:00
rollingHits++;
else
2017-04-01 15:32:31 +08:00
rollingHits--;
2017-04-01 15:32:31 +08:00
rollingHits = MathHelper.Clamp(rollingHits, 0, rolling_hits_for_dark_accent);
2017-04-01 15:32:31 +08:00
Color4 newAccent = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_dark_accent, AccentColour, accentDarkColour, 0, 1);
MainPiece.FadeAccent(newAccent, 100);
}
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{
if (userTriggered)
return;
if (timeOffset < 0)
return;
int countHit = NestedHitObjects.Count(o => o.AllJudged);
if (countHit > HitObject.RequiredGoodHits)
{
AddJudgement(new TaikoJudgement { Result = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Good });
if (HitObject.IsStrong)
AddJudgement(new TaikoStrongHitJudgement());
}
else
AddJudgement(new TaikoJudgement { Result = HitResult.Miss });
}
2017-03-28 15:50:06 +08:00
protected override void UpdateState(ArmedState state)
{
}
}
}