2017-03-17 17:54:44 +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
|
|
|
|
|
|
|
|
|
|
using OpenTK.Input;
|
|
|
|
|
using osu.Game.Modes.Objects.Drawables;
|
|
|
|
|
using osu.Game.Modes.Taiko.Judgements;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|
|
|
|
{
|
2017-03-25 19:57:49 +08:00
|
|
|
|
public class DrawableSwell : DrawableTaikoHitObject
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-03-25 19:57:49 +08:00
|
|
|
|
/// The amount of times the user has hit this swell.
|
2017-03-17 17:54:44 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
private int userHits;
|
|
|
|
|
|
2017-03-25 19:57:49 +08:00
|
|
|
|
private readonly Swell swell;
|
2017-03-17 18:25:55 +08:00
|
|
|
|
|
2017-03-25 19:57:49 +08:00
|
|
|
|
public DrawableSwell(Swell swell)
|
|
|
|
|
: base(swell)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
2017-03-25 19:57:49 +08:00
|
|
|
|
this.swell = swell;
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (Time.Current < HitObject.StartTime)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
userHits++;
|
|
|
|
|
|
2017-03-25 19:57:49 +08:00
|
|
|
|
if (userHits == swell.RequiredHits)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
|
|
|
|
Judgement.Result = HitResult.Hit;
|
2017-03-22 00:55:31 +08:00
|
|
|
|
Judgement.TaikoResult = TaikoHitResult.Great;
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Judgement.TimeOffset < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-03-25 19:57:49 +08:00
|
|
|
|
if (userHits > swell.RequiredHits / 2)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
|
|
|
|
Judgement.Result = HitResult.Hit;
|
2017-03-22 00:55:31 +08:00
|
|
|
|
Judgement.TaikoResult = TaikoHitResult.Good;
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-24 14:05:54 +08:00
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 00:55:41 +08:00
|
|
|
|
protected override void UpdateScrollPosition(double time)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
2017-03-22 00:55:41 +08:00
|
|
|
|
base.UpdateScrollPosition(Math.Min(time, HitObject.StartTime));
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-25 22:48:13 +08:00
|
|
|
|
protected override bool HandleKeyPress(Key key)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
|
|
|
|
if (Judgement.Result.HasValue)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
UpdateJudgement(true);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|