2017-05-24 11:45:01 +00:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System;
|
2017-05-24 12:24:18 +00:00
|
|
|
using OpenTK;
|
2017-05-24 11:45:01 +00:00
|
|
|
using OpenTK.Graphics;
|
2017-05-24 12:24:18 +00:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-05-24 11:45:01 +00:00
|
|
|
using osu.Framework.Graphics;
|
2017-05-24 12:24:18 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-05-24 11:45:01 +00:00
|
|
|
using osu.Game.Rulesets.Mania.Judgements;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-06-20 05:54:23 +00:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-05-24 11:45:01 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|
|
|
{
|
2017-05-24 12:57:38 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Visualises a <see cref="HoldNoteTick"/> hit object.
|
|
|
|
/// </summary>
|
2017-05-24 11:45:01 +00:00
|
|
|
public class DrawableHoldNoteTick : DrawableManiaHitObject<HoldNoteTick>
|
|
|
|
{
|
2017-05-24 12:57:38 +00:00
|
|
|
/// <summary>
|
|
|
|
/// References the time at which the user started holding the hold note.
|
|
|
|
/// </summary>
|
2017-05-26 09:56:21 +00:00
|
|
|
public Func<double?> HoldStartTime;
|
2017-05-24 12:57:38 +00:00
|
|
|
|
2017-05-24 12:24:18 +00:00
|
|
|
private readonly Container glowContainer;
|
|
|
|
|
2017-05-24 11:45:01 +00:00
|
|
|
public DrawableHoldNoteTick(HoldNoteTick hitObject)
|
2017-05-24 12:25:01 +00:00
|
|
|
: base(hitObject)
|
2017-05-24 11:45:01 +00:00
|
|
|
{
|
2017-05-24 12:24:18 +00:00
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
|
2017-09-10 19:45:10 +00:00
|
|
|
Y = (float)HitObject.StartTime;
|
|
|
|
|
2017-05-24 11:45:01 +00:00
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-05-24 12:24:18 +00:00
|
|
|
Size = new Vector2(1);
|
2017-05-24 11:45:01 +00:00
|
|
|
|
2017-09-10 19:45:10 +00:00
|
|
|
// Life time managed by the parent DrawableHoldNote
|
|
|
|
LifetimeStart = double.MinValue;
|
|
|
|
LifetimeEnd = double.MaxValue;
|
|
|
|
|
2017-05-24 11:45:01 +00:00
|
|
|
Children = new[]
|
|
|
|
{
|
2017-05-24 12:24:18 +00:00
|
|
|
glowContainer = new CircularContainer
|
2017-05-24 11:45:01 +00:00
|
|
|
{
|
2017-05-24 12:24:18 +00:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true
|
|
|
|
}
|
|
|
|
}
|
2017-05-24 11:45:01 +00:00
|
|
|
}
|
|
|
|
};
|
2017-05-24 12:24:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Color4 AccentColour
|
|
|
|
{
|
|
|
|
get { return base.AccentColour; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
base.AccentColour = value;
|
|
|
|
|
2017-06-12 03:48:47 +00:00
|
|
|
glowContainer.EdgeEffect = new EdgeEffectParameters
|
2017-05-24 12:24:18 +00:00
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Radius = 2f,
|
|
|
|
Roundness = 15f,
|
|
|
|
Colour = value.Opacity(0.3f)
|
|
|
|
};
|
|
|
|
}
|
2017-05-24 11:45:01 +00:00
|
|
|
}
|
|
|
|
|
2017-09-06 08:02:13 +00:00
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
2017-05-24 11:45:01 +00:00
|
|
|
{
|
|
|
|
if (!userTriggered)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Time.Current < HitObject.StartTime)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (HoldStartTime?.Invoke() > HitObject.StartTime)
|
|
|
|
return;
|
|
|
|
|
2017-09-12 14:36:51 +00:00
|
|
|
AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect });
|
2017-05-24 11:45:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
{
|
|
|
|
switch (State)
|
|
|
|
{
|
|
|
|
case ArmedState.Hit:
|
2017-05-24 12:24:18 +00:00
|
|
|
AccentColour = Color4.Green;
|
2017-05-24 11:45:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
2017-09-12 08:37:37 +00:00
|
|
|
if (AllJudged)
|
2017-05-24 11:45:01 +00:00
|
|
|
return;
|
|
|
|
|
2017-09-10 19:51:44 +00:00
|
|
|
if (HoldStartTime?.Invoke() == null)
|
2017-05-24 11:45:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
UpdateJudgement(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|