Add catcher kiai/fail animation states

This commit is contained in:
Dean Herbert
2020-03-10 15:26:39 +09:00
parent a6cf6207aa
commit 7069cef9ce
6 changed files with 134 additions and 14 deletions

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
namespace osu.Game.Rulesets.Catch.UI
{
public enum CatcherAnimationState
{
Idle,
Fail,
Kiai
}
}

View File

@ -155,11 +155,21 @@ namespace osu.Game.Rulesets.Catch.UI
Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre,
},
createCatcherSprite().With(c =>
{
c.Anchor = Anchor.TopCentre;
})
};
updateCatcher();
}
private Drawable catcherSprite;
private void updateCatcher()
{
catcherSprite?.Expire();
Add(catcherSprite = createCatcherSprite().With(c =>
{
c.Anchor = Anchor.TopCentre;
}));
}
private int currentDirection;
@ -222,7 +232,7 @@ namespace osu.Game.Rulesets.Catch.UI
Scheduler.AddDelayed(beginTrail, HyperDashing ? 25 : 50);
}
private Drawable createCatcherSprite() => new CatcherSprite();
private Drawable createCatcherSprite() => new CatcherSprite(currentState);
/// <summary>
/// Add a caught fruit to the catcher's stack.
@ -290,9 +300,25 @@ namespace osu.Game.Rulesets.Catch.UI
SetHyperDashState();
}
if (validCatch)
updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle);
else
updateState(CatcherAnimationState.Fail);
return validCatch;
}
private void updateState(CatcherAnimationState state)
{
if (currentState == state)
return;
currentState = state;
updateCatcher();
}
private CatcherAnimationState currentState;
private double hyperDashModifier = 1;
private int hyperDashDirection;
private float hyperDashTargetPosition;

View File

@ -14,9 +14,9 @@ namespace osu.Game.Rulesets.Catch.UI
{
protected override bool ApplySizeRestrictionsToDefault => true;
public CatcherSprite()
: base(new CatchSkinComponent(CatchSkinComponents.CatcherIdle), _ =>
new DefaultCatcherSprite(), confineMode: ConfineMode.ScaleDownToFit)
public CatcherSprite(CatcherAnimationState state)
: base(new CatchSkinComponent(componentFromState(state)), _ =>
new DefaultCatcherSprite(state), confineMode: ConfineMode.ScaleDownToFit)
{
RelativeSizeAxes = Axes.None;
Size = new Vector2(CatcherArea.CATCHER_SIZE);
@ -25,12 +25,34 @@ namespace osu.Game.Rulesets.Catch.UI
OriginPosition = new Vector2(0.5f, 0.06f) * CatcherArea.CATCHER_SIZE;
}
private static CatchSkinComponents componentFromState(CatcherAnimationState state)
{
switch (state)
{
case CatcherAnimationState.Fail:
return CatchSkinComponents.CatcherFail;
case CatcherAnimationState.Kiai:
return CatchSkinComponents.CatcherKiai;
default:
return CatchSkinComponents.CatcherIdle;
}
}
private class DefaultCatcherSprite : Sprite
{
private readonly CatcherAnimationState state;
public DefaultCatcherSprite(CatcherAnimationState state)
{
this.state = state;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get("Gameplay/catch/fruit-catcher-idle");
Texture = textures.Get($"Gameplay/catch/fruit-catcher-{state.ToString().ToLower()}");
}
}
}