mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into news
This commit is contained in:
commit
0280f00022
@ -35,22 +35,25 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation)
|
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation)
|
||||||
{
|
{
|
||||||
Container explodingFruitContainer;
|
var explodingFruitContainer = new Container
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
{
|
||||||
explodingFruitContainer = new Container
|
RelativeSizeAxes = Axes.Both,
|
||||||
{
|
};
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
CatcherArea = new CatcherArea(difficulty)
|
||||||
CatcherArea = new CatcherArea(difficulty)
|
{
|
||||||
{
|
CreateDrawableRepresentation = createDrawableRepresentation,
|
||||||
CreateDrawableRepresentation = createDrawableRepresentation,
|
ExplodingFruitTarget = explodingFruitContainer,
|
||||||
ExplodingFruitTarget = explodingFruitContainer,
|
Anchor = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
Origin = Anchor.TopLeft,
|
||||||
Origin = Anchor.TopLeft,
|
};
|
||||||
},
|
|
||||||
HitObjectContainer
|
InternalChildren = new[]
|
||||||
|
{
|
||||||
|
explodingFruitContainer,
|
||||||
|
CatcherArea.MovableCatcher.CreateProxiedContent(),
|
||||||
|
HitObjectContainer,
|
||||||
|
CatcherArea
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,12 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
public Container ExplodingFruitTarget;
|
public Container ExplodingFruitTarget;
|
||||||
|
|
||||||
|
private Container<DrawableHitObject> caughtFruitContainer { get; } = new Container<DrawableHitObject>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
};
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private readonly Container trailsTarget;
|
private readonly Container trailsTarget;
|
||||||
|
|
||||||
@ -83,8 +89,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly float catchWidth;
|
private readonly float catchWidth;
|
||||||
|
|
||||||
private Container<DrawableHitObject> caughtFruit;
|
|
||||||
|
|
||||||
private CatcherSprite catcherIdle;
|
private CatcherSprite catcherIdle;
|
||||||
private CatcherSprite catcherKiai;
|
private CatcherSprite catcherKiai;
|
||||||
private CatcherSprite catcherFail;
|
private CatcherSprite catcherFail;
|
||||||
@ -118,11 +122,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
caughtFruit = new Container<DrawableHitObject>
|
caughtFruitContainer,
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
},
|
|
||||||
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
|
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
@ -145,6 +145,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
updateCatcher();
|
updateCatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates proxied content to be displayed beneath hitobjects.
|
||||||
|
/// </summary>
|
||||||
|
public Drawable CreateProxiedContent() => caughtFruitContainer.CreateProxy();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculates the scale of the catcher based off the provided beatmap difficulty.
|
/// Calculates the scale of the catcher based off the provided beatmap difficulty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -176,7 +181,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
const float allowance = 10;
|
const float allowance = 10;
|
||||||
|
|
||||||
while (caughtFruit.Any(f =>
|
while (caughtFruitContainer.Any(f =>
|
||||||
f.LifetimeEnd == double.MaxValue &&
|
f.LifetimeEnd == double.MaxValue &&
|
||||||
Vector2Extensions.Distance(f.Position, fruit.Position) < (ourRadius + (theirRadius = f.DrawSize.X / 2 * f.Scale.X)) / (allowance / 2)))
|
Vector2Extensions.Distance(f.Position, fruit.Position) < (ourRadius + (theirRadius = f.DrawSize.X / 2 * f.Scale.X)) / (allowance / 2)))
|
||||||
{
|
{
|
||||||
@ -187,7 +192,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
fruit.X = Math.Clamp(fruit.X, -CatcherArea.CATCHER_SIZE / 2, CatcherArea.CATCHER_SIZE / 2);
|
fruit.X = Math.Clamp(fruit.X, -CatcherArea.CATCHER_SIZE / 2, CatcherArea.CATCHER_SIZE / 2);
|
||||||
|
|
||||||
caughtFruit.Add(fruit);
|
caughtFruitContainer.Add(fruit);
|
||||||
|
|
||||||
AddInternal(new HitExplosion(fruit)
|
AddInternal(new HitExplosion(fruit)
|
||||||
{
|
{
|
||||||
@ -342,7 +347,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Drop()
|
public void Drop()
|
||||||
{
|
{
|
||||||
foreach (var f in caughtFruit.ToArray())
|
foreach (var f in caughtFruitContainer.ToArray())
|
||||||
Drop(f);
|
Drop(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +356,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Explode()
|
public void Explode()
|
||||||
{
|
{
|
||||||
foreach (var f in caughtFruit.ToArray())
|
foreach (var f in caughtFruitContainer.ToArray())
|
||||||
Explode(f);
|
Explode(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,9 +455,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
if (ExplodingFruitTarget != null)
|
if (ExplodingFruitTarget != null)
|
||||||
{
|
{
|
||||||
fruit.Anchor = Anchor.TopLeft;
|
fruit.Anchor = Anchor.TopLeft;
|
||||||
fruit.Position = caughtFruit.ToSpaceOfOtherDrawable(fruit.DrawPosition, ExplodingFruitTarget);
|
fruit.Position = caughtFruitContainer.ToSpaceOfOtherDrawable(fruit.DrawPosition, ExplodingFruitTarget);
|
||||||
|
|
||||||
if (!caughtFruit.Remove(fruit))
|
if (!caughtFruitContainer.Remove(fruit))
|
||||||
// we may have already been removed by a previous operation (due to the weird OnLoadComplete scheduling).
|
// we may have already been removed by a previous operation (due to the weird OnLoadComplete scheduling).
|
||||||
// this avoids a crash on potentially attempting to Add a fruit to ExplodingFruitTarget twice.
|
// this avoids a crash on potentially attempting to Add a fruit to ExplodingFruitTarget twice.
|
||||||
return;
|
return;
|
||||||
|
@ -22,6 +22,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> CreateDrawableRepresentation;
|
public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> CreateDrawableRepresentation;
|
||||||
|
|
||||||
|
public readonly Catcher MovableCatcher;
|
||||||
|
|
||||||
public Container ExplodingFruitTarget
|
public Container ExplodingFruitTarget
|
||||||
{
|
{
|
||||||
set => MovableCatcher.ExplodingFruitTarget = value;
|
set => MovableCatcher.ExplodingFruitTarget = value;
|
||||||
@ -104,7 +106,5 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
if (state?.CatcherX != null)
|
if (state?.CatcherX != null)
|
||||||
MovableCatcher.X = state.CatcherX.Value;
|
MovableCatcher.X = state.CatcherX.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal readonly Catcher MovableCatcher;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user