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