1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 03:55:30 +08:00
osu-lazer/osu.Game/Screens/Menu/IntroSequence.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

300 lines
12 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
using System.Linq;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
2017-10-05 07:50:13 +08:00
using osu.Framework.Extensions.Color4Extensions;
2017-10-05 04:06:31 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-10-05 07:50:13 +08:00
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
2017-10-05 04:06:31 +08:00
using osu.Game.Graphics.Sprites;
2018-04-13 17:19:50 +08:00
2017-10-05 04:06:31 +08:00
namespace osu.Game.Screens.Menu
{
public class IntroSequence : Container
{
2017-11-03 16:54:35 +08:00
private const float logo_size = 460; //todo: this should probably be 480
2018-04-13 17:19:50 +08:00
private OsuSpriteText welcomeText;
2018-04-13 17:19:50 +08:00
private Container<Box> lines;
2018-04-13 17:19:50 +08:00
private Box lineTopLeft;
private Box lineBottomLeft;
private Box lineTopRight;
private Box lineBottomRight;
2018-04-13 17:19:50 +08:00
private Ring smallRing;
private Ring mediumRing;
private Ring bigRing;
2018-04-13 17:19:50 +08:00
private Box backgroundFill;
private Box foregroundFill;
2018-04-13 17:19:50 +08:00
private CircularContainer pinkCircle;
private CircularContainer blueCircle;
private CircularContainer yellowCircle;
private CircularContainer purpleCircle;
2018-04-13 17:19:50 +08:00
2017-10-05 04:06:31 +08:00
public IntroSequence()
{
RelativeSizeAxes = Axes.Both;
Alpha = 0;
}
2018-04-13 17:19:50 +08:00
[BackgroundDependencyLoader]
private void load()
{
const int line_offset = 80;
const int circle_offset = 250;
2018-04-13 17:19:50 +08:00
2017-10-05 04:06:31 +08:00
Children = new Drawable[]
{
2017-11-08 11:07:52 +08:00
lines = new Container<Box>
2017-10-05 04:06:31 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
2019-02-28 12:31:40 +08:00
Children = new[]
2017-10-05 07:50:13 +08:00
{
2017-11-08 11:07:52 +08:00
lineTopLeft = new Box
2017-10-05 07:50:13 +08:00
{
Origin = Anchor.CentreLeft,
2017-10-05 07:50:13 +08:00
Anchor = Anchor.Centre,
Position = new Vector2(-line_offset, -line_offset),
Rotation = 45,
2017-11-08 11:07:52 +08:00
Colour = Color4.White.Opacity(180),
},
2017-11-08 11:07:52 +08:00
lineTopRight = new Box
{
Origin = Anchor.CentreRight,
Anchor = Anchor.Centre,
Position = new Vector2(line_offset, -line_offset),
Rotation = -45,
2017-11-08 11:07:52 +08:00
Colour = Color4.White.Opacity(80),
2017-10-05 07:50:13 +08:00
},
2017-11-08 11:07:52 +08:00
lineBottomLeft = new Box
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.Centre,
Position = new Vector2(-line_offset, line_offset),
Rotation = -45,
2017-11-08 11:07:52 +08:00
Colour = Color4.White.Opacity(230),
},
2017-11-08 11:07:52 +08:00
lineBottomRight = new Box
{
Origin = Anchor.CentreRight,
Anchor = Anchor.Centre,
Position = new Vector2(line_offset, line_offset),
Rotation = 45,
2017-11-08 11:07:52 +08:00
Colour = Color4.White.Opacity(130),
},
}
},
bigRing = new Ring(Color4Extensions.FromHex(@"B6C5E9"), 0.85f),
mediumRing = new Ring(Color4.White.Opacity(130), 0.7f),
smallRing = new Ring(Color4.White, 0.6f),
welcomeText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = "welcome",
Padding = new MarginPadding { Bottom = 10 },
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 42),
Alpha = 0,
Spacing = new Vector2(5),
},
new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2017-10-10 23:30:46 +08:00
Size = new Vector2(logo_size),
Masking = true,
Children = new Drawable[]
{
2017-11-08 11:10:32 +08:00
backgroundFill = new Box
2017-10-05 07:50:13 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Height = 0,
Colour = Color4Extensions.FromHex(@"C6D8FF").Opacity(160),
2017-10-05 07:50:13 +08:00
},
2017-11-08 11:10:32 +08:00
foregroundFill = new Box
2017-10-05 07:50:13 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = Vector2.Zero,
RelativeSizeAxes = Axes.Both,
Width = 0,
2017-11-08 11:10:32 +08:00
Colour = Color4.White,
2017-10-05 07:50:13 +08:00
},
}
},
purpleCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, circle_offset),
Colour = Color4Extensions.FromHex(@"AA92FF"),
},
blueCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Position = new Vector2(-circle_offset, 0),
Colour = Color4Extensions.FromHex(@"8FE5FE"),
},
yellowCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Position = new Vector2(0, -circle_offset),
Colour = Color4Extensions.FromHex(@"FFD64C"),
},
pinkCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Position = new Vector2(circle_offset, 0),
Colour = Color4Extensions.FromHex(@"e967a1"),
},
2017-10-05 04:06:31 +08:00
};
2018-04-13 17:19:50 +08:00
2017-11-08 11:07:52 +08:00
foreach (var line in lines)
2017-11-08 11:06:22 +08:00
{
line.Size = new Vector2(105, 1.5f);
line.Alpha = 0;
}
2018-04-13 17:19:50 +08:00
Scale = new Vector2(0.5f);
2017-11-08 11:06:22 +08:00
}
2018-04-13 17:19:50 +08:00
2017-11-03 16:54:35 +08:00
public void Start(double length)
2017-10-05 04:06:31 +08:00
{
if (Children.Any())
{
// restart if we were already run previously.
FinishTransforms(true);
load();
}
2018-04-13 17:19:50 +08:00
2017-11-08 11:06:22 +08:00
smallRing.ResizeTo(logo_size * 0.086f, 400, Easing.InOutQuint);
2018-04-13 17:19:50 +08:00
2017-11-08 11:06:22 +08:00
mediumRing.ResizeTo(130, 340, Easing.OutQuad);
mediumRing.Foreground.ResizeTo(1, 880, Easing.Out);
2018-04-13 17:19:50 +08:00
2018-01-16 02:42:17 +08:00
double remainingTime() => length - TransformDelay;
2018-04-13 17:19:50 +08:00
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(250))
{
2017-11-03 16:54:35 +08:00
welcomeText.FadeIn(700);
2017-11-08 10:20:21 +08:00
welcomeText.TransformSpacingTo(new Vector2(20, 0), remainingTime(), Easing.Out);
2018-04-13 17:19:50 +08:00
2017-11-08 10:21:50 +08:00
const int line_duration = 700;
const int line_resize = 150;
2018-04-13 17:19:50 +08:00
2017-11-08 11:07:52 +08:00
foreach (var line in lines)
{
2017-11-08 11:06:22 +08:00
line.FadeIn(40).ResizeWidthTo(0, line_duration - line_resize, Easing.OutQuint);
2017-11-08 10:20:21 +08:00
}
2018-04-13 17:19:50 +08:00
2017-11-08 10:21:50 +08:00
const int line_end_offset = 120;
2018-04-13 17:19:50 +08:00
2017-11-08 11:06:22 +08:00
smallRing.Foreground.ResizeTo(1, line_duration, Easing.OutQuint);
smallRing.Delay(400).FadeColour(Color4.Black, 300);
2018-04-13 17:19:50 +08:00
2017-11-08 10:21:50 +08:00
lineTopLeft.MoveTo(new Vector2(-line_end_offset, -line_end_offset), line_duration, Easing.OutQuint);
lineTopRight.MoveTo(new Vector2(line_end_offset, -line_end_offset), line_duration, Easing.OutQuint);
lineBottomLeft.MoveTo(new Vector2(-line_end_offset, line_end_offset), line_duration, Easing.OutQuint);
lineBottomRight.MoveTo(new Vector2(line_end_offset, line_end_offset), line_duration, Easing.OutQuint);
2018-04-13 17:19:50 +08:00
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(length * 0.56))
2017-11-08 10:20:21 +08:00
{
2017-11-09 17:12:33 +08:00
bigRing.ResizeTo(logo_size, 500, Easing.InOutQuint);
bigRing.Foreground.Delay(250).ResizeTo(1, 850, Easing.OutQuint);
2018-04-13 17:19:50 +08:00
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(250))
2017-11-03 16:54:35 +08:00
{
2017-11-08 10:20:21 +08:00
backgroundFill.ResizeHeightTo(1, remainingTime(), Easing.InOutQuart);
backgroundFill.RotateTo(-90, remainingTime(), Easing.InOutQuart);
2018-04-13 17:19:50 +08:00
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(50))
2017-11-03 16:54:35 +08:00
{
2017-11-08 10:20:21 +08:00
foregroundFill.ResizeWidthTo(1, remainingTime(), Easing.InOutQuart);
foregroundFill.RotateTo(-90, remainingTime(), Easing.InOutQuart);
}
2018-04-13 17:19:50 +08:00
this.ScaleTo(1, remainingTime(), Easing.InOutCubic);
2018-04-13 17:19:50 +08:00
2017-11-08 10:20:21 +08:00
const float circle_size = logo_size * 0.9f;
2018-04-13 17:19:50 +08:00
2017-11-08 10:20:21 +08:00
const int rotation_delay = 110;
const int appear_delay = 80;
2018-04-13 17:19:50 +08:00
purpleCircle.MoveToY(circle_size / 2, remainingTime(), Easing.InOutQuart);
purpleCircle.Delay(rotation_delay).RotateTo(-180, remainingTime() - rotation_delay, Easing.InOutQuart);
purpleCircle.ResizeTo(circle_size, remainingTime(), Easing.InOutQuart);
2018-04-13 17:19:50 +08:00
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(appear_delay))
2017-11-08 10:20:21 +08:00
{
yellowCircle.MoveToY(-circle_size / 2, remainingTime(), Easing.InOutQuart);
yellowCircle.Delay(rotation_delay).RotateTo(-180, remainingTime() - rotation_delay, Easing.InOutQuart);
yellowCircle.ResizeTo(circle_size, remainingTime(), Easing.InOutQuart);
2018-04-13 17:19:50 +08:00
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(appear_delay))
2017-11-03 16:54:35 +08:00
{
blueCircle.MoveToX(-circle_size / 2, remainingTime(), Easing.InOutQuart);
blueCircle.Delay(rotation_delay).RotateTo(-180, remainingTime() - rotation_delay, Easing.InOutQuart);
blueCircle.ResizeTo(circle_size, remainingTime(), Easing.InOutQuart);
2018-04-13 17:19:50 +08:00
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(appear_delay))
2017-11-03 16:54:35 +08:00
{
pinkCircle.MoveToX(circle_size / 2, remainingTime(), Easing.InOutQuart);
pinkCircle.Delay(rotation_delay).RotateTo(-180, remainingTime() - rotation_delay, Easing.InOutQuart);
pinkCircle.ResizeTo(circle_size, remainingTime(), Easing.InOutQuart);
2017-11-03 16:54:35 +08:00
}
}
}
}
}
}
2017-10-05 04:06:31 +08:00
}
2018-04-13 17:19:50 +08:00
private class Ring : Container<Circle>
2017-10-05 07:50:13 +08:00
{
public readonly Circle Foreground;
2018-04-13 17:19:50 +08:00
public Ring(Color4 ringColour, float foregroundSize)
2017-10-05 07:50:13 +08:00
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
2017-10-10 11:06:09 +08:00
Children = new[]
2017-10-05 07:50:13 +08:00
{
new Circle
2017-10-05 07:50:13 +08:00
{
2017-10-10 11:06:09 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
2017-11-08 11:06:22 +08:00
Scale = new Vector2(0.98f),
Colour = ringColour,
2017-10-05 07:50:13 +08:00
},
Foreground = new Circle
2017-10-05 07:50:13 +08:00
{
Size = new Vector2(foregroundSize),
2017-10-05 07:50:13 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
2017-10-05 07:50:13 +08:00
}
};
}
}
2017-10-05 04:06:31 +08:00
}
}