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
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2017-04-04 11:38:55 +08:00
|
|
|
|
using System;
|
2018-08-02 15:09:04 +08:00
|
|
|
|
using System.Linq;
|
2020-12-15 06:06:22 +08:00
|
|
|
|
using JetBrains.Annotations;
|
2017-03-28 14:05:45 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK.Graphics;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-09-16 17:26:12 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2019-10-17 10:57:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2020-12-07 11:30:25 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Skinning.Default;
|
2020-04-15 15:54:50 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
|
public partial class DrawableSwell : DrawableTaikoHitObject<Swell>
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
2017-03-31 10:20:04 +08:00
|
|
|
|
private const float target_ring_thick_border = 1.4f;
|
2017-03-28 14:05:45 +08:00
|
|
|
|
private const float target_ring_thin_border = 1f;
|
|
|
|
|
private const float target_ring_scale = 5f;
|
2017-03-31 10:20:04 +08:00
|
|
|
|
private const float inner_ring_alpha = 0.65f;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-08-27 14:21:54 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset away from the start time of the swell at which the ring starts appearing.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const double ring_appear_offset = 100;
|
|
|
|
|
|
2022-06-20 23:22:41 +08:00
|
|
|
|
private readonly Container<DrawableSwellTick> ticks;
|
2017-03-28 14:05:45 +08:00
|
|
|
|
private readonly Container bodyContainer;
|
|
|
|
|
private readonly CircularContainer targetRing;
|
2017-03-31 10:20:04 +08:00
|
|
|
|
private readonly CircularContainer expandingRing;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-08-05 22:30:07 +08:00
|
|
|
|
public override bool DisplayResult => false;
|
|
|
|
|
|
2020-12-15 06:06:22 +08:00
|
|
|
|
public DrawableSwell()
|
|
|
|
|
: this(null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DrawableSwell([CanBeNull] Swell swell)
|
2017-03-25 19:57:49 +08:00
|
|
|
|
: base(swell)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
FillMode = FillMode.Fit;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-11 20:45:19 +08:00
|
|
|
|
Content.Add(bodyContainer = new Container
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Depth = 1,
|
|
|
|
|
Children = new Drawable[]
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
expandingRing = new CircularContainer
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
Name = "Expanding ring",
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-08-21 12:29:50 +08:00
|
|
|
|
Blending = BlendingParameters.Additive,
|
2017-08-03 12:24:13 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
new Box
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = inner_ring_alpha,
|
2017-03-28 14:05:45 +08:00
|
|
|
|
}
|
2017-08-03 12:24:13 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
targetRing = new CircularContainer
|
|
|
|
|
{
|
|
|
|
|
Name = "Target ring (thick border)",
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
BorderThickness = target_ring_thick_border,
|
2019-08-21 12:29:50 +08:00
|
|
|
|
Blending = BlendingParameters.Additive,
|
2017-08-03 12:24:13 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
new Box
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
AlwaysPresent = true
|
|
|
|
|
},
|
|
|
|
|
new CircularContainer
|
|
|
|
|
{
|
|
|
|
|
Name = "Target ring (thin border)",
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
BorderThickness = target_ring_thin_border,
|
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
|
Children = new[]
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
new Box
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-08-03 12:24:13 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
AlwaysPresent = true
|
2017-03-28 14:05:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-29 13:52:14 +08:00
|
|
|
|
}
|
2017-03-28 14:05:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-16 15:09:51 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-20 23:22:41 +08:00
|
|
|
|
AddInternal(ticks = new Container<DrawableSwellTick> { RelativeSizeAxes = Axes.Both });
|
2017-03-28 14:05:45 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-28 14:05:45 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-12-26 13:18:38 +08:00
|
|
|
|
private void load(OsuColour colours)
|
2017-03-28 14:05:45 +08:00
|
|
|
|
{
|
2017-03-31 10:20:04 +08:00
|
|
|
|
expandingRing.Colour = colours.YellowLight;
|
2017-03-28 14:05:45 +08:00
|
|
|
|
targetRing.BorderColour = colours.YellowDark.Opacity(0.25f);
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-11-09 15:04:56 +08:00
|
|
|
|
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Swell),
|
2020-04-15 15:54:50 +08:00
|
|
|
|
_ => new SwellCirclePiece
|
|
|
|
|
{
|
|
|
|
|
// to allow for rotation transform
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
});
|
2020-04-11 12:14:34 +08:00
|
|
|
|
|
2020-12-15 06:06:22 +08:00
|
|
|
|
protected override void OnFree()
|
2017-08-09 09:54:00 +08:00
|
|
|
|
{
|
2020-12-15 06:06:22 +08:00
|
|
|
|
base.OnFree();
|
|
|
|
|
|
|
|
|
|
UnproxyContent();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-15 06:06:22 +08:00
|
|
|
|
lastWasCentre = null;
|
2017-08-09 09:54:00 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
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);
|
2019-10-17 10:57:00 +08:00
|
|
|
|
|
2019-10-17 11:53:54 +08:00
|
|
|
|
switch (hitObject)
|
2019-10-17 10:57:00 +08:00
|
|
|
|
{
|
|
|
|
|
case DrawableSwellTick tick:
|
2022-06-20 23:22:41 +08:00
|
|
|
|
ticks.Add(tick);
|
2019-10-17 10:57:00 +08:00
|
|
|
|
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();
|
2022-06-20 23:22:41 +08:00
|
|
|
|
ticks.Clear(false);
|
2019-10-17 10:57:00 +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 SwellTick tick:
|
|
|
|
|
return new DrawableSwellTick(tick);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 12:52:21 +08:00
|
|
|
|
return base.CreateNestedHitObject(hitObject);
|
2019-10-17 10:57:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
|
|
|
|
if (userTriggered)
|
|
|
|
|
{
|
2019-10-17 10:57:00 +08:00
|
|
|
|
DrawableSwellTick nextTick = null;
|
|
|
|
|
|
2022-06-20 23:22:41 +08:00
|
|
|
|
foreach (var t in ticks)
|
2019-10-17 10:57:00 +08:00
|
|
|
|
{
|
2020-12-15 07:28:00 +08:00
|
|
|
|
if (!t.Result.HasResult)
|
2019-10-17 10:57:00 +08:00
|
|
|
|
{
|
|
|
|
|
nextTick = t;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-09-29 14:13:11 +08:00
|
|
|
|
nextTick?.TriggerResult(true);
|
2018-08-02 15:09:04 +08:00
|
|
|
|
|
2022-06-20 23:22:41 +08:00
|
|
|
|
int numHits = ticks.Count(r => r.IsHit);
|
|
|
|
|
|
|
|
|
|
float completion = (float)numHits / HitObject.RequiredHits;
|
|
|
|
|
|
|
|
|
|
expandingRing
|
|
|
|
|
.FadeTo(expandingRing.Alpha + Math.Clamp(completion / 16, 0.1f, 0.6f), 50)
|
|
|
|
|
.Then()
|
|
|
|
|
.FadeTo(completion / 8, 2000, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
MainPiece.Drawable.RotateTo((float)(completion * HitObject.Duration / 8), 4000, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-20 23:22:41 +08:00
|
|
|
|
expandingRing.ScaleTo(1f + Math.Min(target_ring_scale - 1f, (target_ring_scale - 1f) * completion * 1.3f), 260, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-08-02 15:09:04 +08:00
|
|
|
|
if (numHits == HitObject.RequiredHits)
|
2022-06-20 23:22:41 +08:00
|
|
|
|
ApplyResult(r => r.Type = r.Judgement.MaxResult);
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-09-06 16:02:13 +08:00
|
|
|
|
if (timeOffset < 0)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-08-02 15:09:04 +08:00
|
|
|
|
int numHits = 0;
|
|
|
|
|
|
2022-06-20 23:22:41 +08:00
|
|
|
|
foreach (var tick in ticks)
|
2018-08-02 15:09:04 +08:00
|
|
|
|
{
|
2018-08-03 15:35:29 +08:00
|
|
|
|
if (tick.IsHit)
|
2018-08-02 15:09:04 +08:00
|
|
|
|
{
|
|
|
|
|
numHits++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-15 07:28:00 +08:00
|
|
|
|
if (!tick.Result.HasResult)
|
|
|
|
|
tick.TriggerResult(false);
|
2018-08-02 15:09:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-30 20:44:44 +08:00
|
|
|
|
ApplyResult(r => r.Type = numHits == HitObject.RequiredHits ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-04 15:19:07 +08:00
|
|
|
|
protected override void UpdateStartTimeStateTransforms()
|
2019-08-27 14:19:16 +08:00
|
|
|
|
{
|
2020-11-04 15:19:07 +08:00
|
|
|
|
base.UpdateStartTimeStateTransforms();
|
2019-08-27 10:03:56 +08:00
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
|
using (BeginDelayedSequence(-ring_appear_offset))
|
2019-08-27 14:19:16 +08:00
|
|
|
|
targetRing.ScaleTo(target_ring_scale, 400, Easing.OutQuint);
|
|
|
|
|
}
|
2019-08-27 10:03:56 +08:00
|
|
|
|
|
2020-11-04 15:19:07 +08:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2017-03-24 14:05:54 +08:00
|
|
|
|
{
|
2019-08-27 10:03:56 +08:00
|
|
|
|
const double transition_duration = 300;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-28 14:05:45 +08:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
2018-06-11 21:32:08 +08:00
|
|
|
|
case ArmedState.Idle:
|
|
|
|
|
expandingRing.FadeTo(0);
|
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-06-11 21:32:08 +08:00
|
|
|
|
case ArmedState.Miss:
|
2017-03-28 14:05:45 +08:00
|
|
|
|
case ArmedState.Hit:
|
2020-11-04 15:19:07 +08:00
|
|
|
|
this.FadeOut(transition_duration, Easing.Out);
|
|
|
|
|
bodyContainer.ScaleTo(1.4f, transition_duration);
|
2017-03-28 14:05:45 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-03-24 14:05:54 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-08-08 15:01:18 +08:00
|
|
|
|
protected override void Update()
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
2017-08-08 15:01:18 +08:00
|
|
|
|
base.Update();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-08-22 19:51:53 +08:00
|
|
|
|
Size = BaseSize * Parent.RelativeChildSize;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-29 08:01:40 +08:00
|
|
|
|
// Make the swell stop at the hit target
|
2018-01-04 20:45:29 +08:00
|
|
|
|
X = Math.Max(0, X);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-08-27 14:21:54 +08:00
|
|
|
|
if (Time.Current >= HitObject.StartTime - ring_appear_offset)
|
2018-06-11 20:45:19 +08:00
|
|
|
|
ProxyContent();
|
2019-08-27 14:19:16 +08:00
|
|
|
|
else
|
|
|
|
|
UnproxyContent();
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-25 14:04:22 +08:00
|
|
|
|
private bool? lastWasCentre;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-09-16 17:26:12 +08:00
|
|
|
|
public override bool OnPressed(KeyBindingPressEvent<TaikoAction> e)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
2017-03-29 15:02:12 +08:00
|
|
|
|
// Don't handle keys before the swell starts
|
|
|
|
|
if (Time.Current < HitObject.StartTime)
|
|
|
|
|
return false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2023-07-13 12:16:58 +08:00
|
|
|
|
if (AllJudged)
|
|
|
|
|
return false;
|
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
|
bool isCentre = e.Action == TaikoAction.LeftCentre || e.Action == TaikoAction.RightCentre;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-25 14:04:22 +08:00
|
|
|
|
// Ensure alternating centre and rim hits
|
|
|
|
|
if (lastWasCentre == isCentre)
|
2017-03-29 14:59:12 +08:00
|
|
|
|
return false;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2017-12-25 14:04:22 +08:00
|
|
|
|
lastWasCentre = isCentre;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
UpdateResult(true);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-17 17:54:44 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|