2017-03-20 16:02:06 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2017-03-20 15:50:22 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
using OpenTK.Graphics;
|
2017-05-23 16:36:35 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Framework.Audio.Track;
|
2017-03-20 15:50:22 +08:00
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A circle piece which is used uniformly through osu!taiko to visualise hitobjects.
|
|
|
|
/// <para>
|
2017-04-05 09:01:40 +08:00
|
|
|
/// Note that this can actually be non-circle if the width is changed. See <see cref="ElongatedCirclePiece"/>
|
|
|
|
/// for a usage example.
|
2017-03-20 15:50:22 +08:00
|
|
|
/// </para>
|
|
|
|
/// </summary>
|
2017-04-05 09:01:40 +08:00
|
|
|
public class CirclePiece : TaikoPiece
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-04-10 08:23:00 +08:00
|
|
|
public const float SYMBOL_SIZE = TaikoHitObject.DEFAULT_CIRCLE_DIAMETER * 0.45f;
|
2017-03-28 09:32:01 +08:00
|
|
|
public const float SYMBOL_BORDER = 8;
|
|
|
|
public const float SYMBOL_INNER_SIZE = SYMBOL_SIZE - 2 * SYMBOL_BORDER;
|
2017-05-24 16:15:51 +08:00
|
|
|
private const double pre_beat_transition_time = 80;
|
2017-03-28 09:32:01 +08:00
|
|
|
|
2017-03-20 15:50:22 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The colour of the inner circle and outer glows.
|
|
|
|
/// </summary>
|
2017-04-05 09:01:40 +08:00
|
|
|
public override Color4 AccentColour
|
2017-03-24 17:37:56 +08:00
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
get { return base.AccentColour; }
|
2017-03-24 17:37:56 +08:00
|
|
|
set
|
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
base.AccentColour = value;
|
2017-03-24 17:37:56 +08:00
|
|
|
|
2017-03-30 17:59:00 +08:00
|
|
|
background.Colour = AccentColour;
|
2017-03-24 17:37:56 +08:00
|
|
|
|
|
|
|
resetEdgeEffects();
|
|
|
|
}
|
|
|
|
}
|
2017-03-20 15:50:22 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-24 14:55:25 +08:00
|
|
|
/// Whether Kiai mode effects are enabled for this circle piece.
|
2017-03-20 15:50:22 +08:00
|
|
|
/// </summary>
|
2017-04-05 09:01:40 +08:00
|
|
|
public override bool KiaiMode
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
get { return base.KiaiMode; }
|
2017-03-20 15:50:22 +08:00
|
|
|
set
|
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
base.KiaiMode = value;
|
2017-03-20 15:50:22 +08:00
|
|
|
|
2017-03-24 17:37:56 +08:00
|
|
|
resetEdgeEffects();
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-05 09:01:40 +08:00
|
|
|
protected override Container<Drawable> Content => content;
|
2017-03-24 17:37:56 +08:00
|
|
|
|
2017-04-05 09:01:40 +08:00
|
|
|
private readonly Container content;
|
2017-03-24 19:08:40 +08:00
|
|
|
|
2017-03-30 17:59:00 +08:00
|
|
|
private readonly Container background;
|
2017-03-20 15:50:22 +08:00
|
|
|
|
2017-04-07 15:55:51 +08:00
|
|
|
public Box FlashBox;
|
|
|
|
|
2017-04-05 09:01:40 +08:00
|
|
|
public CirclePiece(bool isStrong = false)
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-05-24 14:40:34 +08:00
|
|
|
EarlyActivationMilliseconds = pre_beat_transition_time;
|
|
|
|
|
2017-04-05 09:01:40 +08:00
|
|
|
AddInternal(new Drawable[]
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
background = new CircularContainer
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
Name = "Background",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
new Box
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
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)
|
2017-03-24 17:37:56 +08:00
|
|
|
}
|
2017-04-05 09:01:40 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
new CircularContainer
|
|
|
|
{
|
|
|
|
Name = "Ring",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
BorderThickness = 8,
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
Masking = true,
|
|
|
|
Children = new[]
|
2017-03-24 17:37:56 +08:00
|
|
|
{
|
2017-04-07 15:55:51 +08:00
|
|
|
FlashBox = new Box
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-04-07 15:55:51 +08:00
|
|
|
Colour = Color4.White,
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
2017-04-05 09:01:40 +08:00
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
|
|
|
}
|
2017-04-05 09:01:40 +08:00
|
|
|
},
|
|
|
|
content = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-04-05 12:53:07 +08:00
|
|
|
Name = "Content",
|
2017-04-05 09:01:40 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2017-03-24 17:37:56 +08:00
|
|
|
}
|
|
|
|
});
|
2017-03-20 15:50:22 +08:00
|
|
|
|
2017-04-05 09:01:40 +08:00
|
|
|
if (isStrong)
|
|
|
|
{
|
2017-04-10 08:23:00 +08:00
|
|
|
Size *= TaikoHitObject.STRONG_CIRCLE_DIAMETER_SCALE;
|
2017-04-05 09:01:40 +08:00
|
|
|
|
2017-04-05 12:53:07 +08:00
|
|
|
//default for symbols etc.
|
2017-04-10 08:23:00 +08:00
|
|
|
Content.Scale *= TaikoHitObject.STRONG_CIRCLE_DIAMETER_SCALE;
|
2017-04-05 09:01:40 +08:00
|
|
|
}
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
|
|
|
|
2017-04-05 15:27:59 +08:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
//we want to allow for width of content to remain mapped to the area inside us, regardless of the scale applied above.
|
|
|
|
Content.Width = 1 / Content.Scale.X;
|
|
|
|
}
|
|
|
|
|
2017-05-24 16:15:51 +08:00
|
|
|
private const float edge_alpha_kiai = 0.5f;
|
|
|
|
|
2017-03-24 17:37:56 +08:00
|
|
|
private void resetEdgeEffects()
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-30 17:59:00 +08:00
|
|
|
background.EdgeEffect = new EdgeEffect
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
2017-05-24 16:15:51 +08:00
|
|
|
Colour = AccentColour.Opacity(KiaiMode ? edge_alpha_kiai : 1f),
|
|
|
|
Radius = KiaiMode ? 32 : 8
|
2017-03-20 15:50:22 +08:00
|
|
|
};
|
|
|
|
}
|
2017-05-23 16:36:35 +08:00
|
|
|
|
|
|
|
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
|
|
|
{
|
|
|
|
if (!effectPoint.KiaiMode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (beatIndex % (int)timingPoint.TimeSignature != 0)
|
|
|
|
return;
|
|
|
|
|
2017-05-24 16:15:51 +08:00
|
|
|
double duration = timingPoint.BeatLength * 2;
|
2017-05-24 14:40:34 +08:00
|
|
|
|
2017-05-24 16:15:51 +08:00
|
|
|
background.FadeEdgeEffectTo(1, pre_beat_transition_time, EasingTypes.OutQuint);
|
2017-05-24 14:40:34 +08:00
|
|
|
using (background.BeginDelayedSequence(pre_beat_transition_time))
|
2017-05-24 16:15:51 +08:00
|
|
|
background.FadeEdgeEffectTo(edge_alpha_kiai, duration, EasingTypes.OutQuint);
|
2017-05-23 16:36:35 +08:00
|
|
|
}
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
|
|
|
}
|