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-10-20 05:31:23 +08:00
|
|
|
using osu.Framework.Allocation;
|
2020-06-23 12:49:18 +08:00
|
|
|
using osu.Framework.Audio.Track;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-12-07 11:30:25 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2020-04-15 15:54:50 +08:00
|
|
|
using osu.Game.Graphics;
|
2020-12-07 11:30:25 +08:00
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2020-04-11 12:33:19 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2022-10-20 05:31:23 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2022-04-03 05:21:23 +08:00
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
2020-12-07 11:30:25 +08:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-12-07 11:30:25 +08:00
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning.Default
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A circle piece which is used uniformly through osu!taiko to visualise hitobjects.
|
|
|
|
/// <para>
|
|
|
|
/// Note that this can actually be non-circle if the width is changed. See <see cref="ElongatedCirclePiece"/>
|
|
|
|
/// for a usage example.
|
|
|
|
/// </para>
|
|
|
|
/// </summary>
|
2020-04-15 15:54:50 +08:00
|
|
|
public abstract class CirclePiece : BeatSyncedContainer, IHasAccentColour
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2022-04-03 05:21:23 +08:00
|
|
|
public const float SYMBOL_SIZE = TaikoHitObject.DEFAULT_SIZE;
|
2018-04-13 17:19:50 +08:00
|
|
|
public const float SYMBOL_BORDER = 8;
|
2022-04-03 05:21:23 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
private const double pre_beat_transition_time = 80;
|
|
|
|
|
2022-10-19 05:55:40 +08:00
|
|
|
private const float flash_opacity = 0.3f;
|
|
|
|
|
2022-11-09 12:36:46 +08:00
|
|
|
[Resolved]
|
|
|
|
private DrawableHitObject drawableHitObject { get; set; } = null!;
|
|
|
|
|
2020-04-11 12:33:19 +08:00
|
|
|
private Color4 accentColour;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The colour of the inner circle and outer glows.
|
|
|
|
/// </summary>
|
2020-04-11 12:33:19 +08:00
|
|
|
public Color4 AccentColour
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2020-04-11 12:33:19 +08:00
|
|
|
get => accentColour;
|
2018-04-13 17:19:50 +08:00
|
|
|
set
|
|
|
|
{
|
2020-04-11 12:33:19 +08:00
|
|
|
accentColour = value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
background.Colour = AccentColour;
|
|
|
|
|
|
|
|
resetEdgeEffects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-11 12:33:19 +08:00
|
|
|
private bool kiaiMode;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether Kiai mode effects are enabled for this circle piece.
|
|
|
|
/// </summary>
|
2020-04-11 12:33:19 +08:00
|
|
|
public bool KiaiMode
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2020-04-11 12:33:19 +08:00
|
|
|
get => kiaiMode;
|
2018-04-13 17:19:50 +08:00
|
|
|
set
|
|
|
|
{
|
2020-04-11 12:33:19 +08:00
|
|
|
kiaiMode = value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
resetEdgeEffects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
private readonly Container background;
|
|
|
|
|
2022-11-08 14:19:08 +08:00
|
|
|
private readonly Box flashBox;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-04-12 16:40:22 +08:00
|
|
|
protected CirclePiece()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2020-04-11 12:41:14 +08:00
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
EarlyActivationMilliseconds = pre_beat_transition_time;
|
|
|
|
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
|
|
{
|
|
|
|
background = new CircularContainer
|
|
|
|
{
|
|
|
|
Name = "Background",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new Triangles
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ColourLight = Color4.White,
|
|
|
|
ColourDark = Color4.White.Darken(0.1f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new CircularContainer
|
|
|
|
{
|
|
|
|
Name = "Ring",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
BorderThickness = 8,
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
Masking = true,
|
|
|
|
Children = new[]
|
|
|
|
{
|
2022-11-08 14:19:08 +08:00
|
|
|
flashBox = new Box
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.White,
|
2019-08-21 12:29:50 +08:00
|
|
|
Blending = BlendingParameters.Additive,
|
2018-04-13 17:19:50 +08:00
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
content = new Container
|
|
|
|
{
|
|
|
|
Name = "Content",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-11-08 14:19:08 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
drawableHitObject.ApplyCustomUpdateState += updateStateTransforms;
|
|
|
|
updateStateTransforms(drawableHitObject, drawableHitObject.State.Value);
|
|
|
|
}
|
|
|
|
|
2022-11-15 17:22:27 +08:00
|
|
|
private void updateStateTransforms(DrawableHitObject h, ArmedState state)
|
2022-11-08 14:19:08 +08:00
|
|
|
{
|
2022-11-15 17:22:27 +08:00
|
|
|
if (h.HitObject is not Hit)
|
|
|
|
return;
|
|
|
|
|
2022-11-08 14:19:08 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case ArmedState.Hit:
|
2022-11-15 17:22:27 +08:00
|
|
|
using (BeginAbsoluteSequence(h.HitStateUpdateTime))
|
2022-11-10 21:31:24 +08:00
|
|
|
flashBox.FadeTo(0.9f).FadeOut(300);
|
2022-11-08 14:19:08 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
private const float edge_alpha_kiai = 0.5f;
|
|
|
|
|
|
|
|
private void resetEdgeEffects()
|
|
|
|
{
|
|
|
|
background.EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = AccentColour.Opacity(KiaiMode ? edge_alpha_kiai : 1f),
|
|
|
|
Radius = KiaiMode ? 32 : 8
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-06-23 12:49:18 +08:00
|
|
|
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
if (!effectPoint.KiaiMode)
|
|
|
|
return;
|
|
|
|
|
2022-10-20 05:31:23 +08:00
|
|
|
if (drawableHitObject.State.Value == ArmedState.Idle)
|
|
|
|
{
|
2022-11-08 14:19:08 +08:00
|
|
|
flashBox
|
2022-10-20 05:31:23 +08:00
|
|
|
.FadeTo(flash_opacity)
|
|
|
|
.Then()
|
2022-10-21 14:34:25 +08:00
|
|
|
.FadeOut(timingPoint.BeatLength * 0.75, Easing.OutSine);
|
2022-10-20 05:31:23 +08:00
|
|
|
}
|
2022-10-19 05:55:40 +08:00
|
|
|
|
2022-01-23 00:27:27 +08:00
|
|
|
if (beatIndex % timingPoint.TimeSignature.Numerator != 0)
|
2018-04-13 17:19:50 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
double duration = timingPoint.BeatLength * 2;
|
|
|
|
|
|
|
|
background
|
|
|
|
.FadeEdgeEffectTo(1, pre_beat_transition_time, Easing.OutQuint)
|
|
|
|
.Then()
|
|
|
|
.FadeEdgeEffectTo(edge_alpha_kiai, duration, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|