1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 18:27:31 +08:00
osu-lazer/osu.Game/Screens/Menu/IntroSequence.cs

298 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
using System.Linq;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Menu
{
public class IntroSequence : Container
{
private const float logo_size = 460; //todo: this should probably be 480
private OsuSpriteText welcomeText;
private Container<Box> lines;
private Box lineTopLeft;
private Box lineBottomLeft;
private Box lineTopRight;
private Box lineBottomRight;
private Ring smallRing;
private Ring mediumRing;
private Ring bigRing;
private Box backgroundFill;
private Box foregroundFill;
private CircularContainer pinkCircle;
private CircularContainer blueCircle;
private CircularContainer yellowCircle;
private CircularContainer purpleCircle;
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;
Children = new Drawable[]
{
lines = new Container<Box>
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
2019-02-28 12:31:40 +08:00
Children = new[]
2018-04-13 17:19:50 +08:00
{
lineTopLeft = new Box
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.Centre,
Position = new Vector2(-line_offset, -line_offset),
Rotation = 45,
Colour = Color4.White.Opacity(180),
},
lineTopRight = new Box
{
Origin = Anchor.CentreRight,
Anchor = Anchor.Centre,
Position = new Vector2(line_offset, -line_offset),
Rotation = -45,
Colour = Color4.White.Opacity(80),
},
lineBottomLeft = new Box
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.Centre,
Position = new Vector2(-line_offset, line_offset),
Rotation = -45,
Colour = Color4.White.Opacity(230),
},
lineBottomRight = new Box
{
Origin = Anchor.CentreRight,
Anchor = Anchor.Centre,
Position = new Vector2(line_offset, line_offset),
Rotation = 45,
Colour = Color4.White.Opacity(130),
},
}
},
bigRing = new Ring(Color4Extensions.FromHex(@"B6C5E9"), 0.85f),
2018-04-13 17:19:50 +08:00
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),
2018-04-13 17:19:50 +08:00
Alpha = 0,
Spacing = new Vector2(5),
},
new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(logo_size),
Masking = true,
Children = new Drawable[]
{
backgroundFill = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Height = 0,
Colour = Color4Extensions.FromHex(@"C6D8FF").Opacity(160),
2018-04-13 17:19:50 +08:00
},
foregroundFill = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = Vector2.Zero,
RelativeSizeAxes = Axes.Both,
Width = 0,
Colour = Color4.White,
},
}
},
purpleCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, circle_offset),
Colour = Color4Extensions.FromHex(@"AA92FF"),
2018-04-13 17:19:50 +08:00
},
blueCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Position = new Vector2(-circle_offset, 0),
Colour = Color4Extensions.FromHex(@"8FE5FE"),
2018-04-13 17:19:50 +08:00
},
yellowCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Position = new Vector2(0, -circle_offset),
Colour = Color4Extensions.FromHex(@"FFD64C"),
2018-04-13 17:19:50 +08:00
},
pinkCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Position = new Vector2(circle_offset, 0),
Colour = Color4Extensions.FromHex(@"e967a1"),
2018-04-13 17:19:50 +08:00
},
};
foreach (var line in lines)
{
line.Size = new Vector2(105, 1.5f);
line.Alpha = 0;
}
Scale = new Vector2(0.5f);
}
public void Start(double length)
{
if (Children.Any())
{
// restart if we were already run previously.
FinishTransforms(true);
load();
}
smallRing.ResizeTo(logo_size * 0.086f, 400, Easing.InOutQuint);
mediumRing.ResizeTo(130, 340, Easing.OutQuad);
mediumRing.Foreground.ResizeTo(1, 880, Easing.Out);
double remainingTime() => length - TransformDelay;
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(250))
2018-04-13 17:19:50 +08:00
{
welcomeText.FadeIn(700);
welcomeText.TransformSpacingTo(new Vector2(20, 0), remainingTime(), Easing.Out);
const int line_duration = 700;
const int line_resize = 150;
foreach (var line in lines)
{
line.FadeIn(40).ResizeWidthTo(0, line_duration - line_resize, Easing.OutQuint);
}
const int line_end_offset = 120;
smallRing.Foreground.ResizeTo(1, line_duration, Easing.OutQuint);
smallRing.Delay(400).FadeColour(Color4.Black, 300);
2018-04-13 17:19: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);
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(length * 0.56))
2018-04-13 17:19:50 +08:00
{
bigRing.ResizeTo(logo_size, 500, Easing.InOutQuint);
bigRing.Foreground.Delay(250).ResizeTo(1, 850, Easing.OutQuint);
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(250))
2018-04-13 17:19:50 +08:00
{
backgroundFill.ResizeHeightTo(1, remainingTime(), Easing.InOutQuart);
backgroundFill.RotateTo(-90, remainingTime(), Easing.InOutQuart);
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(50))
2018-04-13 17:19:50 +08:00
{
foregroundFill.ResizeWidthTo(1, remainingTime(), Easing.InOutQuart);
foregroundFill.RotateTo(-90, remainingTime(), Easing.InOutQuart);
}
this.ScaleTo(1, remainingTime(), Easing.InOutCubic);
const float circle_size = logo_size * 0.9f;
const int rotation_delay = 110;
const int appear_delay = 80;
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);
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(appear_delay))
2018-04-13 17:19:50 +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);
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(appear_delay))
2018-04-13 17:19:50 +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);
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(appear_delay))
2018-04-13 17:19:50 +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);
}
}
}
}
}
}
}
private class Ring : Container<Circle>
{
public readonly Circle Foreground;
public Ring(Color4 ringColour, float foregroundSize)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Children = new[]
{
new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.98f),
Colour = ringColour,
},
Foreground = new Circle
{
Size = new Vector2(foregroundSize),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
}
};
}
}
}
}