osu/osu.Game/Screens/Menu/IntroSequence.cs

347 lines
15 KiB
C#
Raw Normal View History

2017-10-04 20:06:31 +00:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-11-03 08:54:35 +00:00
using System;
2017-10-04 20:06:31 +00:00
using OpenTK;
2017-10-04 23:50:13 +00:00
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
2017-10-04 20:06:31 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-10-04 23:50:13 +00:00
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
2017-10-04 20:06:31 +00:00
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Menu
{
public class IntroSequence : Container
{
2017-10-10 15:30:46 +00:00
//Size
2017-11-03 08:54:35 +00:00
private const float logo_size = 460; //todo: this should probably be 480
2017-10-10 15:30:46 +00:00
2017-10-09 22:36:40 +00:00
private readonly OsuSpriteText welcomeText;
2017-10-04 20:06:31 +00:00
private readonly Container barsContainer;
2017-10-04 23:50:13 +00:00
private readonly Container barTopLeft;
private readonly Container barBottomLeft;
private readonly Container barTopRight;
private readonly Container barBottomRight;
private readonly Ring smallRing;
private readonly Ring mediumRing;
private readonly Ring bigRing;
private readonly Container backgroundFill;
private readonly Container foregroundFill;
private readonly CircularContainer pinkCircle;
private readonly CircularContainer blueCircle;
private readonly CircularContainer yellowCircle;
private readonly CircularContainer purpleCircle;
2017-10-04 20:06:31 +00:00
public IntroSequence()
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
2017-10-10 17:06:18 +00:00
mediumRing = new Ring(Color4.White.Opacity(130)),
barsContainer = new Container
2017-10-04 20:06:31 +00:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
2017-10-04 23:50:13 +00:00
Children = new Drawable[]
{
barTopLeft = new Container
2017-10-04 23:50:13 +00:00
{
Origin = Anchor.CentreLeft,
2017-10-04 23:50:13 +00:00
Anchor = Anchor.Centre,
Rotation = 45,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White.Opacity(180),
}
},
barTopRight = new Container
{
Origin = Anchor.CentreRight,
Anchor = Anchor.Centre,
Rotation = -45,
Child = new Box
2017-10-04 23:50:13 +00:00
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White.Opacity(80),
2017-10-04 23:50:13 +00:00
}
},
barBottomLeft = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.Centre,
Rotation = -45,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White.Opacity(230),
}
},
barBottomRight = new Container
{
Origin = Anchor.CentreRight,
Anchor = Anchor.Centre,
Rotation = 45,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White.Opacity(130),
}
},
}
},
smallRing = new Ring(Color4.White),
bigRing = new Ring(OsuColour.FromHex(@"B6C5E9")),
new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2017-10-10 15:30:46 +00:00
Size = new Vector2(logo_size),
Masking = true,
Children = new Drawable[]
{
2017-10-04 23:50:13 +00:00
backgroundFill = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
2017-10-04 23:50:13 +00:00
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"C6D8FF").Opacity(160),
}
},
welcomeText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = "welcome",
Font = @"Exo2.0-Light",
TextSize = 42,
},
foregroundFill = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
2017-10-04 23:50:13 +00:00
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
}
},
}
},
purpleCircle = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
Masking = true,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
2017-10-05 18:37:37 +00:00
Colour = OsuColour.FromHex(@"AA92FF"),
2017-10-04 23:50:13 +00:00
}
},
yellowCircle = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Masking = true,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
2017-10-05 18:37:37 +00:00
Colour = OsuColour.FromHex(@"FFD64C"),
2017-10-04 23:50:13 +00:00
}
},
blueCircle = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Masking = true,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
2017-10-05 18:37:37 +00:00
Colour = OsuColour.FromHex(@"8FE5FE"),
2017-10-04 23:50:13 +00:00
}
},
pinkCircle = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Masking = true,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
2017-10-05 18:37:37 +00:00
Colour = OsuColour.FromHex(@"e967a1"),
2017-10-04 23:50:13 +00:00
}
2017-10-05 18:37:37 +00:00
},
2017-10-04 20:06:31 +00:00
};
}
2017-11-03 08:54:35 +00:00
public void Start(double length)
2017-10-04 20:06:31 +00:00
{
2017-11-03 08:54:35 +00:00
FinishTransforms(true);
setDefaults();
2017-11-01 08:07:03 +00:00
2017-11-03 08:54:35 +00:00
mediumRing.ResizeTo(130, 360, Easing.InExpo).OnComplete(r => r.Foreground.ResizeTo(1, 420, Easing.OutQuad));
2017-11-01 08:07:03 +00:00
2017-11-03 08:54:35 +00:00
Func<double> remainingTime = () => length - TransformDelay;
2017-10-05 18:37:37 +00:00
using (BeginDelayedSequence(200, true))
{
2017-11-03 08:54:35 +00:00
welcomeText.FadeIn(700);
welcomeText.TransformSpacingTo(new Vector2(20, 0), 1500, Easing.Out);
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
smallRing.ResizeTo(logo_size * 0.086f, 250, Easing.InExpo).OnComplete(r => r.Foreground.ResizeTo(1, 650, Easing.OutQuad));
2017-11-03 08:54:35 +00:00
using (BeginDelayedSequence(160, true))
{
2017-11-03 08:54:35 +00:00
const int bar_duration = 700;
const int bar_resize = 150;
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
foreach (var bar in barsContainer)
{
bar.FadeIn();
bar.Delay(bar_resize).ResizeWidthTo(0, bar_duration - bar_resize, Easing.OutQuint);
}
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
const int bar_end_offset = 120;
barTopLeft.MoveTo(new Vector2(-bar_end_offset, -bar_end_offset), bar_duration, Easing.OutQuint);
barTopRight.MoveTo(new Vector2(bar_end_offset, -bar_end_offset), bar_duration, Easing.OutQuint);
barBottomLeft.MoveTo(new Vector2(-bar_end_offset, bar_end_offset), bar_duration, Easing.OutQuint);
barBottomRight.MoveTo(new Vector2(bar_end_offset, bar_end_offset), bar_duration, Easing.OutQuint);
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
using (BeginDelayedSequence(1640, true)) // 2000
{
bigRing.ResizeTo(logo_size * 0.86f, 500, Easing.InOutQuint);
bigRing.Foreground.Delay(250).ResizeTo(1, 450, Easing.OutExpo);
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
using (BeginDelayedSequence(250, true)) // 2250
{
backgroundFill.ResizeHeightTo(1, remainingTime(), Easing.InOutQuart);
backgroundFill.RotateTo(-90, remainingTime(), Easing.InOutQuart);
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
using (BeginDelayedSequence(50, true))
{
foregroundFill.ResizeWidthTo(1, remainingTime(), Easing.InOutQuart);
foregroundFill.RotateTo(-90, remainingTime(), Easing.InOutQuart);
}
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
const float circle_size = logo_size * 0.9f;
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
const int rotation_delay = 110;
const int appear_delay = 80;
2017-10-04 23:50:13 +00:00
2017-11-03 08:54:35 +00:00
purpleCircle.MoveToY(circle_size / 2, remainingTime(), Easing.InOutQuad);
purpleCircle.Delay(rotation_delay).RotateTo(-180, remainingTime() - rotation_delay, Easing.OutQuad);
purpleCircle.ResizeTo(circle_size, remainingTime(), Easing.InOutQuad);
using (BeginDelayedSequence(appear_delay, true))
{
yellowCircle.MoveToY(-circle_size / 2, remainingTime(), Easing.InOutQuad);
yellowCircle.Delay(rotation_delay).RotateTo(-180, remainingTime() - rotation_delay, Easing.OutQuad);
yellowCircle.ResizeTo(circle_size, remainingTime(), Easing.InOutQuad);
using (BeginDelayedSequence(appear_delay, true))
{
blueCircle.MoveToX(-circle_size / 2, remainingTime(), Easing.InOutQuad);
blueCircle.Delay(rotation_delay).RotateTo(-180, remainingTime() - rotation_delay, Easing.OutQuad);
blueCircle.ResizeTo(circle_size, remainingTime(), Easing.InOutQuad);
using (BeginDelayedSequence(appear_delay, true))
{
pinkCircle.MoveToX(circle_size / 2, remainingTime(), Easing.InOutQuad);
pinkCircle.Delay(rotation_delay).RotateTo(-180, remainingTime() - rotation_delay, Easing.OutQuad);
pinkCircle.ResizeTo(circle_size, remainingTime(), Easing.InOutQuad);
}
}
}
}
}
}
}
2017-10-04 20:06:31 +00:00
}
2017-10-04 23:50:13 +00:00
private void setDefaults()
2017-10-04 20:06:31 +00:00
{
2017-10-10 17:06:18 +00:00
welcomeText.Spacing = new Vector2(5);
2017-10-05 18:37:37 +00:00
welcomeText.Alpha = 0;
2017-10-04 20:06:31 +00:00
smallRing.Size = mediumRing.Size = bigRing.Size = Vector2.Zero;
2017-10-04 23:50:13 +00:00
2017-11-01 08:07:03 +00:00
mediumRing.Foreground.Size = Vector2.One - new Vector2(0.7f);
smallRing.Foreground.Size = Vector2.One - new Vector2(0.4f);
bigRing.Foreground.Size = Vector2.One - new Vector2(0.15f);
barTopLeft.Size = barTopRight.Size = barBottomLeft.Size = barBottomRight.Size = new Vector2(105, 1.5f);
2017-10-05 18:37:37 +00:00
barTopLeft.Alpha = barTopRight.Alpha = barBottomLeft.Alpha = barBottomRight.Alpha = 0;
2017-11-01 08:07:03 +00:00
const int bar_offset = 80;
barTopLeft.Position = new Vector2(-bar_offset, -bar_offset);
barTopRight.Position = new Vector2(bar_offset, -bar_offset);
barBottomLeft.Position = new Vector2(-bar_offset, bar_offset);
barBottomRight.Position = new Vector2(bar_offset, bar_offset);
2017-10-04 23:50:13 +00:00
2017-10-05 18:37:37 +00:00
backgroundFill.Rotation = foregroundFill.Rotation = 0;
backgroundFill.Alpha = foregroundFill.Alpha = 1;
backgroundFill.Height = foregroundFill.Width = 0;
2017-10-04 23:50:13 +00:00
2017-10-05 18:37:37 +00:00
yellowCircle.Size = purpleCircle.Size = blueCircle.Size = pinkCircle.Size = Vector2.Zero;
yellowCircle.Rotation = purpleCircle.Rotation = blueCircle.Rotation = pinkCircle.Rotation = 0;
2017-11-01 08:07:03 +00:00
const int circle_offset = 250;
yellowCircle.Position = new Vector2(0, -circle_offset);
purpleCircle.Position = new Vector2(0, circle_offset);
blueCircle.Position = new Vector2(-circle_offset, 0);
pinkCircle.Position = new Vector2(circle_offset, 0);
2017-10-04 23:50:13 +00:00
}
2017-10-10 03:06:09 +00:00
private class Ring : Container<CircularContainer>
2017-10-04 23:50:13 +00:00
{
2017-10-09 22:36:40 +00:00
public readonly CircularContainer Foreground;
2017-10-04 23:50:13 +00:00
public Ring(Color4 ringColour)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
2017-10-10 03:06:09 +00:00
Children = new[]
2017-10-04 23:50:13 +00:00
{
2017-10-10 03:06:09 +00:00
new CircularContainer
2017-10-04 23:50:13 +00:00
{
2017-10-10 03:06:09 +00:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
2017-10-10 03:06:09 +00:00
Masking = true,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ringColour,
}
2017-10-04 23:50:13 +00:00
},
Foreground = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
2017-10-04 23:50:13 +00:00
Masking = true,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
}
}
};
}
}
2017-10-04 20:06:31 +00:00
}
}