mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Add catcher scale based on CircleSize
This commit is contained in:
parent
b11de50df2
commit
2bb61e51ac
@ -11,13 +11,23 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
[Ignore("getting CI working")]
|
[Ignore("getting CI working")]
|
||||||
public class TestCaseCatchStacker : Game.Tests.Visual.TestCasePlayer
|
public class TestCaseCatchStacker : Game.Tests.Visual.TestCasePlayer
|
||||||
{
|
{
|
||||||
public TestCaseCatchStacker() : base(typeof(CatchRuleset))
|
public TestCaseCatchStacker()
|
||||||
|
: base(typeof(CatchRuleset))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Beatmap CreateBeatmap()
|
protected override Beatmap CreateBeatmap()
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap();
|
var beatmap = new Beatmap
|
||||||
|
{
|
||||||
|
BeatmapInfo = new BeatmapInfo
|
||||||
|
{
|
||||||
|
BaseDifficulty = new BeatmapDifficulty
|
||||||
|
{
|
||||||
|
CircleSize = 6,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for (int i = 0; i < 512; i++)
|
for (int i = 0; i < 512; i++)
|
||||||
beatmap.HitObjects.Add(new Fruit { X = 0.5f + i / 2048f * (i % 10 - 5), StartTime = i * 100, NewCombo = i % 8 == 0 });
|
beatmap.HitObjects.Add(new Fruit { X = 0.5f + i / 2048f * (i % 10 - 5), StartTime = i * 100, NewCombo = i % 8 == 0 });
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
@ -15,26 +16,35 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
[Ignore("getting CI working")]
|
[Ignore("getting CI working")]
|
||||||
internal class TestCaseCatcherArea : OsuTestCase
|
internal class TestCaseCatcherArea : OsuTestCase
|
||||||
{
|
{
|
||||||
|
private RulesetInfo catchRuleset;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(CatcherArea),
|
typeof(CatcherArea),
|
||||||
};
|
};
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
public TestCaseCatcherArea()
|
||||||
private void load(RulesetStore rulesets)
|
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
AddSliderStep<float>("CircleSize", 0, 8, 5, craeteCatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void craeteCatcher(float size)
|
||||||
|
{
|
||||||
|
Child = new CatchInputManager(catchRuleset)
|
||||||
{
|
{
|
||||||
new CatchInputManager(rulesets.GetRuleset(2))
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = new CatcherArea(new BeatmapDifficulty { CircleSize = size })
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Anchor = Anchor.CentreLeft,
|
||||||
Child = new CatcherArea()
|
Origin = Anchor.BottomLeft
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(RulesetStore rulesets)
|
||||||
|
{
|
||||||
|
catchRuleset = rulesets.GetRuleset(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
catcher.Add(fruit);
|
catcher.Add(fruit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanCatch(CatchHitObject obj) => Math.Abs(catcher.Position.X - obj.X) < catcher.DrawSize.X / DrawSize.X / 2;
|
public bool CanCatch(CatchHitObject obj) => Math.Abs(catcher.Position.X - obj.X) < catcher.DrawSize.X * Math.Abs(catcher.Scale.X) / DrawSize.X / 2;
|
||||||
|
|
||||||
public class Catcher : Container, IKeyBindingHandler<CatchAction>
|
public class Catcher : Container, IKeyBindingHandler<CatchAction>
|
||||||
{
|
{
|
||||||
@ -68,10 +68,12 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
RelativePositionAxes = Axes.X;
|
RelativePositionAxes = Axes.X;
|
||||||
X = 0.5f;
|
X = 0.5f;
|
||||||
|
|
||||||
Origin = Anchor.BottomCentre;
|
Origin = Anchor.TopCentre;
|
||||||
Anchor = Anchor.BottomLeft;
|
Anchor = Anchor.TopLeft;
|
||||||
|
|
||||||
Size = new Vector2(CATCHER_SIZE);
|
Size = new Vector2(CATCHER_SIZE);
|
||||||
|
if (difficulty != null)
|
||||||
|
Scale = new Vector2(1.0f - 0.7f * (difficulty.CircleSize - 5) / 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -115,7 +117,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
var additive = createCatcherSprite();
|
var additive = createCatcherSprite();
|
||||||
|
|
||||||
additive.Anchor = Anchor;
|
additive.Anchor = Anchor;
|
||||||
additive.OriginPosition = additive.OriginPosition + new Vector2(DrawWidth / 2, DrawHeight); // also temporary to align sprite correctly.
|
additive.OriginPosition = additive.OriginPosition + new Vector2(DrawWidth / 2, 0); // also temporary to align sprite correctly.
|
||||||
additive.Position = Position;
|
additive.Position = Position;
|
||||||
additive.Scale = Scale;
|
additive.Scale = Scale;
|
||||||
additive.RelativePositionAxes = RelativePositionAxes;
|
additive.RelativePositionAxes = RelativePositionAxes;
|
||||||
@ -201,7 +203,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
double dashModifier = Dashing ? 1 : 0.5;
|
double dashModifier = Dashing ? 1 : 0.5;
|
||||||
|
|
||||||
Scale = new Vector2(Math.Sign(currentDirection), 1);
|
Scale = new Vector2(Math.Abs(Scale.X) * Math.Sign(currentDirection), Scale.Y);
|
||||||
X = (float)MathHelper.Clamp(X + Math.Sign(currentDirection) * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1);
|
X = (float)MathHelper.Clamp(X + Math.Sign(currentDirection) * Clock.ElapsedFrameTime * BASE_SPEED * dashModifier, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user