mirror of
https://github.com/ppy/osu.git
synced 2025-02-03 15:53:17 +08:00
Merge pull request #8198 from peppy/add-catcher-animation-states
Add catcher kiai/fail animation states
This commit is contained in:
commit
6e43f617e0
@ -8,9 +8,15 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Catch.Judgements;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
@ -27,9 +33,41 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
CreatedDrawables.OfType<CatchInputManager>().Select(i => i.Child)
|
CreatedDrawables.OfType<CatchInputManager>().Select(i => i.Child)
|
||||||
.OfType<TestCatcherArea>().ForEach(c => c.ToggleHyperDash(t)));
|
.OfType<TestCatcherArea>().ForEach(c => c.ToggleHyperDash(t)));
|
||||||
|
|
||||||
AddRepeatStep("catch fruit", () =>
|
AddRepeatStep("catch fruit", () => catchFruit(new TestFruit(false)
|
||||||
this.ChildrenOfType<CatcherArea>().ForEach(area =>
|
{
|
||||||
area.MovableCatcher.PlaceOnPlate(new DrawableFruit(new TestSceneFruitObjects.TestCatchFruit(FruitVisualRepresentation.Grape)))), 20);
|
X = this.ChildrenOfType<CatcherArea>().First().MovableCatcher.X
|
||||||
|
}), 20);
|
||||||
|
AddRepeatStep("catch fruit last in combo", () => catchFruit(new TestFruit(false)
|
||||||
|
{
|
||||||
|
X = this.ChildrenOfType<CatcherArea>().First().MovableCatcher.X,
|
||||||
|
LastInCombo = true,
|
||||||
|
}), 20);
|
||||||
|
AddRepeatStep("catch kiai fruit", () => catchFruit(new TestFruit(true)
|
||||||
|
{
|
||||||
|
X = this.ChildrenOfType<CatcherArea>().First().MovableCatcher.X,
|
||||||
|
}), 20);
|
||||||
|
AddRepeatStep("miss fruit", () => catchFruit(new Fruit
|
||||||
|
{
|
||||||
|
X = this.ChildrenOfType<CatcherArea>().First().MovableCatcher.X + 100,
|
||||||
|
LastInCombo = true,
|
||||||
|
}, true), 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void catchFruit(Fruit fruit, bool miss = false)
|
||||||
|
{
|
||||||
|
this.ChildrenOfType<CatcherArea>().ForEach(area =>
|
||||||
|
{
|
||||||
|
DrawableFruit drawable = new DrawableFruit(fruit);
|
||||||
|
area.Add(drawable);
|
||||||
|
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
area.AttemptCatch(fruit);
|
||||||
|
area.OnResult(drawable, new JudgementResult(fruit, new CatchJudgement()) { Type = miss ? HitResult.Miss : HitResult.Great });
|
||||||
|
|
||||||
|
drawable.Expire();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCatcher(float size)
|
private void createCatcher(float size)
|
||||||
@ -40,7 +78,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
Child = new TestCatcherArea(new BeatmapDifficulty { CircleSize = size })
|
Child = new TestCatcherArea(new BeatmapDifficulty { CircleSize = size })
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.TopLeft
|
Origin = Anchor.TopLeft,
|
||||||
|
CreateDrawableRepresentation = ((DrawableRuleset<CatchHitObject>)catchRuleset.CreateInstance().CreateDrawableRulesetWith(new CatchBeatmap())).CreateDrawableRepresentation
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -51,6 +90,17 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
catchRuleset = rulesets.GetRuleset(2);
|
catchRuleset = rulesets.GetRuleset(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TestFruit : Fruit
|
||||||
|
{
|
||||||
|
public TestFruit(bool kiai)
|
||||||
|
{
|
||||||
|
var kiaiCpi = new ControlPointInfo();
|
||||||
|
kiaiCpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
||||||
|
|
||||||
|
ApplyDefaultsToSelf(kiaiCpi, new BeatmapDifficulty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class TestCatcherArea : CatcherArea
|
private class TestCatcherArea : CatcherArea
|
||||||
{
|
{
|
||||||
public TestCatcherArea(BeatmapDifficulty beatmapDifficulty)
|
public TestCatcherArea(BeatmapDifficulty beatmapDifficulty)
|
||||||
|
@ -11,6 +11,8 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
FruitOrange,
|
FruitOrange,
|
||||||
FruitPear,
|
FruitPear,
|
||||||
Droplet,
|
Droplet,
|
||||||
CatcherIdle
|
CatcherIdle,
|
||||||
|
CatcherFail,
|
||||||
|
CatcherKiai
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,14 @@ namespace osu.Game.Rulesets.Catch.Skinning
|
|||||||
case CatchSkinComponents.CatcherIdle:
|
case CatchSkinComponents.CatcherIdle:
|
||||||
return this.GetAnimation("fruit-catcher-idle", true, true, true) ??
|
return this.GetAnimation("fruit-catcher-idle", true, true, true) ??
|
||||||
this.GetAnimation("fruit-ryuuta", true, true, true);
|
this.GetAnimation("fruit-ryuuta", true, true, true);
|
||||||
|
|
||||||
|
case CatchSkinComponents.CatcherFail:
|
||||||
|
return this.GetAnimation("fruit-catcher-fail", true, true, true) ??
|
||||||
|
this.GetAnimation("fruit-ryuuta", true, true, true);
|
||||||
|
|
||||||
|
case CatchSkinComponents.CatcherKiai:
|
||||||
|
return this.GetAnimation("fruit-catcher-kiai", true, true, true) ??
|
||||||
|
this.GetAnimation("fruit-ryuuta", true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
12
osu.Game.Rulesets.Catch/UI/CatcherAnimationState.cs
Normal file
12
osu.Game.Rulesets.Catch/UI/CatcherAnimationState.cs
Normal 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
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Animations;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
@ -148,18 +149,62 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Children = new[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
caughtFruit = new Container<DrawableHitObject>
|
caughtFruit = new Container<DrawableHitObject>
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
},
|
},
|
||||||
createCatcherSprite().With(c =>
|
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
|
||||||
{
|
{
|
||||||
c.Anchor = Anchor.TopCentre;
|
Anchor = Anchor.TopCentre,
|
||||||
})
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
catcherKiai = new CatcherSprite(CatcherAnimationState.Kiai)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
catcherFail = new CatcherSprite(CatcherAnimationState.Fail)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Alpha = 0,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateCatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CatcherSprite catcherIdle;
|
||||||
|
private CatcherSprite catcherKiai;
|
||||||
|
private CatcherSprite catcherFail;
|
||||||
|
|
||||||
|
private void updateCatcher()
|
||||||
|
{
|
||||||
|
catcherIdle.Hide();
|
||||||
|
catcherKiai.Hide();
|
||||||
|
catcherFail.Hide();
|
||||||
|
|
||||||
|
CatcherSprite current;
|
||||||
|
|
||||||
|
switch (currentState)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
current = catcherIdle;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CatcherAnimationState.Fail:
|
||||||
|
current = catcherFail;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CatcherAnimationState.Kiai:
|
||||||
|
current = catcherKiai;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
current.Show();
|
||||||
|
(current.Drawable as IAnimation)?.GotoFrame(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int currentDirection;
|
private int currentDirection;
|
||||||
@ -229,7 +274,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
return additive;
|
return additive;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable createCatcherSprite() => new CatcherSprite();
|
private Drawable createCatcherSprite() => new CatcherSprite(currentState);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a caught fruit to the catcher's stack.
|
/// Add a caught fruit to the catcher's stack.
|
||||||
@ -297,9 +342,25 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
SetHyperDashState();
|
SetHyperDashState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (validCatch)
|
||||||
|
updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle);
|
||||||
|
else
|
||||||
|
updateState(CatcherAnimationState.Fail);
|
||||||
|
|
||||||
return validCatch;
|
return validCatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateState(CatcherAnimationState state)
|
||||||
|
{
|
||||||
|
if (currentState == state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
currentState = state;
|
||||||
|
updateCatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CatcherAnimationState currentState;
|
||||||
|
|
||||||
private double hyperDashModifier = 1;
|
private double hyperDashModifier = 1;
|
||||||
private int hyperDashDirection;
|
private int hyperDashDirection;
|
||||||
private float hyperDashTargetPosition;
|
private float hyperDashTargetPosition;
|
||||||
|
@ -14,9 +14,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
protected override bool ApplySizeRestrictionsToDefault => true;
|
protected override bool ApplySizeRestrictionsToDefault => true;
|
||||||
|
|
||||||
public CatcherSprite()
|
public CatcherSprite(CatcherAnimationState state)
|
||||||
: base(new CatchSkinComponent(CatchSkinComponents.CatcherIdle), _ =>
|
: base(new CatchSkinComponent(componentFromState(state)), _ =>
|
||||||
new DefaultCatcherSprite(), confineMode: ConfineMode.ScaleDownToFit)
|
new DefaultCatcherSprite(state), confineMode: ConfineMode.ScaleDownToFit)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
Size = new Vector2(CatcherArea.CATCHER_SIZE);
|
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;
|
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 class DefaultCatcherSprite : Sprite
|
||||||
{
|
{
|
||||||
|
private readonly CatcherAnimationState state;
|
||||||
|
|
||||||
|
public DefaultCatcherSprite(CatcherAnimationState state)
|
||||||
|
{
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures)
|
||||||
{
|
{
|
||||||
Texture = textures.Get("Gameplay/catch/fruit-catcher-idle");
|
Texture = textures.Get($"Gameplay/catch/fruit-catcher-{state.ToString().ToLower()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user