2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|
|
|
|
{
|
|
|
|
|
public class DrawableDrumRoll : DrawableTaikoHitObject<DrumRoll>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of rolling hits required to reach the dark/final colour.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const int rolling_hits_for_engaged_colour = 5;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Rolling number of tick hits. This increases for hits and decreases for misses.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int rollingHits;
|
|
|
|
|
|
|
|
|
|
public DrawableDrumRoll(DrumRoll drumRoll)
|
|
|
|
|
: base(drumRoll)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
Container<DrawableDrumRollTick> tickContainer;
|
|
|
|
|
MainPiece.Add(tickContainer = new Container<DrawableDrumRollTick> { RelativeSizeAxes = Axes.Both });
|
|
|
|
|
|
|
|
|
|
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
|
|
|
|
|
{
|
|
|
|
|
var newTick = new DrawableDrumRollTick(tick);
|
2018-08-06 09:54:16 +08:00
|
|
|
|
newTick.OnNewResult += onNewTickResult;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
AddNested(newTick);
|
|
|
|
|
tickContainer.Add(newTick);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
|
|
|
|
|
|
|
|
|
|
public override bool OnPressed(TaikoAction action) => false;
|
|
|
|
|
|
|
|
|
|
private Color4 colourIdle;
|
|
|
|
|
private Color4 colourEngaged;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
MainPiece.AccentColour = colourIdle = colours.YellowDark;
|
|
|
|
|
colourEngaged = colours.YellowDarker;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 09:54:16 +08:00
|
|
|
|
private void onNewTickResult(DrawableHitObject obj, JudgementResult result)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-08-02 19:36:08 +08:00
|
|
|
|
if (result.Type > HitResult.Miss)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
rollingHits++;
|
|
|
|
|
else
|
|
|
|
|
rollingHits--;
|
|
|
|
|
|
|
|
|
|
rollingHits = MathHelper.Clamp(rollingHits, 0, rolling_hits_for_engaged_colour);
|
|
|
|
|
|
|
|
|
|
Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1);
|
|
|
|
|
MainPiece.FadeAccent(newColour, 100);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
if (userTriggered)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (timeOffset < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int countHit = NestedHitObjects.Count(o => o.IsHit);
|
|
|
|
|
if (countHit >= HitObject.RequiredGoodHits)
|
2018-08-03 15:20:08 +08:00
|
|
|
|
ApplyResult(r => r.Type = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Good);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
else
|
2018-08-03 15:20:08 +08:00
|
|
|
|
ApplyResult(r => r.Type = HitResult.Miss);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(100).Expire();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-03 15:20:08 +08:00
|
|
|
|
|
2018-08-14 13:28:05 +08:00
|
|
|
|
protected override DrawableStrongNestedHit CreateStrongHit(StrongHitObject hitObject) => new StrongNestedHit(hitObject, this);
|
2018-08-03 15:56:46 +08:00
|
|
|
|
|
2018-08-14 13:28:05 +08:00
|
|
|
|
private class StrongNestedHit : DrawableStrongNestedHit
|
2018-08-03 15:56:46 +08:00
|
|
|
|
{
|
2018-08-14 13:28:05 +08:00
|
|
|
|
public StrongNestedHit(StrongHitObject strong, DrawableDrumRoll drumRoll)
|
2018-08-03 15:56:46 +08:00
|
|
|
|
: base(strong, drumRoll)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-08-03 15:56:46 +08:00
|
|
|
|
{
|
|
|
|
|
if (!MainObject.Judged)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ApplyResult(r => r.Type = MainObject.IsHit ? HitResult.Great : HitResult.Miss);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnPressed(TaikoAction action) => false;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|