2016-09-29 19:13:58 +08:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2016-10-05 19:49:31 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.Objects;
|
2016-10-06 22:33:09 +08:00
|
|
|
|
using osu.Game.GameModes.Backgrounds;
|
2016-10-05 19:49:31 +08:00
|
|
|
|
using osu.Game.GameModes.Play.Catch;
|
|
|
|
|
using osu.Game.GameModes.Play.Mania;
|
|
|
|
|
using osu.Game.GameModes.Play.Osu;
|
|
|
|
|
using osu.Game.GameModes.Play.Taiko;
|
2016-10-10 16:17:26 +08:00
|
|
|
|
using osu.Framework;
|
2016-10-27 16:53:37 +08:00
|
|
|
|
using osu.Game.Database;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.GameModes.Play
|
|
|
|
|
{
|
2016-10-19 17:00:35 +08:00
|
|
|
|
public class Player : OsuGameMode
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2016-10-05 19:03:52 +08:00
|
|
|
|
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
|
|
|
|
|
|
2016-10-27 16:53:37 +08:00
|
|
|
|
public BeatmapInfo BeatmapInfo;
|
2016-10-19 17:00:35 +08:00
|
|
|
|
public Beatmap Beatmap;
|
|
|
|
|
|
|
|
|
|
public PlayMode PlayMode;
|
2016-10-05 19:49:31 +08:00
|
|
|
|
|
2016-10-10 16:17:26 +08:00
|
|
|
|
public override void Load(BaseGame game)
|
2016-10-05 19:49:31 +08:00
|
|
|
|
{
|
2016-10-10 16:17:26 +08:00
|
|
|
|
base.Load(game);
|
2016-10-05 19:49:31 +08:00
|
|
|
|
|
2016-10-27 19:37:01 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Beatmap == null)
|
|
|
|
|
Beatmap = ((OsuGame)game).Beatmaps.GetBeatmap(BeatmapInfo);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
//couldn't load, hard abort!
|
|
|
|
|
Exit();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-10-05 19:49:31 +08:00
|
|
|
|
|
2016-10-19 18:44:03 +08:00
|
|
|
|
HitRenderer hitRenderer;
|
|
|
|
|
ScoreOverlay scoreOverlay;
|
|
|
|
|
|
2016-10-19 17:00:35 +08:00
|
|
|
|
switch (PlayMode)
|
2016-10-05 19:49:31 +08:00
|
|
|
|
{
|
2016-10-19 18:44:03 +08:00
|
|
|
|
default:
|
|
|
|
|
scoreOverlay = new ScoreOverlayOsu();
|
|
|
|
|
|
|
|
|
|
hitRenderer = new OsuHitRenderer
|
2016-10-05 19:49:31 +08:00
|
|
|
|
{
|
2016-10-27 16:53:37 +08:00
|
|
|
|
Objects = Beatmap.HitObjects,
|
2016-10-05 19:49:31 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre
|
2016-10-19 18:44:03 +08:00
|
|
|
|
};
|
2016-10-05 19:49:31 +08:00
|
|
|
|
break;
|
|
|
|
|
case PlayMode.Taiko:
|
2016-10-19 18:44:03 +08:00
|
|
|
|
scoreOverlay = null;
|
|
|
|
|
|
|
|
|
|
hitRenderer = new TaikoHitRenderer
|
2016-10-05 19:49:31 +08:00
|
|
|
|
{
|
2016-10-27 16:53:37 +08:00
|
|
|
|
Objects = Beatmap.HitObjects,
|
2016-10-05 19:49:31 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre
|
2016-10-19 18:44:03 +08:00
|
|
|
|
};
|
2016-10-05 19:49:31 +08:00
|
|
|
|
break;
|
|
|
|
|
case PlayMode.Catch:
|
2016-10-19 18:44:03 +08:00
|
|
|
|
scoreOverlay = null;
|
|
|
|
|
|
|
|
|
|
hitRenderer = new CatchHitRenderer
|
2016-10-05 19:49:31 +08:00
|
|
|
|
{
|
2016-10-27 16:53:37 +08:00
|
|
|
|
Objects = Beatmap.HitObjects,
|
2016-10-05 19:49:31 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre
|
2016-10-19 18:44:03 +08:00
|
|
|
|
};
|
2016-10-05 19:49:31 +08:00
|
|
|
|
break;
|
|
|
|
|
case PlayMode.Mania:
|
2016-10-19 18:44:03 +08:00
|
|
|
|
scoreOverlay = null;
|
|
|
|
|
|
|
|
|
|
hitRenderer = new ManiaHitRenderer
|
2016-10-05 19:49:31 +08:00
|
|
|
|
{
|
2016-10-27 16:53:37 +08:00
|
|
|
|
Objects = Beatmap.HitObjects,
|
2016-10-05 19:49:31 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre
|
2016-10-19 18:44:03 +08:00
|
|
|
|
};
|
2016-10-05 19:49:31 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2016-10-06 22:33:09 +08:00
|
|
|
|
|
2016-10-19 18:44:03 +08:00
|
|
|
|
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
|
|
|
|
|
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
2016-10-06 22:33:09 +08:00
|
|
|
|
{
|
2016-10-19 18:44:03 +08:00
|
|
|
|
hitRenderer,
|
|
|
|
|
scoreOverlay,
|
|
|
|
|
};
|
2016-10-05 19:49:31 +08:00
|
|
|
|
}
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
2016-10-05 19:49:31 +08:00
|
|
|
|
}
|