mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 15:22:55 +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 &&
|
||||||
catchObjectPosition <= catcherPosition + halfCatchWidth;
|
catchObjectPosition <= catcherPosition + halfCatchWidth;
|
||||||
|
|
||||||
// only update hyperdash state if we are not catching a tiny droplet.
|
// droplet doesn't affect the catcher state
|
||||||
if (fruit is TinyDroplet) return validCatch;
|
if (!(fruit is TinyDroplet))
|
||||||
|
|
||||||
if (validCatch && fruit.HyperDash)
|
|
||||||
{
|
{
|
||||||
var target = fruit.HyperDashTarget;
|
if (validCatch && fruit.HyperDash)
|
||||||
var timeDifference = target.StartTime - fruit.StartTime;
|
{
|
||||||
double positionDifference = target.X - catcherPosition;
|
var target = fruit.HyperDashTarget;
|
||||||
var velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0);
|
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)
|
if (validCatch)
|
||||||
updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle);
|
placeCaughtObject(fruit);
|
||||||
else if (!(fruit is Banana))
|
|
||||||
updateState(CatcherAnimationState.Fail);
|
|
||||||
|
|
||||||
return validCatch;
|
return validCatch;
|
||||||
}
|
}
|
||||||
@ -450,6 +454,48 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
updateCatcher();
|
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)
|
private void clearPlate(DroppedObjectAnimation animation)
|
||||||
{
|
{
|
||||||
var caughtObjects = caughtFruitContainer.Children.ToArray();
|
var caughtObjects = caughtFruitContainer.Children.ToArray();
|
||||||
|
@ -45,29 +45,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
if (!result.Type.IsScorable())
|
if (!result.Type.IsScorable())
|
||||||
return;
|
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 (hitObject.HitObject.LastInCombo)
|
||||||
{
|
{
|
||||||
if (result.Judgement is CatchJudgement catchJudgement && catchJudgement.ShouldExplodeFor(result))
|
if (result.Judgement is CatchJudgement catchJudgement && catchJudgement.ShouldExplodeFor(result))
|
||||||
@ -98,26 +75,5 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
comboDisplay.X = MovableCatcher.X;
|
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