1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:57:52 +08:00

HyperDashModifier >= 1

This commit is contained in:
ekrctb 2018-06-03 15:29:56 +09:00
parent 9a5624b49e
commit 9f27dd848a

View File

@ -18,6 +18,7 @@ using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using System.Diagnostics;
namespace osu.Game.Rulesets.Catch.UI namespace osu.Game.Rulesets.Catch.UI
{ {
@ -243,14 +244,21 @@ namespace osu.Game.Rulesets.Catch.UI
double positionDifference = target.X * CatchPlayfield.BASE_WIDTH - catcherPosition; double positionDifference = target.X * CatchPlayfield.BASE_WIDTH - catcherPosition;
double velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0); double velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0);
HyperDashing = true; // An edge case
hyperDashModifier = Math.Abs(velocity); if (Math.Abs(velocity) <= 1)
hyperDashDirection = Math.Sign(velocity); {
hyperDashTargetPosition = target.X; HyperDashModifier = 1;
}
else
{
hyperDashDirection = Math.Sign(velocity);
hyperDashTargetPosition = target.X;
HyperDashModifier = Math.Abs(velocity);
}
} }
else else
{ {
HyperDashing = false; HyperDashModifier = 1;
} }
return validCatch; return validCatch;
@ -259,23 +267,27 @@ namespace osu.Game.Rulesets.Catch.UI
private double hyperDashModifier = 1; private double hyperDashModifier = 1;
private int hyperDashDirection; private int hyperDashDirection;
private float hyperDashTargetPosition; private float hyperDashTargetPosition;
private bool hyperDashing;
/// <summary> /// <summary>
/// Whether we are hypderdashing or not. /// Whether we are hypderdashing or not.
/// </summary> /// </summary>
protected bool HyperDashing public bool HyperDashing => hyperDashModifier != 1;
/// <summary>
/// The modifier multiplied to the catcher speed.
/// It is always not less than 1 and it is greater than 1 if and only if the catcher is hyper-dashing.
/// </summary>
protected double HyperDashModifier
{ {
get => hyperDashing; get => hyperDashModifier;
set set
{ {
if (hyperDashing == value) return; Trace.Assert(value >= 1);
if (hyperDashModifier == value) return;
hyperDashing = value; hyperDashModifier = value;
if (!HyperDashing) if (!HyperDashing)
{ {
hyperDashModifier = 1;
hyperDashDirection = 0; hyperDashDirection = 0;
} }
@ -355,7 +367,7 @@ namespace osu.Game.Rulesets.Catch.UI
hyperDashDirection < 0 && hyperDashTargetPosition > X) hyperDashDirection < 0 && hyperDashTargetPosition > X)
{ {
X = hyperDashTargetPosition; X = hyperDashTargetPosition;
HyperDashing = false; HyperDashModifier = 1;
} }
} }