1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 19:02:56 +08:00
osu-lazer/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs

113 lines
3.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
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
2017-02-17 17:59:30 +08:00
using osu.Framework.Screens.Testing;
using osu.Game.Beatmaps;
using OpenTK;
2016-11-17 20:29:35 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps.IO;
using osu.Game.Database;
using osu.Game.Modes;
2016-11-14 17:03:20 +08:00
using osu.Game.Modes.Objects;
2016-11-14 17:54:24 +08:00
using osu.Game.Modes.Osu.Objects;
2016-11-14 16:23:33 +08:00
using osu.Game.Screens.Play;
2016-11-17 20:29:35 +08:00
using OpenTK.Graphics;
namespace osu.Desktop.VisualTests.Tests
{
2017-03-07 09:59:19 +08:00
internal class TestCasePlayer : TestCase
{
protected Player Player;
private BeatmapDatabase db;
public override string Description => @"Showing everything to play the game.";
[BackgroundDependencyLoader]
private void load(BeatmapDatabase db)
{
this.db = db;
}
public override void Reset()
{
base.Reset();
WorkingBeatmap beatmap = null;
var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.Mode == PlayMode.Osu);
if (beatmapInfo != null)
beatmap = db.GetWorkingBeatmap(beatmapInfo);
2017-02-23 15:44:59 +08:00
if (beatmap?.Track == null)
{
var objects = new List<HitObject>();
int time = 1500;
for (int i = 0; i < 50; i++)
{
2017-03-07 09:59:19 +08:00
objects.Add(new HitCircle
{
StartTime = time,
Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : 512,
i % 4 < 2 ? 0 : 384),
NewCombo = i % 4 == 0
});
time += 500;
}
Beatmap b = new Beatmap
{
2017-02-22 22:27:29 +08:00
HitObjects = objects,
BeatmapInfo = new BeatmapInfo
{
Difficulty = new BeatmapDifficulty(),
2017-02-22 22:27:29 +08:00
Metadata = new BeatmapMetadata
{
Artist = @"Unknown",
Title = @"Sample Beatmap",
Author = @"peppy",
}
}
};
2016-11-02 17:08:08 +08:00
beatmap = new TestWorkingBeatmap(b);
}
2016-11-02 17:08:08 +08:00
2016-11-17 20:29:35 +08:00
Add(new Box
{
RelativeSizeAxes = Framework.Graphics.Axes.Both,
Colour = Color4.Black,
2016-11-17 20:29:35 +08:00
});
Add(new PlayerLoader(Player = CreatePlayer(beatmap))
2016-11-09 07:13:20 +08:00
{
Beatmap = beatmap
});
}
protected virtual Player CreatePlayer(WorkingBeatmap beatmap)
{
return new Player
2017-02-22 20:43:29 +08:00
{
Beatmap = beatmap
};
}
2017-03-07 09:59:19 +08:00
private class TestWorkingBeatmap : WorkingBeatmap
{
public TestWorkingBeatmap(Beatmap beatmap)
: base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet)
{
Beatmap = beatmap;
}
protected override ArchiveReader GetReader() => null;
}
}
}