1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 12:45:09 +08:00

don't expose HyperDashModifier directly

This commit is contained in:
ekrctb 2018-06-20 20:08:27 +09:00
parent 79c5596b27
commit 9194fd8dfe
2 changed files with 26 additions and 35 deletions

View File

@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Catch.Tests
{ {
} }
public void ToggleHyperDash(bool status) => MovableCatcher.HyperDashModifier = status ? 2 : 1; public void ToggleHyperDash(bool status) => MovableCatcher.SetHyperdashState(status ? 2 : 1);
} }
} }
} }

View File

@ -18,7 +18,6 @@ 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
{ {
@ -250,21 +249,11 @@ 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);
// An edge case SetHyperdashState(Math.Abs(velocity), target.X);
if (Math.Abs(velocity) <= 1)
{
HyperDashModifier = 1;
}
else
{
hyperDashDirection = Math.Sign(velocity);
hyperDashTargetPosition = target.X;
HyperDashModifier = Math.Abs(velocity);
}
} }
else else
{ {
HyperDashModifier = 1; SetHyperdashState();
} }
return validCatch; return validCatch;
@ -279,37 +268,39 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary> /// </summary>
public bool HyperDashing => hyperDashModifier != 1; public bool HyperDashing => hyperDashModifier != 1;
private const float hyperdash_transition_length = 180;
/// <summary> /// <summary>
/// The modifier multiplied to the catcher speed. /// Set hyperdash state.
/// It is always not less than 1 and it is greater than 1 if and only if the catcher is hyper-dashing.
/// </summary> /// </summary>
public double HyperDashModifier /// <param name="modifier">The speed multiplier. If this is less or equals to 1, this catcher will be non-hyperdashing state.</param>
/// <param name="targetPosition">When this catcher crosses this position, this catcher ends hyperdashing.</param>
public void SetHyperdashState(double modifier = 1, float targetPosition = -1)
{ {
get => hyperDashModifier; bool previouslyHyperDashing = HyperDashing;
set if (modifier <= 1 || X == targetPosition)
{ {
Trace.Assert(value >= 1); hyperDashModifier = 1;
if (hyperDashModifier == value) return; hyperDashDirection = 0;
hyperDashModifier = value;
if (!HyperDashing) if (previouslyHyperDashing)
{ {
hyperDashDirection = 0; this.FadeColour(Color4.White, hyperdash_transition_length, Easing.OutQuint);
this.FadeTo(1, hyperdash_transition_length, Easing.OutQuint);
} }
}
else
{
hyperDashModifier = modifier;
hyperDashDirection = Math.Sign(targetPosition - X);
hyperDashTargetPosition = targetPosition;
const float transition_length = 180; if (!previouslyHyperDashing)
if (HyperDashing)
{ {
this.FadeColour(Color4.OrangeRed, transition_length, Easing.OutQuint); this.FadeColour(Color4.OrangeRed, hyperdash_transition_length, Easing.OutQuint);
this.FadeTo(0.2f, transition_length, Easing.OutQuint); this.FadeTo(0.2f, hyperdash_transition_length, Easing.OutQuint);
Trail = true; Trail = true;
} }
else
{
this.FadeColour(Color4.White, transition_length, Easing.OutQuint);
this.FadeTo(1, transition_length, Easing.OutQuint);
}
} }
} }
@ -373,7 +364,7 @@ namespace osu.Game.Rulesets.Catch.UI
hyperDashDirection < 0 && hyperDashTargetPosition > X) hyperDashDirection < 0 && hyperDashTargetPosition > X)
{ {
X = hyperDashTargetPosition; X = hyperDashTargetPosition;
HyperDashModifier = 1; SetHyperdashState();
} }
} }