1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-29 08:07:39 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs

74 lines
2.2 KiB
C#
Raw Normal View History

// 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;
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.UI;
2020-11-04 15:19:07 +08:00
using osu.Game.Rulesets.Objects.Drawables;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Catch.Objects.Drawables
2018-04-13 17:19:50 +08:00
{
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
{
public readonly Bindable<float> XBindable = new Bindable<float>();
protected override double InitialLifetimeOffset => HitObject.TimePreempt;
public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;
protected override float SamplePlaybackPosition => HitObject.X / CatchPlayfield.WIDTH;
2018-04-13 17:19:50 +08:00
protected DrawableCatchHitObject(CatchHitObject hitObject)
: base(hitObject)
{
if (hitObject != null)
XBindable.Value = hitObject.X;
Anchor = Anchor.BottomLeft;
2018-04-13 17:19:50 +08:00
}
protected override void OnApply()
{
base.OnApply();
XBindable.BindTo(HitObject.XBindable);
}
protected override void OnFree()
{
base.OnFree();
XBindable.UnbindFrom(HitObject.XBindable);
}
2018-04-13 17:19:50 +08:00
public Func<CatchHitObject, bool> CheckPosition;
public bool IsOnPlate;
public override bool RemoveWhenNotAlive => IsOnPlate;
protected override void CheckForResult(bool userTriggered, double timeOffset)
2018-04-13 17:19:50 +08:00
{
if (CheckPosition == null) return;
if (timeOffset >= 0 && Result != null)
2020-09-29 13:26:36 +08:00
ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? r.Judgement.MaxResult : r.Judgement.MinResult);
2018-04-13 17:19:50 +08:00
}
2020-11-04 15:19:07 +08:00
protected override void UpdateHitStateTransforms(ArmedState state)
{
2020-11-04 15:19:07 +08:00
switch (state)
2018-04-13 17:19:50 +08:00
{
2020-11-04 15:19:07 +08:00
case ArmedState.Miss:
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
break;
2019-04-01 11:44:46 +08:00
2020-11-04 15:19:07 +08:00
case ArmedState.Hit:
this.FadeOut();
break;
2018-04-13 17:19:50 +08:00
}
}
}
}