mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Move more logic to Catcher from CatcherArea
This commit is contained in:
parent
2eb2c934cc
commit
5a5c956ced
@ -245,25 +245,29 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
catchObjectPosition >= catcherPosition - halfCatchWidth &&
|
||||
catchObjectPosition <= catcherPosition + halfCatchWidth;
|
||||
|
||||
// only update hyperdash state if we are not catching a tiny droplet.
|
||||
if (fruit is TinyDroplet) return validCatch;
|
||||
|
||||
if (validCatch && fruit.HyperDash)
|
||||
// droplet doesn't affect the catcher state
|
||||
if (!(fruit is TinyDroplet))
|
||||
{
|
||||
var target = fruit.HyperDashTarget;
|
||||
var timeDifference = target.StartTime - fruit.StartTime;
|
||||
double positionDifference = target.X - catcherPosition;
|
||||
var velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0);
|
||||
if (validCatch && fruit.HyperDash)
|
||||
{
|
||||
var target = fruit.HyperDashTarget;
|
||||
var timeDifference = target.StartTime - fruit.StartTime;
|
||||
double positionDifference = target.X - catcherPosition;
|
||||
var velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0);
|
||||
|
||||
SetHyperDashState(Math.Abs(velocity), target.X);
|
||||
SetHyperDashState(Math.Abs(velocity), target.X);
|
||||
}
|
||||
else
|
||||
SetHyperDashState();
|
||||
|
||||
if (validCatch)
|
||||
updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle);
|
||||
else if (!(fruit is Banana))
|
||||
updateState(CatcherAnimationState.Fail);
|
||||
}
|
||||
else
|
||||
SetHyperDashState();
|
||||
|
||||
if (validCatch)
|
||||
updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle);
|
||||
else if (!(fruit is Banana))
|
||||
updateState(CatcherAnimationState.Fail);
|
||||
placeCaughtObject(fruit);
|
||||
|
||||
return validCatch;
|
||||
}
|
||||
@ -450,6 +454,48 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
updateCatcher();
|
||||
}
|
||||
|
||||
private void placeCaughtObject(PalpableCatchHitObject source)
|
||||
{
|
||||
var caughtObject = createCaughtObject(source);
|
||||
if (caughtObject == null) return;
|
||||
|
||||
caughtObject.RelativePositionAxes = Axes.None;
|
||||
caughtObject.X = source.X - X;
|
||||
caughtObject.IsOnPlate = true;
|
||||
|
||||
caughtObject.Anchor = Anchor.TopCentre;
|
||||
caughtObject.Origin = Anchor.Centre;
|
||||
caughtObject.Scale *= 0.5f;
|
||||
caughtObject.LifetimeStart = source.StartTime;
|
||||
caughtObject.LifetimeEnd = double.MaxValue;
|
||||
|
||||
PlaceOnPlate(caughtObject);
|
||||
|
||||
if (!caughtObject.StaysOnPlate)
|
||||
Explode(caughtObject);
|
||||
}
|
||||
|
||||
private DrawablePalpableCatchHitObject createCaughtObject(PalpableCatchHitObject source)
|
||||
{
|
||||
switch (source)
|
||||
{
|
||||
case Banana banana:
|
||||
return new DrawableBanana(banana);
|
||||
|
||||
case Fruit fruit:
|
||||
return new DrawableFruit(fruit);
|
||||
|
||||
case TinyDroplet tiny:
|
||||
return new DrawableTinyDroplet(tiny);
|
||||
|
||||
case Droplet droplet:
|
||||
return new DrawableDroplet(droplet);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void clearPlate(DroppedObjectAnimation animation)
|
||||
{
|
||||
var caughtObjects = caughtFruitContainer.Children.ToArray();
|
||||
|
@ -45,29 +45,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
if (!result.Type.IsScorable())
|
||||
return;
|
||||
|
||||
if (result.IsHit && hitObject is DrawablePalpableCatchHitObject fruit)
|
||||
{
|
||||
// create a new (cloned) fruit to stay on the plate. the original is faded out immediately.
|
||||
var caughtFruit = createCaughtFruit(fruit);
|
||||
|
||||
if (caughtFruit == null) return;
|
||||
|
||||
caughtFruit.RelativePositionAxes = Axes.None;
|
||||
caughtFruit.Position = new Vector2(MovableCatcher.ToLocalSpace(hitObject.ScreenSpaceDrawQuad.Centre).X - MovableCatcher.DrawSize.X / 2, 0);
|
||||
caughtFruit.IsOnPlate = true;
|
||||
|
||||
caughtFruit.Anchor = Anchor.TopCentre;
|
||||
caughtFruit.Origin = Anchor.Centre;
|
||||
caughtFruit.Scale *= 0.5f;
|
||||
caughtFruit.LifetimeStart = caughtFruit.HitObject.StartTime;
|
||||
caughtFruit.LifetimeEnd = double.MaxValue;
|
||||
|
||||
MovableCatcher.PlaceOnPlate(caughtFruit);
|
||||
|
||||
if (!fruit.StaysOnPlate)
|
||||
MovableCatcher.Explode(caughtFruit);
|
||||
}
|
||||
|
||||
if (hitObject.HitObject.LastInCombo)
|
||||
{
|
||||
if (result.Judgement is CatchJudgement catchJudgement && catchJudgement.ShouldExplodeFor(result))
|
||||
@ -98,26 +75,5 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
comboDisplay.X = MovableCatcher.X;
|
||||
}
|
||||
|
||||
private DrawablePalpableCatchHitObject createCaughtFruit(DrawablePalpableCatchHitObject hitObject)
|
||||
{
|
||||
switch (hitObject.HitObject)
|
||||
{
|
||||
case Banana banana:
|
||||
return new DrawableBanana(banana);
|
||||
|
||||
case Fruit fruit:
|
||||
return new DrawableFruit(fruit);
|
||||
|
||||
case TinyDroplet tiny:
|
||||
return new DrawableTinyDroplet(tiny);
|
||||
|
||||
case Droplet droplet:
|
||||
return new DrawableDroplet(droplet);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user