1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00
osu-lazer/osu.Game/Screens/Menu/IntroSequence.cs

297 lines
12 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
2017-10-05 04:06:31 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
2017-10-05 04:06:31 +08:00
using OpenTK;
2017-10-05 07:50:13 +08:00
using OpenTK.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;
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
2017-10-10 23:30:46 +08:00
private OsuSpriteText welcomeText;
2017-10-05 04:06:31 +08:00
private Container<Box> lines;
private Box lineTopLeft;
private Box lineBottomLeft;
private Box lineTopRight;
private Box lineBottomRight;
2017-10-05 07:50:13 +08:00
private Ring smallRing;
private Ring mediumRing;
private Ring bigRing;
2017-10-05 07:50:13 +08:00
private Box backgroundFill;
private Box foregroundFill;
2017-10-05 07:50:13 +08:00
private CircularContainer pinkCircle;
private CircularContainer blueCircle;
private CircularContainer yellowCircle;
private CircularContainer purpleCircle;
2017-10-05 07:50:13 +08:00
2017-10-05 04:06:31 +08:00
public IntroSequence()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
const int line_offset = 80;
const int circle_offset = 250;
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,
2017-11-08 11:07:52 +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(OsuColour.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 = @"Exo2.0-Light",
Alpha = 0,
TextSize = 42,
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,
2017-11-08 11:10:32 +08:00
Colour = OsuColour.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 = OsuColour.FromHex(@"AA92FF"),
},
blueCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Position = new Vector2(-circle_offset, 0),
Colour = OsuColour.FromHex(@"8FE5FE"),
},
yellowCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Position = new Vector2(0, -circle_offset),
Colour = OsuColour.FromHex(@"FFD64C"),
},
pinkCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Position = new Vector2(circle_offset, 0),
Colour = OsuColour.FromHex(@"e967a1"),
},
2017-10-05 04:06:31 +08:00
};
2017-11-08 11:06:22 +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;
}
Scale = new Vector2(0.5f);
2017-11-08 11:06:22 +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();
}
2017-11-01 16:07:03 +08:00
2017-11-08 11:06:22 +08:00
smallRing.ResizeTo(logo_size * 0.086f, 400, Easing.InOutQuint);
mediumRing.ResizeTo(130, 340, Easing.OutQuad);
mediumRing.Foreground.ResizeTo(1, 880, Easing.Out);
2017-11-01 16:07:03 +08:00
2018-01-16 02:42:17 +08:00
double remainingTime() => length - TransformDelay;
2017-10-06 02:37:37 +08:00
2017-11-08 11:06:22 +08:00
using (BeginDelayedSequence(250, true))
{
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);
2017-10-05 07:50:13 +08:00
2017-11-08 10:21:50 +08:00
const int line_duration = 700;
const int line_resize = 150;
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
}
2017-10-05 07:50:13 +08:00
2017-11-08 10:21:50 +08:00
const int line_end_offset = 120;
2017-11-08 11:06:22 +08:00
smallRing.Foreground.ResizeTo(1, line_duration, Easing.OutQuint);
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);
2017-10-05 07:50:13 +08:00
2017-11-08 13:31:11 +08:00
using (BeginDelayedSequence(length * 0.56, true))
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);
2017-10-05 07:50:13 +08:00
2017-11-08 13:31:11 +08:00
using (BeginDelayedSequence(250, true))
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);
2017-10-05 07:50:13 +08:00
2017-11-08 10:20:21 +08:00
using (BeginDelayedSequence(50, true))
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);
}
2017-10-05 07:50:13 +08:00
this.ScaleTo(1, remainingTime(), Easing.InOutCubic);
2017-11-08 10:20:21 +08:00
const float circle_size = logo_size * 0.9f;
2017-10-05 07:50:13 +08:00
2017-11-08 10:20:21 +08:00
const int rotation_delay = 110;
const int appear_delay = 80;
2017-10-05 07:50:13 +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);
2017-10-05 07:50:13 +08:00
2017-11-08 10:20:21 +08:00
using (BeginDelayedSequence(appear_delay, true))
{
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);
2017-11-03 16:54:35 +08:00
using (BeginDelayedSequence(appear_delay, true))
{
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);
2017-11-03 16:54:35 +08:00
using (BeginDelayedSequence(appear_delay, true))
{
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
}
private class Ring : Container<Circle>
2017-10-05 07:50:13 +08:00
{
public readonly Circle Foreground;
2017-10-05 07:50:13 +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
}
}