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