From 2b33594400dae72c9dc05d428f927353b53fe407 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Mar 2020 15:59:13 +0900 Subject: [PATCH] Add random rotation and scale factors to osu!catch bananas --- .../TestSceneBananaShower.cs | 2 ++ .../Objects/Drawables/DrawableBanana.cs | 17 +++++++++++++++++ osu.Game/Tests/Visual/ScreenTestScene.cs | 5 ++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs index 20911b8d06..024c4cefb0 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs @@ -18,7 +18,9 @@ public class TestSceneBananaShower : PlayerTestScene public override IReadOnlyList RequiredTypes => new[] { typeof(BananaShower), + typeof(Banana), typeof(DrawableBananaShower), + typeof(DrawableBanana), typeof(CatchRuleset), typeof(DrawableCatchRuleset), diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableBanana.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableBanana.cs index cf7231ebb2..2e7618b8df 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableBanana.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableBanana.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Framework.Graphics; using osu.Framework.Utils; using osuTK.Graphics; @@ -22,6 +23,22 @@ protected override Color4 GetComboColour(IReadOnlyList comboColours) return colour ??= getBananaColour(); } + protected override void UpdateInitialTransforms() + { + base.UpdateInitialTransforms(); + + const float end_scale = 0.6f; + const float random_scale_range = 1.6f; + + ScaleContainer.ScaleTo(HitObject.Scale * (end_scale + random_scale_range * RNG.NextSingle())) + .Then().ScaleTo(HitObject.Scale * end_scale, HitObject.TimePreempt); + + const float random_angle_range = 180; + + ScaleContainer.RotateTo(random_angle_range * (RNG.NextSingle() * 2 - 1)) + .Then().RotateTo(random_angle_range * (RNG.NextSingle() * 2 - 1), HitObject.TimePreempt); + } + private Color4 getBananaColour() { switch (RNG.Next(0, 3)) diff --git a/osu.Game/Tests/Visual/ScreenTestScene.cs b/osu.Game/Tests/Visual/ScreenTestScene.cs index d26aacf2bc..1a6ebed425 100644 --- a/osu.Game/Tests/Visual/ScreenTestScene.cs +++ b/osu.Game/Tests/Visual/ScreenTestScene.cs @@ -38,12 +38,11 @@ protected ScreenTestScene() private void addExitAllScreensStep() { - AddUntilStep("exit all screens", () => + AddStep("exit all screens", () => { - if (Stack.CurrentScreen == null) return true; + if (Stack.CurrentScreen == null) return; Stack.Exit(); - return false; }); } }