示例#1
0
        protected override void Load(BaseGame game)
        {
            base.Load(game);

            try
            {
                if (Beatmap == null)
                {
                    Beatmap = ((OsuGame)game).Beatmaps.GetWorkingBeatmap(BeatmapInfo);
                }
            }
            catch
            {
                //couldn't load, hard abort!
                Exit();
                return;
            }

            AudioTrack track = Beatmap.Track;

            if (track != null)
            {
                game.Audio.Track.SetExclusive(track);
                sourceClock = track;
            }

            sourceClock = (IAdjustableClock)track ?? new StopwatchClock();
            playerClock = new InterpolatingFramedClock(sourceClock);

            Schedule(() =>
            {
                sourceClock.Reset();
                sourceClock.Start();
            });

            HitRenderer  hitRenderer;
            ScoreOverlay scoreOverlay;

            var beatmap = Beatmap.Beatmap;

            if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu)
            {
                //we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
                Exit();
                return;
            }

            PlayMode usablePlayMode = beatmap.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode;

            switch (usablePlayMode)
            {
            default:
                scoreOverlay = new ScoreOverlayOsu();

                hitRenderer = new OsuHitRenderer
                {
                    Objects = beatmap.HitObjects,
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre
                };
                break;

            case PlayMode.Taiko:
                scoreOverlay = new ScoreOverlayOsu();

                hitRenderer = new TaikoHitRenderer
                {
                    Objects = beatmap.HitObjects,
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre
                };
                break;

            case PlayMode.Catch:
                scoreOverlay = new ScoreOverlayOsu();

                hitRenderer = new CatchHitRenderer
                {
                    Objects = beatmap.HitObjects,
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre
                };
                break;

            case PlayMode.Mania:
                scoreOverlay = new ScoreOverlayOsu();

                hitRenderer = new ManiaHitRenderer
                {
                    Objects = beatmap.HitObjects,
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre
                };
                break;
            }

            hitRenderer.OnHit  += delegate(HitObject h) { scoreOverlay.OnHit(h); };
            hitRenderer.OnMiss += delegate(HitObject h) { scoreOverlay.OnMiss(h); };

            if (autoplay)
            {
                hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Armed));
            }

            Children = new Drawable[]
            {
                hitRenderer,
                scoreOverlay,
            };
        }
示例#2
0
        public override void Load(BaseGame game)
        {
            base.Load(game);

            try
            {
                if (Beatmap == null)
                {
                    Beatmap = ((OsuGame)game).Beatmaps.GetBeatmap(BeatmapInfo);
                }
            }
            catch
            {
                //couldn't load, hard abort!
                Exit();
                return;
            }

            HitRenderer  hitRenderer;
            ScoreOverlay scoreOverlay;

            switch (PlayMode)
            {
            default:
                scoreOverlay = new ScoreOverlayOsu();

                hitRenderer = new OsuHitRenderer
                {
                    Objects = Beatmap.HitObjects,
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre
                };
                break;

            case PlayMode.Taiko:
                scoreOverlay = new ScoreOverlayOsu();

                hitRenderer = new TaikoHitRenderer
                {
                    Objects = Beatmap.HitObjects,
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre
                };
                break;

            case PlayMode.Catch:
                scoreOverlay = new ScoreOverlayOsu();

                hitRenderer = new CatchHitRenderer
                {
                    Objects = Beatmap.HitObjects,
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre
                };
                break;

            case PlayMode.Mania:
                scoreOverlay = new ScoreOverlayOsu();

                hitRenderer = new ManiaHitRenderer
                {
                    Objects = Beatmap.HitObjects,
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre
                };
                break;
            }

            hitRenderer.OnHit  += delegate(HitObject h) { scoreOverlay.OnHit(h); };
            hitRenderer.OnMiss += delegate(HitObject h) { scoreOverlay.OnMiss(h); };

            Children = new Drawable[]
            {
                hitRenderer,
                scoreOverlay,
            };
        }