1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-19 19:43:05 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs

94 lines
3.1 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// Copyright (c) 2007-2018 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;
2018-01-12 20:46:50 +08:00
using osu.Game.Rulesets.Objects.Types;
2017-11-24 13:49:38 +08:00
using OpenTK;
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
public abstract class PalpableCatchHitObject<TObject> : DrawableCatchHitObject<TObject>
where TObject : CatchHitObject
{
2018-01-12 20:46:50 +08:00
public override bool CanBePlated => true;
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
where TObject : CatchHitObject
2017-10-10 15:34:01 +08:00
{
public new TObject HitObject;
protected DrawableCatchHitObject(TObject hitObject)
: base(hitObject)
{
HitObject = hitObject;
Anchor = Anchor.BottomLeft;
2017-10-10 15:34:01 +08:00
}
}
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
{
2018-01-12 20:46:50 +08:00
public virtual bool CanBePlated => false;
protected DrawableCatchHitObject(CatchHitObject hitObject)
: base(hitObject)
{
RelativePositionAxes = Axes.X;
X = hitObject.X;
}
public Func<CatchHitObject, bool> CheckPosition;
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{
2018-01-12 20:46:50 +08:00
if (CheckPosition == null) return;
if (timeOffset >= 0)
2018-01-12 23:51:20 +08:00
AddJudgement(new Judgement { Result = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss });
}
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
{
base.SkinChanged(skin, allowFallback);
if (HitObject is IHasComboInformation combo)
AccentColour = skin.GetValue<SkinConfiguration, Color4>(s => s.ComboColours.Count > 0 ? s.ComboColours[combo.ComboIndex % s.ComboColours.Count] : (Color4?)null) ?? Color4.White;
}
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))
{
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;
}
}
}
}
}