2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-10-09 18:42:55 +08:00
|
|
|
|
// 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;
|
2018-01-12 20:46:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2017-11-24 13:49:38 +08:00
|
|
|
|
using OpenTK;
|
2017-12-31 04:23:18 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2017-10-09 18:42:55 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|
|
|
|
{
|
2018-01-11 20:49:20 +08:00
|
|
|
|
public abstract class PalpableCatchHitObject<TObject> : DrawableCatchHitObject<TObject>
|
|
|
|
|
where TObject : CatchHitObject
|
|
|
|
|
{
|
2018-01-12 20:46:50 +08:00
|
|
|
|
public override bool CanBePlated => true;
|
|
|
|
|
|
2018-01-11 20:49:20 +08:00
|
|
|
|
protected PalpableCatchHitObject(TObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
Scale = new Vector2(HitObject.Scale);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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;
|
2018-01-11 19:55:43 +08:00
|
|
|
|
Anchor = Anchor.BottomLeft;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 17:50:17 +08:00
|
|
|
|
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
|
2017-10-09 18:42:55 +08:00
|
|
|
|
{
|
2018-01-12 20:46:50 +08:00
|
|
|
|
public virtual bool CanBePlated => false;
|
|
|
|
|
|
2017-11-28 17:37:41 +08:00
|
|
|
|
protected DrawableCatchHitObject(CatchHitObject hitObject)
|
2017-10-09 18:42:55 +08:00
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
2018-01-04 17:50:17 +08:00
|
|
|
|
RelativePositionAxes = Axes.X;
|
2017-10-09 18:42:55 +08:00
|
|
|
|
X = hitObject.X;
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2018-01-12 20:46:50 +08:00
|
|
|
|
if (CheckPosition == null) return;
|
|
|
|
|
|
2017-10-09 18:42:55 +08:00
|
|
|
|
if (timeOffset > 0)
|
2018-01-12 20:46:50 +08:00
|
|
|
|
AddJudgement(new Judgement { Result = (bool)CheckPosition?.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss });
|
2017-10-09 18:42:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private const float preempt = 1000;
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
using (BeginAbsoluteSequence(HitObject.StartTime - preempt))
|
|
|
|
|
this.FadeIn(200);
|
|
|
|
|
|
2018-01-12 20:46:50 +08:00
|
|
|
|
var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
|
|
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(endTime, true))
|
2017-10-09 18:42:55 +08:00
|
|
|
|
{
|
2018-01-12 20:46:50 +08:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out).Expire();
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
this.FadeOut().Expire();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-10-09 18:42:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|