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.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets.Mania.Judgements;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|
|
|
{
|
|
|
|
public class DrawableHoldNoteTick : DrawableManiaHitObject<HoldNoteTick>
|
|
|
|
{
|
|
|
|
public Func<double> HoldStartTime;
|
|
|
|
public Func<bool> IsHolding;
|
|
|
|
|
2017-05-24 20:24:18 +08:00
|
|
|
private readonly Container glowContainer;
|
|
|
|
|
2017-05-24 19:45:01 +08:00
|
|
|
public DrawableHoldNoteTick(HoldNoteTick hitObject)
|
|
|
|
: base(hitObject, null)
|
|
|
|
{
|
2017-05-24 20:24:18 +08:00
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
AccentColour = Color4.White;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Color4 AccentColour
|
|
|
|
{
|
|
|
|
get { return base.AccentColour; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
base.AccentColour = value;
|
|
|
|
|
|
|
|
glowContainer.EdgeEffect = new EdgeEffect
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Radius = 2f,
|
|
|
|
Roundness = 15f,
|
|
|
|
Colour = value.Opacity(0.3f)
|
|
|
|
};
|
|
|
|
}
|
2017-05-24 19:45:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override ManiaJudgement CreateJudgement() => new HoldNoteTickJudgement();
|
|
|
|
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
{
|
|
|
|
if (!userTriggered)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Time.Current < HitObject.StartTime)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (HoldStartTime?.Invoke() > HitObject.StartTime)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Judgement.ManiaResult = ManiaHitResult.Perfect;
|
|
|
|
Judgement.Result = HitResult.Hit;
|
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
if (Judgement.Result != HitResult.None)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (IsHolding?.Invoke() != true)
|
|
|
|
return;
|
|
|
|
|
|
|
|
UpdateJudgement(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|