1
0
mirror of https://github.com/ppy/osu.git synced 2024-10-01 22:47:31 +08:00
osu-lazer/osu.Desktop.Tests/Visual/TestCaseGamefield.cs

121 lines
4.3 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-09-02 17:06:36 +08:00
using System.Collections.Generic;
using osu.Desktop.Tests.Beatmaps;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2017-02-27 17:30:10 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Mania;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Taiko;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Taiko.UI;
using OpenTK;
2016-09-02 17:06:36 +08:00
namespace osu.Desktop.Tests.Visual
2016-09-02 17:06:36 +08:00
{
internal class TestCaseGamefield : OsuTestCase
2016-09-02 17:06:36 +08:00
{
private RulesetStore rulesets;
2017-04-17 18:44:03 +08:00
public override string Description => @"Showing hitobjects and what not.";
2017-04-17 18:44:03 +08:00
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
2017-04-17 18:44:03 +08:00
{
this.rulesets = rulesets;
}
protected override void LoadComplete()
2016-09-02 17:06:36 +08:00
{
base.LoadComplete();
2016-09-26 14:07:29 +08:00
List<HitObject> objects = new List<HitObject>();
int time = 500;
for (int i = 0; i < 100; i++)
{
2017-03-07 09:59:19 +08:00
objects.Add(new HitCircle
2016-09-02 18:25:13 +08:00
{
StartTime = time,
2017-04-18 11:19:39 +08:00
Position = new Vector2(RNG.Next(0, (int)OsuPlayfield.BASE_SIZE.X), RNG.Next(0, (int)OsuPlayfield.BASE_SIZE.Y)),
Scale = RNG.NextSingle(0.5f, 1.0f),
});
time += RNG.Next(50, 500);
}
var controlPointInfo = new ControlPointInfo();
controlPointInfo.TimingPoints.Add(new TimingControlPoint
{
BeatLength = 200
});
WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap
{
HitObjects = objects,
BeatmapInfo = new BeatmapInfo
{
Difficulty = new BeatmapDifficulty(),
2017-04-17 18:44:03 +08:00
Ruleset = rulesets.Query<RulesetInfo>().First(),
Metadata = new BeatmapMetadata
{
Artist = @"Unknown",
Title = @"Sample Beatmap",
Author = @"peppy",
},
},
ControlPointInfo = controlPointInfo
});
2017-07-11 21:58:06 +08:00
AddRange(new Drawable[]
{
2017-02-27 17:30:10 +08:00
new Container
2016-09-21 12:25:23 +08:00
{
2017-02-27 17:30:10 +08:00
RelativeSizeAxes = Axes.Both,
//ensure we are at offset 0
Clock = new FramedClock(),
Children = new Drawable[]
{
new OsuHitRenderer(new OsuRuleset(new RulesetInfo()), beatmap, false)
2017-02-27 17:30:10 +08:00
{
Scale = new Vector2(0.5f),
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft
},
new TaikoHitRenderer(new TaikoRuleset(new RulesetInfo()),beatmap, false)
2017-02-27 17:30:10 +08:00
{
Scale = new Vector2(0.5f),
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight
},
new CatchHitRenderer(new CatchRuleset(new RulesetInfo()),beatmap, false)
2017-02-27 17:30:10 +08:00
{
Scale = new Vector2(0.5f),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft
},
new ManiaHitRenderer(new ManiaRuleset(new RulesetInfo()),beatmap, false)
2017-02-27 17:30:10 +08:00
{
Scale = new Vector2(0.5f),
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight
}
}
2016-09-21 12:25:23 +08:00
}
});
}
2016-09-02 17:06:36 +08:00
}
}