osu/osu.Game/Screens/Menu/Intro.cs

125 lines
3.7 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-14 08:23:33 +00:00
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.GameModes;
2016-10-07 08:07:23 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics.Containers;
2016-11-14 08:23:33 +00:00
using osu.Game.Screens.Backgrounds;
2016-10-07 08:07:23 +00:00
using OpenTK.Graphics;
2016-11-14 08:23:33 +00:00
namespace osu.Game.Screens.Menu
{
class Intro : OsuGameMode
{
2016-10-07 08:07:23 +00:00
private OsuLogo logo;
/// <summary>
/// Whether we have loaded the menu previously.
/// </summary>
internal bool DidLoadMenu;
2016-11-01 14:24:14 +00:00
MainMenu mainMenu;
private AudioSample welcome;
private AudioSample seeya;
2016-11-01 14:24:14 +00:00
private AudioTrack bgm;
internal override bool ShowOverlays => (ParentGameMode as OsuGameMode)?.ShowOverlays ?? false;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
2016-11-01 14:24:14 +00:00
public Intro()
{
2016-10-07 08:07:23 +00:00
Children = new Drawable[]
{
new ParallaxContainer
2016-10-07 08:07:23 +00:00
{
ParallaxAmount = 0.01f,
Children = new Drawable[]
{
logo = new OsuLogo
{
Alpha = 0,
Triangles = false,
BlendingMode = BlendingMode.Additive,
Interactive = false,
Colour = Color4.DarkGray,
Ripple = false
}
}
2016-10-07 08:07:23 +00:00
}
};
2016-11-01 14:24:14 +00:00
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
2016-11-01 14:24:14 +00:00
{
2016-11-08 23:13:20 +00:00
welcome = audio.Sample.Get(@"welcome");
seeya = audio.Sample.Get(@"seeya");
2016-10-07 08:07:23 +00:00
2016-11-08 23:13:20 +00:00
bgm = audio.Track.Get(@"circles");
bgm.Looping = true;
2016-11-01 14:24:14 +00:00
}
2016-11-01 14:24:14 +00:00
protected override void LoadComplete()
{
base.LoadComplete();
Scheduler.Add(delegate
2016-10-07 08:07:23 +00: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 08:07:23 +00:00
2016-11-01 14:24:14 +00:00
logo.ScaleTo(0.4f);
logo.FadeOut();
logo.ScaleTo(1, 4400, EasingTypes.OutQuint);
logo.FadeIn(20000, EasingTypes.OutQuint);
2016-10-07 08:07:23 +00: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 also handle the exit transition.
seeya.Play();
double fadeOutTime = (last.LifetimeEnd - Time.Current) + 100;
Scheduler.AddDelayed(Exit, fadeOutTime);
//don't want to fade out completely else we will stop running updates and shit will hit the fan.
Game.FadeTo(0.01f, fadeOutTime);
base.OnResuming(last);
}
}
}