2017-10-09 18:42:55 +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;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-11-24 13:49:38 +08:00
|
|
|
|
using OpenTK;
|
2017-10-09 18:42:55 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|
|
|
|
{
|
2017-10-10 15:34:01 +08:00
|
|
|
|
public abstract class DrawableCatchHitObject<TObject> : DrawableCatchHitObject
|
2017-11-28 17:37:41 +08:00
|
|
|
|
where TObject : CatchHitObject
|
2017-10-10 15:34:01 +08:00
|
|
|
|
{
|
|
|
|
|
public new TObject HitObject;
|
|
|
|
|
|
|
|
|
|
protected DrawableCatchHitObject(TObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
HitObject = hitObject;
|
2017-11-24 13:49:38 +08:00
|
|
|
|
|
|
|
|
|
Scale = new Vector2(HitObject.Scale);
|
2017-10-10 15:34:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-28 17:37:41 +08:00
|
|
|
|
public abstract class DrawableCatchHitObject : DrawableScrollingHitObject<CatchHitObject>
|
2017-10-09 18:42:55 +08:00
|
|
|
|
{
|
2017-11-28 17:37:41 +08:00
|
|
|
|
protected DrawableCatchHitObject(CatchHitObject hitObject)
|
2017-10-09 18:42:55 +08:00
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
RelativePositionAxes = Axes.Both;
|
|
|
|
|
X = hitObject.X;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
Y = (float)HitObject.StartTime;
|
2017-10-09 18:42:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-28 17:37:41 +08:00
|
|
|
|
public Func<CatchHitObject, bool> CheckPosition;
|
2017-10-09 18:42:55 +08:00
|
|
|
|
|
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
|
|
|
|
{
|
|
|
|
|
if (timeOffset > 0)
|
|
|
|
|
AddJudgement(new Judgement { Result = CheckPosition?.Invoke(HitObject) ?? false ? HitResult.Perfect : HitResult.Miss });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private const float preempt = 1000;
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
using (BeginAbsoluteSequence(HitObject.StartTime - preempt))
|
|
|
|
|
{
|
|
|
|
|
// animation
|
|
|
|
|
this.FadeIn(200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
using (BeginAbsoluteSequence(HitObject.StartTime, true))
|
|
|
|
|
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|