mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:03:11 +08:00
Move catcher trail generation logic to CatcherArea
This commit is contained in:
parent
de68fd12b3
commit
da69867fd4
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
var skin = new TestSkin { FlipCatcherPlate = flip };
|
||||
container.Child = new SkinProvidingContainer(skin)
|
||||
{
|
||||
Child = catcher = new Catcher(new CatcherTrailDisplay(), new DroppedObjectContainer())
|
||||
Child = catcher = new Catcher(new DroppedObjectContainer())
|
||||
{
|
||||
Anchor = Anchor.Centre
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
private CatcherTrailDisplay trailDisplay;
|
||||
|
||||
private DroppedObjectContainer droppedObjectContainer;
|
||||
|
||||
private TestCatcher catcher;
|
||||
@ -45,7 +43,6 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
CircleSize = 0,
|
||||
};
|
||||
|
||||
trailDisplay = new CatcherTrailDisplay();
|
||||
droppedObjectContainer = new DroppedObjectContainer();
|
||||
|
||||
Child = new Container
|
||||
@ -54,8 +51,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
Children = new Drawable[]
|
||||
{
|
||||
droppedObjectContainer,
|
||||
catcher = new TestCatcher(trailDisplay, droppedObjectContainer, difficulty),
|
||||
trailDisplay,
|
||||
catcher = new TestCatcher(droppedObjectContainer, difficulty),
|
||||
}
|
||||
};
|
||||
});
|
||||
@ -294,8 +290,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
public IEnumerable<CaughtObject> CaughtObjects => this.ChildrenOfType<CaughtObject>();
|
||||
|
||||
public TestCatcher(CatcherTrailDisplay trails, DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty)
|
||||
: base(trails, droppedObjectTarget, difficulty)
|
||||
public TestCatcher(DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty)
|
||||
: base(droppedObjectTarget, difficulty)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -121,13 +121,10 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
public TestCatcherArea(BeatmapDifficulty beatmapDifficulty)
|
||||
{
|
||||
var trailDisplay = new CatcherTrailDisplay { Depth = -1 };
|
||||
Add(trailDisplay);
|
||||
|
||||
var droppedObjectContainer = new DroppedObjectContainer();
|
||||
Add(droppedObjectContainer);
|
||||
|
||||
Catcher = new Catcher(trailDisplay, droppedObjectContainer, beatmapDifficulty)
|
||||
Catcher = new Catcher(droppedObjectContainer, beatmapDifficulty)
|
||||
{
|
||||
X = CatchPlayfield.CENTER_X
|
||||
};
|
||||
|
@ -118,19 +118,19 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
|
||||
AddStep("create hyper-dashing catcher", () =>
|
||||
{
|
||||
trails = new CatcherTrailDisplay();
|
||||
CatcherArea catcherArea;
|
||||
Child = setupSkinHierarchy(new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
Child = catcherArea = new CatcherArea
|
||||
{
|
||||
catcher = new Catcher(trails, new DroppedObjectContainer())
|
||||
Catcher = catcher = new Catcher(new DroppedObjectContainer())
|
||||
{
|
||||
Scale = new Vector2(4)
|
||||
},
|
||||
trails
|
||||
}
|
||||
}
|
||||
}, skin);
|
||||
trails = catcherArea.CatcherTrails;
|
||||
});
|
||||
|
||||
AddStep("start hyper-dash", () =>
|
||||
|
@ -44,14 +44,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var trailDisplay = new CatcherTrailDisplay
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.TopLeft
|
||||
};
|
||||
var droppedObjectContainer = new DroppedObjectContainer();
|
||||
|
||||
Catcher = new Catcher(trailDisplay, droppedObjectContainer, difficulty)
|
||||
Catcher = new Catcher(droppedObjectContainer, difficulty)
|
||||
{
|
||||
X = CENTER_X
|
||||
};
|
||||
@ -69,7 +64,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
Origin = Anchor.TopLeft,
|
||||
Catcher = Catcher,
|
||||
},
|
||||
trailDisplay,
|
||||
HitObjectContainer,
|
||||
});
|
||||
|
||||
|
@ -71,11 +71,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// </summary>
|
||||
private const float caught_fruit_scale_adjust = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// Contains trails and afterimages (also called "end glow" in code) of the catcher.
|
||||
/// </summary>
|
||||
private readonly CatcherTrailDisplay trails;
|
||||
|
||||
/// <summary>
|
||||
/// Contains caught objects on the plate.
|
||||
/// </summary>
|
||||
@ -102,6 +97,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// </summary>
|
||||
public Direction VisualDirection { get; set; } = Direction.Right;
|
||||
|
||||
public Vector2 BodyScale => Scale * body.Scale;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the contents of the catcher plate should be visually flipped when the catcher direction is changed.
|
||||
/// </summary>
|
||||
@ -127,9 +124,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
private readonly DrawablePool<CaughtBanana> caughtBananaPool;
|
||||
private readonly DrawablePool<CaughtDroplet> caughtDropletPool;
|
||||
|
||||
public Catcher([NotNull] CatcherTrailDisplay trails, [NotNull] DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty = null)
|
||||
public Catcher([NotNull] DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty = null)
|
||||
{
|
||||
this.trails = trails;
|
||||
this.droppedObjectTarget = droppedObjectTarget;
|
||||
|
||||
Origin = Anchor.TopCentre;
|
||||
@ -292,10 +288,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
hyperDashTargetPosition = targetPosition;
|
||||
|
||||
if (!wasHyperDashing)
|
||||
{
|
||||
trails.DisplayEndGlow(CurrentState, X, Scale * body.Scale);
|
||||
runHyperDashStateTransition(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,15 +335,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
X = hyperDashTargetPosition;
|
||||
SetHyperDashState();
|
||||
}
|
||||
|
||||
if (Dashing || HyperDashing)
|
||||
{
|
||||
double lastTrailTime = trails.LastDashTrail?.LifetimeStart ?? double.NegativeInfinity;
|
||||
double generationInterval = HyperDashing ? 25 : 50;
|
||||
|
||||
if (Time.Current - lastTrailTime >= generationInterval)
|
||||
trails.DisplayDashTrail(CurrentState, X, Scale * body.Scale, HyperDashing);
|
||||
}
|
||||
}
|
||||
|
||||
private void placeCaughtObject(DrawablePalpableCatchHitObject drawableObject, Vector2 position)
|
||||
|
@ -25,15 +25,13 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
public Catcher Catcher
|
||||
{
|
||||
get => catcher;
|
||||
set
|
||||
{
|
||||
if (catcher != null)
|
||||
Remove(catcher);
|
||||
|
||||
Add(catcher = value);
|
||||
}
|
||||
set => catcherContainer.Child = catcher = value;
|
||||
}
|
||||
|
||||
internal CatcherTrailDisplay CatcherTrails { get; }
|
||||
|
||||
private readonly Container<Catcher> catcherContainer;
|
||||
|
||||
private readonly CatchComboDisplay comboDisplay;
|
||||
|
||||
private Catcher catcher;
|
||||
@ -45,20 +43,28 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// </summary>
|
||||
private int currentDirection;
|
||||
|
||||
// TODO: support replay rewind
|
||||
private bool lastHyperDashState;
|
||||
|
||||
/// <remarks>
|
||||
/// <see cref="Catcher"/> must be set before loading.
|
||||
/// </remarks>
|
||||
public CatcherArea()
|
||||
{
|
||||
Size = new Vector2(CatchPlayfield.WIDTH, Catcher.BASE_SIZE);
|
||||
Child = comboDisplay = new CatchComboDisplay
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.Centre,
|
||||
Margin = new MarginPadding { Bottom = 350f },
|
||||
X = CatchPlayfield.CENTER_X
|
||||
catcherContainer = new Container<Catcher> { RelativeSizeAxes = Axes.Both },
|
||||
CatcherTrails = new CatcherTrailDisplay(),
|
||||
comboDisplay = new CatchComboDisplay
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.Centre,
|
||||
Margin = new MarginPadding { Bottom = 350f },
|
||||
X = CatchPlayfield.CENTER_X
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -102,6 +108,20 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
comboDisplay.X = Catcher.X;
|
||||
|
||||
if (!lastHyperDashState && Catcher.HyperDashing && Time.Elapsed > 0)
|
||||
CatcherTrails.DisplayEndGlow(Catcher.CurrentState, Catcher.X, Catcher.BodyScale);
|
||||
|
||||
if (Catcher.Dashing || Catcher.HyperDashing)
|
||||
{
|
||||
double lastTrailTime = CatcherTrails.LastDashTrail?.LifetimeStart ?? double.NegativeInfinity;
|
||||
double generationInterval = Catcher.HyperDashing ? 25 : 50;
|
||||
|
||||
if (Time.Current - lastTrailTime >= generationInterval)
|
||||
CatcherTrails.DisplayDashTrail(Catcher.CurrentState, Catcher.X, Catcher.BodyScale, Catcher.HyperDashing);
|
||||
}
|
||||
|
||||
lastHyperDashState = Catcher.HyperDashing;
|
||||
}
|
||||
|
||||
public void SetCatcherPosition(float X)
|
||||
|
Loading…
Reference in New Issue
Block a user