public HUDMultiplayerScorePanel(LevelBlueprint lvl, PlayerProfile playerprofile, bool playerHasWon, int addPoints, GDMultiplayerCommon srv, Action preventStopOnRem) { successScreen = playerHasWon; profile = playerprofile; Level = lvl; _server = srv; _serverHost = srv as GDMultiplayerServer; _preventStopOnRem = preventStopOnRem; _deltaPoints = addPoints; RelativePosition = FPoint.Zero; Size = new FSize(WIDTH, HEIGHT); Alignment = HUDAlignment.CENTER; Background = FlatColors.BackgroundHUD; }
public GDMultiplayerGameHUD(GDGameScreen scrn, GDMultiplayerCommon mp) : base(scrn, Textures.HUDFontRegular) { AddElement(new HUDPauseButton(false, false, true)); _backgroundRect = new HUDRectangle(-10) { Alignment = HUDAlignment.TOPLEFT, RelativePosition = FPoint.Zero, Definition = HUDBackgroundDefinition.CreateSimple(Color.Black * 0.3f), Size = new FSize(100, 100), }; AddElement(_backgroundRect); var mpcsc = new MultiplayerConnectionStateControl(mp) { Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(4, 4), TextColor = FlatColors.Clouds, }; AddElement(mpcsc); _cornerElements.Add(mpcsc); if (mp.SessionUserID == 0) { if (mp.SessionCapacity == 2) { var lbl = new HUDLambdaLabel { Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(4, 44), Font = Textures.HUDFontBold, FontSize = 32, Size = new FSize(200, 32), TextColor = FlatColors.Clouds, AutoSize = true, Lambda = () => (mp.ConnState == SAMNetworkConnection.ConnectionState.Offline) ? "Ping: -" : $"Ping: {(int) (mp.UserConn[1].InGamePing.Value * 1000)}ms", }; AddElement(lbl); _cornerElements.Add(lbl); } else { int idx = 0; for (int i = 1; i < mp.SessionCapacity; i++) { int uid = i; var lbl = new HUDLambdaLabel { Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(4, 44 + 40 * idx), Font = Textures.HUDFontBold, FontSize = 32, Size = new FSize(200, 32), TextColor = Color.White, AutoSize = true, Lambda = () => $"Ping[{uid}]: {(int) (mp.UserConn[uid].InGamePing.Value * 1000)}ms", }; AddElement(lbl); _cornerElements.Add(lbl); idx++; } } } else { var lbl = new HUDLambdaLabel { Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(4, 44), Font = Textures.HUDFontBold, FontSize = 32, Size = new FSize(200, 32), TextColor = Color.White, AutoSize = true, Lambda = () => $"Ping: {(int) (mp.UserConn[0].InGamePing.Value * 1000)}ms", }; AddElement(lbl); _cornerElements.Add(lbl); } _countdown = new HUDImage(100) { Alignment = HUDAlignment.CENTER, Image = Textures.TexTitleNumber[3], ImageAlignment = HUDImageAlignmentAlgorithm.CENTER, ImageScale = HUDImageScaleAlgorithm.UNDERSCALE, Size = new FSize(320, 320), }; AddElement(_countdown); var x = _cornerElements.Max(e => e.Right); var y = _cornerElements.Max(e => e.Bottom); _backgroundRect.Size = new FSize(x + 4f, y + 4f); }