2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-11-20 12:19:49 +00:00
|
|
|
|
using System;
|
2017-04-04 03:38:55 +00:00
|
|
|
|
using System.Linq;
|
2020-12-14 22:02:33 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2017-03-30 09:59:00 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-01-09 04:43:44 +00:00
|
|
|
|
using osu.Framework.Utils;
|
2017-03-30 09:59:00 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2017-04-18 07:05:58 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Graphics;
|
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;
|
2021-09-16 09:26:12 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2017-09-06 08:02:13 +00:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2019-10-17 02:57:00 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2017-12-30 20:23:18 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-12-07 03:30:25 +00:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Skinning.Default;
|
2020-04-15 07:54:50 +00:00
|
|
|
|
using osu.Game.Skinning;
|
2020-04-17 10:52:58 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +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
|
|
|
|
{
|
2020-12-14 20:47:31 +00:00
|
|
|
|
public class DrawableDrumRoll : DrawableTaikoStrongableHitObject<DrumRoll, DrumRoll.StrongNestedHit>
|
2017-03-17 10:30:22 +00:00
|
|
|
|
{
|
2017-03-31 02:41:06 +00:00
|
|
|
|
/// <summary>
|
2018-03-15 06:58:04 +00:00
|
|
|
|
/// Number of rolling hits required to reach the dark/final colour.
|
2017-03-31 02:41:06 +00:00
|
|
|
|
/// </summary>
|
2018-03-15 06:58:04 +00:00
|
|
|
|
private const int rolling_hits_for_engaged_colour = 5;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-31 02:41:06 +00:00
|
|
|
|
/// <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;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-12-14 22:02:33 +00:00
|
|
|
|
private readonly Container tickContainer;
|
2019-10-17 02:57:00 +00:00
|
|
|
|
|
|
|
|
|
private Color4 colourIdle;
|
|
|
|
|
private Color4 colourEngaged;
|
|
|
|
|
|
2020-12-14 22:02:33 +00:00
|
|
|
|
public DrawableDrumRoll()
|
|
|
|
|
: this(null)
|
2017-03-17 10:30:22 +00:00
|
|
|
|
{
|
2019-10-17 02:57:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 22:02:33 +00:00
|
|
|
|
public DrawableDrumRoll([CanBeNull] DrumRoll drumRoll)
|
|
|
|
|
: base(drumRoll)
|
2019-10-17 02:57:00 +00:00
|
|
|
|
{
|
2020-12-14 22:02:33 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2020-04-15 07:54:50 +00:00
|
|
|
|
|
2020-05-26 07:58:28 +00:00
|
|
|
|
Content.Add(tickContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Depth = float.MinValue
|
|
|
|
|
});
|
2019-10-17 02:57:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 22:02:33 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
colourIdle = colours.YellowDark;
|
|
|
|
|
colourEngaged = colours.YellowDarker;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 02:57:00 +00:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
OnNewResult += onNewResult;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-26 07:58:28 +00:00
|
|
|
|
protected override void RecreatePieces()
|
|
|
|
|
{
|
|
|
|
|
base.RecreatePieces();
|
|
|
|
|
updateColour();
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 22:02:33 +00:00
|
|
|
|
protected override void OnFree()
|
|
|
|
|
{
|
|
|
|
|
base.OnFree();
|
|
|
|
|
rollingHits = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 04:52:21 +00:00
|
|
|
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
2019-10-17 02:57:00 +00:00
|
|
|
|
{
|
2019-10-17 04:52:21 +00:00
|
|
|
|
base.AddNestedHitObject(hitObject);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-10-17 03:53:54 +00:00
|
|
|
|
switch (hitObject)
|
2017-08-08 07:01:18 +00:00
|
|
|
|
{
|
2019-10-17 02:57:00 +00:00
|
|
|
|
case DrawableDrumRollTick tick:
|
|
|
|
|
tickContainer.Add(tick);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 04:52:21 +00:00
|
|
|
|
protected override void ClearNestedHitObjects()
|
2019-10-17 02:57:00 +00:00
|
|
|
|
{
|
2019-10-17 04:52:21 +00:00
|
|
|
|
base.ClearNestedHitObjects();
|
2020-12-20 16:57:19 +00:00
|
|
|
|
tickContainer.Clear(false);
|
2019-10-17 02:57:00 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-10-17 04:52:21 +00:00
|
|
|
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
2019-10-17 02:57:00 +00:00
|
|
|
|
{
|
|
|
|
|
switch (hitObject)
|
|
|
|
|
{
|
|
|
|
|
case DrumRollTick tick:
|
|
|
|
|
return new DrawableDrumRollTick(tick);
|
2017-03-17 10:30:22 +00:00
|
|
|
|
}
|
2019-10-17 02:57:00 +00:00
|
|
|
|
|
2019-10-17 04:52:21 +00:00
|
|
|
|
return base.CreateNestedHitObject(hitObject);
|
2017-03-17 10:30:22 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-15 07:54:50 +00:00
|
|
|
|
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollBody),
|
|
|
|
|
_ => new ElongatedCirclePiece());
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-09-16 09:26:12 +00:00
|
|
|
|
public override bool OnPressed(KeyBindingPressEvent<TaikoAction> e) => false;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-10-17 02:57:00 +00:00
|
|
|
|
private void onNewResult(DrawableHitObject obj, JudgementResult result)
|
2017-03-29 00:38:24 +00:00
|
|
|
|
{
|
2019-10-17 02:57:00 +00:00
|
|
|
|
if (!(obj is DrawableDrumRollTick))
|
|
|
|
|
return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-10-02 20:57:49 +00:00
|
|
|
|
if (result.IsHit)
|
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--;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-11-20 12:19:49 +00:00
|
|
|
|
rollingHits = Math.Clamp(rollingHits, 0, rolling_hits_for_engaged_colour);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-12-14 22:02:33 +00:00
|
|
|
|
updateColour(100);
|
2017-03-30 09:59:00 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-08-06 02:31:46 +00:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2017-03-17 10:30:22 +00:00
|
|
|
|
{
|
|
|
|
|
if (userTriggered)
|
|
|
|
|
return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-06 08:02:13 +00:00
|
|
|
|
if (timeOffset < 0)
|
2017-03-17 10:30:22 +00:00
|
|
|
|
return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-03-05 12:40:26 +00:00
|
|
|
|
int countHit = NestedHitObjects.Count(o => o.IsHit);
|
2020-04-07 08:40:01 +00:00
|
|
|
|
|
2018-03-05 12:17:26 +00:00
|
|
|
|
if (countHit >= HitObject.RequiredGoodHits)
|
2020-04-07 08:40:01 +00:00
|
|
|
|
{
|
2020-09-29 08:16:55 +00:00
|
|
|
|
ApplyResult(r => r.Type = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Ok);
|
2020-04-07 08:40:01 +00:00
|
|
|
|
}
|
2017-03-17 10:30:22 +00:00
|
|
|
|
else
|
2020-10-02 20:58:10 +00:00
|
|
|
|
ApplyResult(r => r.Type = r.Judgement.MinResult);
|
2017-03-17 10:30:22 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-11-04 07:19:07 +00:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2017-03-28 07:50:06 +00:00
|
|
|
|
{
|
2018-01-10 10:17:43 +00:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
case ArmedState.Miss:
|
2020-11-04 07:19:07 +00:00
|
|
|
|
this.FadeOut(100);
|
2018-01-10 10:17:43 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-03-28 07:50:06 +00:00
|
|
|
|
}
|
2018-08-03 07:20:08 +00:00
|
|
|
|
|
2020-04-17 10:52:58 +00:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
OriginPosition = new Vector2(DrawHeight);
|
|
|
|
|
Content.X = DrawHeight / 2;
|
|
|
|
|
}
|
2018-08-03 07:20:08 +00:00
|
|
|
|
|
2020-12-14 22:21:19 +00:00
|
|
|
|
protected override DrawableStrongNestedHit CreateStrongNestedHit(DrumRoll.StrongNestedHit hitObject) => new StrongNestedHit(hitObject);
|
2018-08-03 07:56:46 +00:00
|
|
|
|
|
2020-12-14 22:02:33 +00:00
|
|
|
|
private void updateColour(double fadeDuration = 0)
|
2020-04-15 09:44:12 +00:00
|
|
|
|
{
|
|
|
|
|
Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1);
|
2020-12-14 22:02:33 +00:00
|
|
|
|
(MainPiece.Drawable as IHasAccentColour)?.FadeAccent(newColour, fadeDuration);
|
2020-04-15 09:44:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-20 17:02:31 +00:00
|
|
|
|
public class StrongNestedHit : DrawableStrongNestedHit
|
2018-08-03 07:56:46 +00:00
|
|
|
|
{
|
2020-12-14 22:21:19 +00:00
|
|
|
|
public new DrawableDrumRoll ParentHitObject => (DrawableDrumRoll)base.ParentHitObject;
|
|
|
|
|
|
|
|
|
|
public StrongNestedHit()
|
|
|
|
|
: this(null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StrongNestedHit([CanBeNull] DrumRoll.StrongNestedHit nestedHit)
|
|
|
|
|
: base(nestedHit)
|
2018-08-03 07:56:46 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 02:31:46 +00:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-08-03 07:56:46 +00:00
|
|
|
|
{
|
2020-12-14 22:21:19 +00:00
|
|
|
|
if (!ParentHitObject.Judged)
|
2018-08-03 07:56:46 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-12-14 22:21:19 +00:00
|
|
|
|
ApplyResult(r => r.Type = ParentHitObject.IsHit ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2018-08-03 07:56:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-16 16:15:01 +00:00
|
|
|
|
public override void OnKilled()
|
|
|
|
|
{
|
|
|
|
|
base.OnKilled();
|
|
|
|
|
|
|
|
|
|
if (Time.Current > ParentHitObject.HitObject.GetEndTime() && !Judged)
|
|
|
|
|
ApplyResult(r => r.Type = r.Judgement.MinResult);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 09:26:12 +00:00
|
|
|
|
public override bool OnPressed(KeyBindingPressEvent<TaikoAction> e) => false;
|
2018-08-03 07:56:46 +00:00
|
|
|
|
}
|
2017-03-17 10:30:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|