-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathTestSceneStrictHardBeat.cs
110 lines (94 loc) · 4.09 KB
/
TestSceneStrictHardBeat.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Tau.Configuration;
using osu.Game.Rulesets.Tau.Objects;
using osu.Game.Rulesets.Tau.Objects.Drawables;
using osu.Game.Rulesets.Tau.UI;
namespace osu.Game.Rulesets.Tau.Tests.Objects
{
[TestFixture]
public partial class TestSceneStrictHardBeat : TauTestScene
{
private int depthIndex;
private TauPlayfieldAdjustmentContainer container;
private BindableBool highlightHardNotes = new BindableBool();
[BackgroundDependencyLoader]
private void load() {
var config = (TauRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
config.BindWith(TauRulesetSettings.HighlightHardBeats, highlightHardNotes);
}
[Test]
public void TestStrictHardBeat()
{
AddStep("clear screen", Clear);
AddStep("add container", () => Add(container = new TauPlayfieldAdjustmentContainer()));
AddStep("highlighting disabled", () => highlightHardNotes.Value = false);
AddStep("Miss Single", () => container.Add(testSingle()));
AddStep("Hit Single", () => container.Add(testSingle(true)));
AddStep("Miss Stream", () => Add(testStream()));
AddStep("Hit Stream", () => Add(testStream(true)));
AddUntilStep("Wait for object despawn", () => !container.Any(h => h is DrawableTauHitObject<StrictHardBeat> { AllJudged: false }));
}
[Test]
public void TestHighlightedStrictHardBeat()
{
AddStep("clear screen", Clear);
AddStep("add container", () => Add(container = new TauPlayfieldAdjustmentContainer()));
AddStep("highlighting enabled", () => highlightHardNotes.Value = true);
AddStep("Miss Single", () => container.Add(testSingle()));
AddStep("Hit Single", () => container.Add(testSingle(true)));
AddStep("Miss Stream", () => Add(testStream()));
AddStep("Hit Stream", () => Add(testStream(true)));
AddUntilStep("Wait for object despawn", () => !container.Any(h => h is DrawableTauHitObject<StrictHardBeat> { AllJudged: false }));
}
private Drawable testSingle(bool auto = false, double timeOffset = 0, float angle = 0)
{
var strict = new StrictHardBeat
{
StartTime = Time.Current + 1000 + timeOffset,
Angle = angle
};
strict.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
return new TestDrawableStrictHardBeat(strict, auto)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = depthIndex++
};
}
private Drawable testStream(bool auto = false)
{
var playfield = new TauPlayfieldAdjustmentContainer();
for (int i = 0; i <= 1000; i += 100)
{
playfield.Add(testSingle(auto, i, i / 10f));
}
return playfield;
}
private partial class TestDrawableStrictHardBeat : DrawableStrictHardBeat
{
private readonly bool auto;
public TestDrawableStrictHardBeat(StrictHardBeat h, bool auto)
: base(h)
{
this.auto = auto;
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (auto && !userTriggered && timeOffset > 0)
// Force success.
ApplyResult(HitResult.Great);
else if (timeOffset > 0)
// We'll have to manually apply the result anyways because we have no way of checking if the paddle is in the correct spot.
ApplyResult(HitResult.Miss);
}
}
}
}