1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 02:27:25 +08:00
osu-lazer/osu.Game.Modes.Taiko/Objects/Drawables/DrawableHit.cs

95 lines
3.0 KiB
C#
Raw Normal View History

2017-03-20 17:25:12 +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
2017-04-04 11:38:55 +08:00
using System;
using System.Linq;
2017-03-28 09:33:23 +08:00
using osu.Framework.Graphics;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
2017-04-04 11:38:55 +08:00
using OpenTK.Input;
2017-04-04 11:38:55 +08:00
namespace osu.Game.Modes.Taiko.Objects.Drawables
{
public abstract class DrawableHit : DrawableTaikoHitObject<Hit>
{
/// <summary>
/// A list of keys which can result in hits for this HitObject.
/// </summary>
2017-03-29 14:35:22 +08:00
protected abstract Key[] HitKeys { get; }
/// <summary>
/// Whether the last key pressed is a valid hit key.
/// </summary>
private bool validKeyPressed;
2017-03-24 13:59:59 +08:00
protected DrawableHit(Hit hit)
: base(hit)
{
}
protected override void CheckJudgement(bool userTriggered)
{
if (!userTriggered)
{
if (Judgement.TimeOffset > HitObject.HitWindowGood)
Judgement.Result = HitResult.Miss;
return;
}
double hitOffset = Math.Abs(Judgement.TimeOffset);
if (hitOffset > HitObject.HitWindowMiss)
return;
if (!validKeyPressed)
Judgement.Result = HitResult.Miss;
else if (hitOffset < HitObject.HitWindowGood)
{
Judgement.Result = HitResult.Hit;
Judgement.TaikoResult = hitOffset < HitObject.HitWindowGreat ? TaikoHitResult.Great : TaikoHitResult.Good;
}
else
Judgement.Result = HitResult.Miss;
}
protected override bool HandleKeyPress(Key key)
{
if (Judgement.Result != HitResult.None)
return false;
validKeyPressed = HitKeys.Contains(key);
return UpdateJudgement(true);
}
2017-03-28 09:33:23 +08:00
protected override void UpdateState(ArmedState state)
{
Delay(HitObject.StartTime - Time.Current + Judgement.TimeOffset, true);
2017-03-28 09:33:23 +08:00
switch (State)
{
case ArmedState.Idle:
Delay(HitObject.HitWindowMiss);
2017-03-28 09:33:23 +08:00
break;
case ArmedState.Miss:
2017-03-29 08:11:07 +08:00
FadeOut(100);
2017-03-28 09:33:23 +08:00
break;
case ArmedState.Hit:
2017-03-29 08:11:07 +08:00
FadeOut(600);
const float gravity_time = 300;
const float gravity_travel_height = 200;
Content.ScaleTo(0.8f, gravity_time * 2, EasingTypes.OutQuad);
MoveToY(-gravity_travel_height, gravity_time, EasingTypes.Out);
Delay(gravity_time, true);
MoveToY(gravity_travel_height * 2, gravity_time * 2, EasingTypes.In);
2017-03-28 09:33:23 +08:00
break;
}
Expire();
2017-03-28 09:33:23 +08:00
}
}
}