1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 00:27:25 +08:00
osu-lazer/osu.Game/GameModes/Menu/Intro.cs

106 lines
2.9 KiB
C#
Raw Normal View History

//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-11-01 22:24:14 +08:00
using System.Threading;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.GameModes;
2016-10-07 16:07:23 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.GameModes.Backgrounds;
2016-10-07 16:07:23 +08:00
using OpenTK.Graphics;
using osu.Framework;
namespace osu.Game.GameModes.Menu
{
class Intro : OsuGameMode
{
2016-10-07 16:07:23 +08:00
private OsuLogo logo;
/// <summary>
/// Whether we have loaded the menu previously.
/// </summary>
internal bool DidLoadMenu;
2016-11-01 22:24:14 +08:00
MainMenu mainMenu;
private AudioSample welcome;
private AudioTrack bgm;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
2016-11-01 22:24:14 +08:00
public Intro()
{
2016-10-07 16:07:23 +08:00
Children = new Drawable[]
{
logo = new OsuLogo()
{
Alpha = 0,
BlendingMode = BlendingMode.Additive,
2016-10-07 16:07:23 +08:00
Interactive = false,
Colour = Color4.DarkGray,
Ripple = false
}
};
2016-11-01 22:24:14 +08:00
}
protected override void Load(BaseGame game)
{
base.Load(game);
2016-10-07 16:07:23 +08:00
2016-11-01 22:24:14 +08:00
welcome = game.Audio.Sample.Get(@"welcome");
2016-11-01 22:24:14 +08:00
bgm = game.Audio.Track.Get(@"circles");
bgm.Looping = true;
2016-11-01 22:24:14 +08:00
}
2016-11-01 22:24:14 +08:00
protected override void LoadComplete()
{
base.LoadComplete();
Scheduler.Add(delegate
2016-10-07 16:07:23 +08:00
{
welcome.Play();
Scheduler.AddDelayed(delegate
{
bgm.Start();
mainMenu = new MainMenu();
mainMenu.Preload(Game);
Scheduler.AddDelayed(delegate
{
DidLoadMenu = true;
Push(mainMenu);
}, 2300);
}, 600);
});
2016-10-07 16:07:23 +08:00
2016-11-01 22:24:14 +08:00
logo.ScaleTo(0.4f);
logo.FadeOut();
logo.ScaleTo(1, 4400, EasingTypes.OutQuint);
logo.FadeIn(20000, EasingTypes.OutQuint);
2016-10-07 16:07:23 +08:00
}
protected override void OnSuspending(GameMode next)
{
Content.FadeOut(300);
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
{
//cancel exiting if we haven't loaded the menu yet.
return !DidLoadMenu;
}
protected override void OnResuming(GameMode last)
{
//we are just an intro. if we are resumed, we just want to exit after a short delay (to allow the last mode to transition out).
Scheduler.AddDelayed(Exit, 600);
base.OnResuming(last);
}
}
}