1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 15:02:55 +08:00
osu-lazer/osu.Game/Screens/Menu/Intro.cs

128 lines
3.6 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
2016-11-14 16:23:33 +08:00
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
2017-02-17 17:59:30 +08:00
using osu.Framework.Screens;
2016-10-07 16:07:23 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics.Containers;
2016-11-14 16:23:33 +08:00
using osu.Game.Screens.Backgrounds;
2016-10-07 16:07:23 +08:00
using OpenTK.Graphics;
2016-11-14 16:23:33 +08:00
namespace osu.Game.Screens.Menu
{
2017-02-18 13:16:46 +08:00
public class Intro : OsuScreen
{
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 SampleChannel welcome;
private SampleChannel seeya;
private Track bgm;
2016-11-01 22:24:14 +08:00
internal override bool ShowOverlays => false;
2017-02-17 17:59:30 +08:00
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
2016-11-01 22:24:14 +08:00
public Intro()
{
2016-10-07 16:07:23 +08:00
Children = new Drawable[]
{
new ParallaxContainer
2016-10-07 16:07:23 +08: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 16:07:23 +08:00
}
};
2016-11-01 22:24:14 +08:00
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
2016-11-01 22:24:14 +08:00
{
2016-11-09 07:13:20 +08:00
welcome = audio.Sample.Get(@"welcome");
seeya = audio.Sample.Get(@"seeya");
2016-10-07 16:07:23 +08:00
2016-11-09 07:13:20 +08:00
bgm = audio.Track.Get(@"circles");
bgm.Looping = true;
2016-11-01 22:24:14 +08:00
}
2017-02-17 17:59:30 +08:00
protected override void OnEntering(Screen last)
2016-11-01 22:24:14 +08:00
{
base.OnEntering(last);
Scheduler.Add(delegate
2016-10-07 16:07:23 +08:00
{
welcome.Play();
Scheduler.AddDelayed(delegate
{
bgm.Start();
2017-02-17 17:59:30 +08:00
(mainMenu = new 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
}
2017-02-17 17:59:30 +08:00
protected override void OnSuspending(Screen next)
2016-10-07 16:07:23 +08:00
{
Content.FadeOut(300);
base.OnSuspending(next);
}
2017-02-17 17:59:30 +08:00
protected override bool OnExiting(Screen next)
{
//cancel exiting if we haven't loaded the menu yet.
return !DidLoadMenu;
}
2017-02-17 17:59:30 +08:00
protected override void OnResuming(Screen last)
{
2017-02-17 14:33:08 +08:00
if (!(last is MainMenu))
Content.FadeIn(300);
//we also handle the exit transition.
seeya.Play();
2017-02-17 14:33:08 +08:00
double fadeOutTime = 2000;
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);
}
}
}