1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-30 15:02:56 +08:00
osu-lazer/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs

126 lines
4.1 KiB
C#
Raw Normal View History

2019-03-04 12:24:19 +08:00
// 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-11-11 09:39:04 +08:00
using osu.Framework.Allocation;
2019-03-02 12:40:43 +08:00
using osu.Framework.Bindables;
2018-11-11 09:39:04 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Tournament.Components;
2019-06-18 13:51:48 +08:00
using osu.Game.Tournament.Models;
using osuTK;
2018-11-11 09:39:04 +08:00
namespace osu.Game.Tournament.Screens.TeamWin
{
public class TeamWinScreen : TournamentScreen, IProvideVideo
{
private Container mainContainer;
2019-06-18 13:57:05 +08:00
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
2018-11-11 09:39:04 +08:00
private readonly Bindable<bool> currentCompleted = new Bindable<bool>();
private TourneyVideo blueWinVideo;
private TourneyVideo redWinVideo;
2018-11-11 09:39:04 +08:00
[BackgroundDependencyLoader]
private void load(LadderInfo ladder, Storage storage)
2018-11-11 09:39:04 +08:00
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
blueWinVideo = new TourneyVideo("teamwin-blue")
2018-11-11 09:39:04 +08:00
{
Alpha = 1,
RelativeSizeAxes = Axes.Both,
Loop = true,
},
redWinVideo = new TourneyVideo("teamwin-red")
2018-11-11 09:39:04 +08:00
{
Alpha = 0,
RelativeSizeAxes = Axes.Both,
Loop = true,
},
mainContainer = new Container
{
RelativeSizeAxes = Axes.Both,
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(ladder.CurrentMatch);
currentCompleted.BindValueChanged(_ => update());
}
2019-06-18 13:57:05 +08:00
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
2018-11-11 09:39:04 +08:00
{
currentCompleted.UnbindBindings();
2019-06-18 13:57:05 +08:00
currentCompleted.BindTo(match.NewValue.Completed);
2018-11-11 09:39:04 +08:00
update();
}
private bool firstDisplay = true;
private void update() => Schedule(() =>
2018-11-11 09:39:04 +08:00
{
2019-06-18 13:57:05 +08:00
var match = currentMatch.Value;
2018-11-11 09:39:04 +08:00
2019-06-18 13:57:05 +08:00
if (match.Winner == null)
2018-11-11 09:39:04 +08:00
{
mainContainer.Clear();
return;
}
redWinVideo.Alpha = match.WinnerColour == TeamColour.Red ? 1 : 0;
blueWinVideo.Alpha = match.WinnerColour == TeamColour.Blue ? 1 : 0;
2018-11-11 09:39:04 +08:00
if (firstDisplay)
{
if (match.WinnerColour == TeamColour.Red)
redWinVideo.Reset();
else
blueWinVideo.Reset();
firstDisplay = false;
}
2018-11-11 09:39:04 +08:00
mainContainer.Children = new Drawable[]
{
new DrawableTeamFlag(match.Winner)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Position = new Vector2(-300, 10),
Scale = new Vector2(2f)
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
X = 260,
Children = new Drawable[]
2018-11-11 09:39:04 +08:00
{
new RoundDisplay(match)
2018-11-11 09:39:04 +08:00
{
Margin = new MarginPadding { Bottom = 30 },
},
new TournamentSpriteText
{
Text = "WINNER",
Font = OsuFont.Torus.With(size: 100, weight: FontWeight.Bold),
Margin = new MarginPadding { Bottom = 50 },
},
new DrawableTeamWithPlayers(match.Winner, match.WinnerColour)
}
},
};
mainContainer.FadeOut();
mainContainer.Delay(2000).FadeIn(1600, Easing.OutQuint);
});
2018-11-11 09:39:04 +08:00
}
}