mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add hyperdash visual testing to TestCaseCatcherArea
Also tidies up hyperdash state logic
This commit is contained in:
@ -17,6 +17,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
internal class TestCaseCatcherArea : OsuTestCase
|
internal class TestCaseCatcherArea : OsuTestCase
|
||||||
{
|
{
|
||||||
private RulesetInfo catchRuleset;
|
private RulesetInfo catchRuleset;
|
||||||
|
private TestCatcherArea catcherArea;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
@ -26,6 +27,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
public TestCaseCatcherArea()
|
public TestCaseCatcherArea()
|
||||||
{
|
{
|
||||||
AddSliderStep<float>("CircleSize", 0, 8, 5, createCatcher);
|
AddSliderStep<float>("CircleSize", 0, 8, 5, createCatcher);
|
||||||
|
AddToggleStep("Hyperdash", t => catcherArea.ToggleHyperDash(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCatcher(float size)
|
private void createCatcher(float size)
|
||||||
@ -33,7 +35,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
Child = new CatchInputManager(catchRuleset)
|
Child = new CatchInputManager(catchRuleset)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = new CatcherArea(new BeatmapDifficulty { CircleSize = size })
|
Child = catcherArea = new TestCatcherArea(new BeatmapDifficulty { CircleSize = size })
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.BottomLeft
|
Origin = Anchor.BottomLeft
|
||||||
@ -46,5 +48,15 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
catchRuleset = rulesets.GetRuleset(2);
|
catchRuleset = rulesets.GetRuleset(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestCatcherArea : CatcherArea
|
||||||
|
{
|
||||||
|
public TestCatcherArea(BeatmapDifficulty beatmapDifficulty)
|
||||||
|
: base(beatmapDifficulty)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ToggleHyperDash(bool status) => MovableCatcher.HyperDashModifier = status ? 2 : 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,18 +22,18 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
public const float CATCHER_SIZE = 172;
|
public const float CATCHER_SIZE = 172;
|
||||||
|
|
||||||
private readonly Catcher catcher;
|
protected readonly Catcher MovableCatcher;
|
||||||
|
|
||||||
public Container ExplodingFruitTarget
|
public Container ExplodingFruitTarget
|
||||||
{
|
{
|
||||||
set { catcher.ExplodingFruitTarget = value; }
|
set { MovableCatcher.ExplodingFruitTarget = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public CatcherArea(BeatmapDifficulty difficulty = null)
|
public CatcherArea(BeatmapDifficulty difficulty = null)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = CATCHER_SIZE;
|
Height = CATCHER_SIZE;
|
||||||
Child = catcher = new Catcher(difficulty)
|
Child = MovableCatcher = new Catcher(difficulty)
|
||||||
{
|
{
|
||||||
AdditiveTarget = this,
|
AdditiveTarget = this,
|
||||||
};
|
};
|
||||||
@ -42,17 +42,17 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
public void Add(DrawableHitObject fruit, Vector2 absolutePosition)
|
public void Add(DrawableHitObject fruit, Vector2 absolutePosition)
|
||||||
{
|
{
|
||||||
fruit.RelativePositionAxes = Axes.None;
|
fruit.RelativePositionAxes = Axes.None;
|
||||||
fruit.Position = new Vector2(catcher.ToLocalSpace(absolutePosition).X - catcher.DrawSize.X / 2, 0);
|
fruit.Position = new Vector2(MovableCatcher.ToLocalSpace(absolutePosition).X - MovableCatcher.DrawSize.X / 2, 0);
|
||||||
|
|
||||||
fruit.Anchor = Anchor.TopCentre;
|
fruit.Anchor = Anchor.TopCentre;
|
||||||
fruit.Origin = Anchor.BottomCentre;
|
fruit.Origin = Anchor.BottomCentre;
|
||||||
fruit.Scale *= 0.7f;
|
fruit.Scale *= 0.7f;
|
||||||
fruit.LifetimeEnd = double.MaxValue;
|
fruit.LifetimeEnd = double.MaxValue;
|
||||||
|
|
||||||
catcher.Add(fruit);
|
MovableCatcher.Add(fruit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AttemptCatch(CatchHitObject obj) => catcher.AttemptCatch(obj);
|
public bool AttemptCatch(CatchHitObject obj) => MovableCatcher.AttemptCatch(obj);
|
||||||
|
|
||||||
public class Catcher : Container, IKeyBindingHandler<CatchAction>
|
public class Catcher : Container, IKeyBindingHandler<CatchAction>
|
||||||
{
|
{
|
||||||
@ -181,8 +181,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
if (catchObject.LastInCombo)
|
if (catchObject.LastInCombo)
|
||||||
explode();
|
explode();
|
||||||
|
|
||||||
updateHyperDashState(catchObject, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -202,12 +200,45 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
catchObjectPosition >= catcherPosition - relative_catcher_width / 2 &&
|
catchObjectPosition >= catcherPosition - relative_catcher_width / 2 &&
|
||||||
catchObjectPosition <= catcherPosition + relative_catcher_width / 2;
|
catchObjectPosition <= catcherPosition + relative_catcher_width / 2;
|
||||||
|
|
||||||
// if we are hypderdashing in teh next hit is not, let's change our state here (it's our only opportunity to handle missed fruit currently).
|
if (validCatch && fruit.HyperDash)
|
||||||
updateHyperDashState(fruit, false);
|
HyperDashModifier = Math.Abs(fruit.HyperDashTarget.X - fruit.X) / Math.Abs(fruit.HyperDashTarget.StartTime - fruit.StartTime) / BASE_SPEED;
|
||||||
|
else
|
||||||
|
HyperDashModifier = 1;
|
||||||
|
|
||||||
return validCatch;
|
return validCatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we are hypderdashing or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool HyperDashing => hyperDashModifier != 1;
|
||||||
|
|
||||||
|
private double hyperDashModifier = 1;
|
||||||
|
|
||||||
|
public double HyperDashModifier
|
||||||
|
{
|
||||||
|
get { return hyperDashModifier; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == hyperDashModifier) return;
|
||||||
|
hyperDashModifier = value;
|
||||||
|
|
||||||
|
const float transition_length = 180;
|
||||||
|
|
||||||
|
if (HyperDashing)
|
||||||
|
{
|
||||||
|
this.FadeColour(Color4.Yellow, transition_length, Easing.OutQuint);
|
||||||
|
this.FadeTo(0.2f, transition_length, Easing.OutQuint);
|
||||||
|
Trail = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.FadeColour(Color4.White, transition_length, Easing.OutQuint);
|
||||||
|
this.FadeTo(1, transition_length, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool OnPressed(CatchAction action)
|
public bool OnPressed(CatchAction action)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
@ -264,39 +295,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
X = (float)MathHelper.Clamp(X + Math.Sign(currentDirection) * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1);
|
X = (float)MathHelper.Clamp(X + Math.Sign(currentDirection) * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether we are hypderdashing or not.
|
|
||||||
/// </summary>
|
|
||||||
protected bool HyperDashing => hyperDashModifier != 1;
|
|
||||||
|
|
||||||
private double hyperDashModifier = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update whether we are hyper or not.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fruit">The fruit to use as a condition for deciding our new state.</param>
|
|
||||||
/// <param name="allowBegin">Whether to allow entering hyperdash or not. If false, we will only exit if required, but never enter.</param>
|
|
||||||
private void updateHyperDashState(CatchHitObject fruit, bool allowBegin)
|
|
||||||
{
|
|
||||||
const float transition_length = 180;
|
|
||||||
|
|
||||||
if (!fruit.HyperDash)
|
|
||||||
{
|
|
||||||
hyperDashModifier = 1;
|
|
||||||
this.FadeColour(Color4.White, transition_length, Easing.OutQuint);
|
|
||||||
this.FadeTo(1, transition_length, Easing.OutQuint);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allowBegin)
|
|
||||||
{
|
|
||||||
hyperDashModifier = Math.Abs(fruit.HyperDashTarget.X - fruit.X) / Math.Abs(fruit.HyperDashTarget.StartTime - fruit.StartTime) / BASE_SPEED;
|
|
||||||
this.FadeColour(Color4.AliceBlue, transition_length, Easing.OutQuint);
|
|
||||||
this.FadeTo(0.5f, transition_length, Easing.OutQuint);
|
|
||||||
Trail = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void explode()
|
private void explode()
|
||||||
{
|
{
|
||||||
var fruit = caughtFruit.ToArray();
|
var fruit = caughtFruit.ToArray();
|
||||||
|
Reference in New Issue
Block a user