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

@ -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;