2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|
|
|
|
{
|
|
|
|
|
public abstract class PalpableCatchHitObject<TObject> : DrawableCatchHitObject<TObject>
|
|
|
|
|
where TObject : CatchHitObject
|
|
|
|
|
{
|
|
|
|
|
public override bool CanBePlated => true;
|
|
|
|
|
|
|
|
|
|
protected PalpableCatchHitObject(TObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
Scale = new Vector2(HitObject.Scale);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class DrawableCatchHitObject<TObject> : DrawableCatchHitObject
|
|
|
|
|
where TObject : CatchHitObject
|
|
|
|
|
{
|
|
|
|
|
public new TObject HitObject;
|
|
|
|
|
|
|
|
|
|
protected DrawableCatchHitObject(TObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
HitObject = hitObject;
|
|
|
|
|
Anchor = Anchor.BottomLeft;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
|
|
|
|
|
{
|
|
|
|
|
public virtual bool CanBePlated => false;
|
|
|
|
|
|
2018-06-15 14:44:47 +08:00
|
|
|
|
public virtual bool StaysOnPlate => CanBePlated;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected DrawableCatchHitObject(CatchHitObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
RelativePositionAxes = Axes.X;
|
|
|
|
|
X = hitObject.X;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Func<CatchHitObject, bool> CheckPosition;
|
|
|
|
|
|
2019-09-07 23:10:31 +08:00
|
|
|
|
public bool IsOnPlate;
|
|
|
|
|
|
|
|
|
|
public override bool RemoveWhenNotAlive => IsOnPlate;
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
if (CheckPosition == null) return;
|
|
|
|
|
|
2018-08-03 14:38:48 +08:00
|
|
|
|
if (timeOffset >= 0 && Result != null)
|
|
|
|
|
ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-26 20:15:23 +08:00
|
|
|
|
protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;
|
2019-07-22 14:55:38 +08:00
|
|
|
|
|
2019-08-28 17:12:47 +08:00
|
|
|
|
protected override void UpdateInitialTransforms() => this.FadeInFromZero(200);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-08-26 20:15:23 +08:00
|
|
|
|
protected override void UpdateStateTransforms(ArmedState state)
|
|
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
|
|
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(endTime, true))
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Miss:
|
2019-09-12 18:29:08 +08:00
|
|
|
|
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case ArmedState.Hit:
|
2019-09-12 18:29:08 +08:00
|
|
|
|
this.FadeOut();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|