mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 04:49:40 +08:00
f06f13215b
The previous version tried to keep both normal multiplayer and team multiplayer results as one screen, but didn't check that team-specific components aren't null in `LoadComplete()`. To decrease number of conditional, split off the team results screen to a separate implementation, and choose one or the other at push time in `MultiplayerPlayer`, depending on team count.
134 lines
4.9 KiB
C#
134 lines
4.9 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 System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Colour;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Effects;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Graphics.Sprites;
|
|
using osu.Game.Localisation;
|
|
using osu.Game.Online.Rooms;
|
|
using osu.Game.Scoring;
|
|
using osu.Game.Screens.Play.HUD;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|
{
|
|
public class MultiplayerTeamResultsScreen : MultiplayerResultsScreen
|
|
{
|
|
private readonly SortedDictionary<int, BindableInt> teamScores;
|
|
|
|
private Container winnerBackground;
|
|
private Drawable winnerText;
|
|
|
|
public MultiplayerTeamResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem, SortedDictionary<int, BindableInt> teamScores)
|
|
: base(score, roomId, playlistItem)
|
|
{
|
|
if (teamScores.Count != 2)
|
|
throw new NotSupportedException(@"This screen currently only supports 2 teams");
|
|
|
|
this.teamScores = teamScores;
|
|
}
|
|
|
|
[Resolved]
|
|
private OsuColour colours { get; set; }
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
const float winner_background_half_height = 250;
|
|
|
|
ScorePanelList.Anchor = ScorePanelList.Origin = Anchor.TopCentre;
|
|
ScorePanelList.Scale = new Vector2(0.9f);
|
|
ScorePanelList.Y = 75;
|
|
|
|
var redScore = teamScores.First().Value;
|
|
var blueScore = teamScores.Last().Value;
|
|
|
|
// eventually this will be replaced by team names coming from the multiplayer match state.
|
|
string winner = redScore.Value > blueScore.Value ? @"Red" : @"Blue";
|
|
|
|
var winnerColour = redScore.Value > blueScore.Value ? colours.TeamColourRed : colours.TeamColourBlue;
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
{
|
|
new MatchScoreDisplay
|
|
{
|
|
Anchor = Anchor.TopCentre,
|
|
Origin = Anchor.TopCentre,
|
|
Team1Score = { BindTarget = redScore },
|
|
Team2Score = { BindTarget = blueScore },
|
|
},
|
|
winnerBackground = new Container
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Alpha = 0,
|
|
Children = new[]
|
|
{
|
|
new Box
|
|
{
|
|
RelativeSizeAxes = Axes.X,
|
|
Height = winner_background_half_height,
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.BottomCentre,
|
|
Colour = ColourInfo.GradientVertical(Colour4.Black.Opacity(0), Colour4.Black.Opacity(0.4f))
|
|
},
|
|
new Box
|
|
{
|
|
RelativeSizeAxes = Axes.X,
|
|
Height = winner_background_half_height,
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.TopCentre,
|
|
Colour = ColourInfo.GradientVertical(Colour4.Black.Opacity(0.4f), Colour4.Black.Opacity(0))
|
|
}
|
|
}
|
|
},
|
|
(winnerText = new OsuSpriteText
|
|
{
|
|
Alpha = 0,
|
|
Font = OsuFont.Torus.With(size: 80, weight: FontWeight.Bold),
|
|
Text = MultiplayerResultsScreenStrings.TeamWins(winner),
|
|
Blending = BlendingParameters.Additive
|
|
}).WithEffect(new GlowEffect
|
|
{
|
|
Colour = winnerColour,
|
|
}).With(e =>
|
|
{
|
|
e.Anchor = Anchor.Centre;
|
|
e.Origin = Anchor.Centre;
|
|
})
|
|
});
|
|
}
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
using (BeginDelayedSequence(300))
|
|
{
|
|
const double fade_in_duration = 600;
|
|
|
|
winnerText.FadeInFromZero(fade_in_duration, Easing.InQuint);
|
|
winnerBackground.FadeInFromZero(fade_in_duration, Easing.InQuint);
|
|
|
|
winnerText
|
|
.ScaleTo(10)
|
|
.ScaleTo(1, 600, Easing.InQuad)
|
|
.Then()
|
|
.ScaleTo(1.02f, 1600, Easing.OutQuint)
|
|
.FadeOut(5000, Easing.InQuad);
|
|
winnerBackground.Delay(2200).FadeOut(2000);
|
|
}
|
|
}
|
|
}
|
|
}
|