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
|
|
|
|
|
2019-11-20 20:19:49 +08:00
|
|
|
|
using System;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
2020-01-09 12:43:44 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
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;
|
2019-10-17 10:57:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-04-15 15:54:50 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2020-04-17 18:52:58 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2020-04-15 17:44:12 +08:00
|
|
|
|
private Container tickContainer;
|
2019-10-17 10:57:00 +08:00
|
|
|
|
|
|
|
|
|
private Color4 colourIdle;
|
|
|
|
|
private Color4 colourEngaged;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public DrawableDrumRoll(DrumRoll drumRoll)
|
|
|
|
|
: base(drumRoll)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2019-10-17 10:57:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2020-04-15 15:54:50 +08:00
|
|
|
|
colourIdle = colours.YellowDark;
|
2019-10-17 10:57:00 +08:00
|
|
|
|
colourEngaged = colours.YellowDarker;
|
2020-04-15 15:54:50 +08:00
|
|
|
|
|
2020-05-26 15:58:28 +08:00
|
|
|
|
Content.Add(tickContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Depth = float.MinValue
|
|
|
|
|
});
|
2019-10-17 10:57:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
OnNewResult += onNewResult;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-26 15:58:28 +08:00
|
|
|
|
protected override void RecreatePieces()
|
|
|
|
|
{
|
|
|
|
|
base.RecreatePieces();
|
|
|
|
|
updateColour();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 12:52:21 +08:00
|
|
|
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
2019-10-17 10:57:00 +08:00
|
|
|
|
{
|
2019-10-17 12:52:21 +08:00
|
|
|
|
base.AddNestedHitObject(hitObject);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-10-17 11:53:54 +08:00
|
|
|
|
switch (hitObject)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-10-17 10:57:00 +08:00
|
|
|
|
case DrawableDrumRollTick tick:
|
|
|
|
|
tickContainer.Add(tick);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 12:52:21 +08:00
|
|
|
|
protected override void ClearNestedHitObjects()
|
2019-10-17 10:57:00 +08:00
|
|
|
|
{
|
2019-10-17 12:52:21 +08:00
|
|
|
|
base.ClearNestedHitObjects();
|
2019-10-17 10:57:00 +08:00
|
|
|
|
tickContainer.Clear();
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-10-17 12:52:21 +08:00
|
|
|
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
2019-10-17 10:57:00 +08:00
|
|
|
|
{
|
|
|
|
|
switch (hitObject)
|
|
|
|
|
{
|
|
|
|
|
case DrumRollTick tick:
|
|
|
|
|
return new DrawableDrumRollTick(tick);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-10-17 10:57:00 +08:00
|
|
|
|
|
2019-10-17 12:52:21 +08:00
|
|
|
|
return base.CreateNestedHitObject(hitObject);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-15 15:54:50 +08:00
|
|
|
|
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollBody),
|
|
|
|
|
_ => new ElongatedCirclePiece());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-25 00:15:37 +08:00
|
|
|
|
public override bool OnPressed(TaikoAction action) => false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-10-17 10:57:00 +08:00
|
|
|
|
private void onNewResult(DrawableHitObject obj, JudgementResult result)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-10-17 10:57:00 +08:00
|
|
|
|
if (!(obj is DrawableDrumRollTick))
|
|
|
|
|
return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-10-03 04:57:49 +08:00
|
|
|
|
if (result.IsHit)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
rollingHits++;
|
|
|
|
|
else
|
|
|
|
|
rollingHits--;
|
|
|
|
|
|
2019-11-20 20:19:49 +08:00
|
|
|
|
rollingHits = Math.Clamp(rollingHits, 0, rolling_hits_for_engaged_colour);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-15 15:54:50 +08:00
|
|
|
|
updateColour();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
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);
|
2020-04-07 16:40:01 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
if (countHit >= HitObject.RequiredGoodHits)
|
2020-04-07 16:40:01 +08:00
|
|
|
|
{
|
2020-09-29 16:16:55 +08:00
|
|
|
|
ApplyResult(r => r.Type = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Ok);
|
2020-04-07 16:40:01 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
else
|
2020-10-03 04:58:10 +08:00
|
|
|
|
ApplyResult(r => r.Type = r.Judgement.MinResult);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-04 15:19:07 +08:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
case ArmedState.Miss:
|
2020-11-04 15:19:07 +08:00
|
|
|
|
this.FadeOut(100);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-03 15:20:08 +08:00
|
|
|
|
|
2020-04-17 18:52:58 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
OriginPosition = new Vector2(DrawHeight);
|
|
|
|
|
Content.X = DrawHeight / 2;
|
|
|
|
|
}
|
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
|
|
|
|
|
2020-04-15 17:44:12 +08:00
|
|
|
|
private void updateColour()
|
|
|
|
|
{
|
|
|
|
|
Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1);
|
|
|
|
|
(MainPiece.Drawable as IHasAccentColour)?.FadeAccent(newColour, 100);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
2020-09-29 14:13:11 +08:00
|
|
|
|
ApplyResult(r => r.Type = MainObject.IsHit ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2018-08-03 15:56:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnPressed(TaikoAction action) => false;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|