1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 07:32:54 +08:00
osu-lazer/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
2020-03-08 15:38:10 +09:00

114 lines
3.7 KiB
C#

// 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.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osuTK;
namespace osu.Game.Tournament.Screens.TeamWin
{
public class TeamWinScreen : TournamentScreen, IProvideVideo
{
private Container mainContainer;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private readonly Bindable<bool> currentCompleted = new Bindable<bool>();
private TourneyVideo blueWinVideo;
private TourneyVideo redWinVideo;
[BackgroundDependencyLoader]
private void load(LadderInfo ladder, Storage storage)
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
blueWinVideo = new TourneyVideo("teamwin-blue")
{
Alpha = 1,
RelativeSizeAxes = Axes.Both,
Loop = true,
},
redWinVideo = new TourneyVideo("teamwin-red")
{
Alpha = 0,
RelativeSizeAxes = Axes.Both,
Loop = true,
},
mainContainer = new Container
{
RelativeSizeAxes = Axes.Both,
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(ladder.CurrentMatch);
currentCompleted.BindValueChanged(_ => update());
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
{
currentCompleted.UnbindBindings();
currentCompleted.BindTo(match.NewValue.Completed);
update();
}
private void update()
{
var match = currentMatch.Value;
if (match.Winner == null)
{
mainContainer.Clear();
return;
}
redWinVideo.Alpha = match.WinnerColour == TeamColour.Red ? 1 : 0;
blueWinVideo.Alpha = match.WinnerColour == TeamColour.Blue ? 1 : 0;
mainContainer.Children = new Drawable[]
{
new DrawableTeamFlag(match.Winner)
{
Size = new Vector2(300, 200),
Scale = new Vector2(0.5f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Position = new Vector2(-300, 10),
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
X = 260,
Children = new Drawable[]
{
new RoundDisplay(match)
{
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)
}
},
};
}
}
}