mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 18:12:56 +08:00
modify catch hyperdash behavior
This commit is contained in:
parent
6d6cea19ec
commit
38e5e35743
@ -248,37 +248,46 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
if (validCatch && fruit.HyperDash)
|
if (validCatch && fruit.HyperDash)
|
||||||
{
|
{
|
||||||
HyperDashModifier = Math.Abs(fruit.HyperDashTarget.X - fruit.X) / Math.Abs(fruit.HyperDashTarget.StartTime - fruit.StartTime) / BASE_SPEED;
|
var target = fruit.HyperDashTarget;
|
||||||
HyperDashDirection = fruit.HyperDashTarget.X - fruit.X;
|
double timeDifference = target.StartTime - fruit.StartTime;
|
||||||
|
double positionDifference = target.X * CatchPlayfield.BASE_WIDTH - catcherPosition;
|
||||||
|
double velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0);
|
||||||
|
|
||||||
|
HyperDashing = true;
|
||||||
|
hyperDashModifier = Math.Abs(velocity);
|
||||||
|
hyperDashDirection = (int)Math.Sign(velocity);
|
||||||
|
hyperDashTargetPosition = target.X;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
HyperDashModifier = 1;
|
{
|
||||||
|
HyperDashing = false;
|
||||||
|
}
|
||||||
|
|
||||||
return validCatch;
|
return validCatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double hyperDashModifier = 1;
|
||||||
|
private int hyperDashDirection = 0;
|
||||||
|
private float hyperDashTargetPosition;
|
||||||
|
private bool hyperDashing = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether we are hypderdashing or not.
|
/// Whether we are hypderdashing or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HyperDashing => hyperDashModifier != 1;
|
protected bool HyperDashing
|
||||||
|
|
||||||
private double hyperDashModifier = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The direction in which hyperdash is allowed. 0 allows both directions.
|
|
||||||
/// </summary>
|
|
||||||
public double HyperDashDirection;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The speed modifier resultant from hyperdash. Will trigger hyperdash when not equal to 1.
|
|
||||||
/// </summary>
|
|
||||||
public double HyperDashModifier
|
|
||||||
{
|
{
|
||||||
get { return hyperDashModifier; }
|
get => hyperDashing;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == hyperDashModifier) return;
|
if (hyperDashing == value) return;
|
||||||
hyperDashModifier = value;
|
|
||||||
|
hyperDashing = value;
|
||||||
|
|
||||||
|
if (!HyperDashing)
|
||||||
|
{
|
||||||
|
hyperDashModifier = 1;
|
||||||
|
hyperDashDirection = 0;
|
||||||
|
}
|
||||||
|
|
||||||
const float transition_length = 180;
|
const float transition_length = 180;
|
||||||
|
|
||||||
@ -290,7 +299,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HyperDashDirection = 0;
|
|
||||||
this.FadeColour(Color4.White, transition_length, Easing.OutQuint);
|
this.FadeColour(Color4.White, transition_length, Easing.OutQuint);
|
||||||
this.FadeTo(1, transition_length, Easing.OutQuint);
|
this.FadeTo(1, transition_length, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
@ -347,12 +355,18 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
var direction = Math.Sign(currentDirection);
|
var direction = Math.Sign(currentDirection);
|
||||||
|
|
||||||
double dashModifier = Dashing ? 1 : 0.5;
|
double dashModifier = Dashing ? 1 : 0.5;
|
||||||
|
double speed = BASE_SPEED * dashModifier * hyperDashModifier;
|
||||||
if (hyperDashModifier != 1 && (HyperDashDirection == 0 || direction == Math.Sign(HyperDashDirection)))
|
|
||||||
dashModifier = hyperDashModifier;
|
|
||||||
|
|
||||||
Scale = new Vector2(Math.Abs(Scale.X) * direction, Scale.Y);
|
Scale = new Vector2(Math.Abs(Scale.X) * direction, Scale.Y);
|
||||||
X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1);
|
X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * speed, 0, 1);
|
||||||
|
|
||||||
|
// Correct overshooting.
|
||||||
|
if ((hyperDashDirection > 0 && hyperDashTargetPosition < X) ||
|
||||||
|
(hyperDashDirection < 0 && hyperDashTargetPosition > X))
|
||||||
|
{
|
||||||
|
X = hyperDashTargetPosition;
|
||||||
|
HyperDashing = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user