Пример #1
0
        private void UpdateLabels()
        {
            _lblLevelID1.Text = _currentLevel.Name.Split('-').First();
            _lblLevelID2.Text = _currentLevel.Name.Split('-').Last();
            _levelUserCount   = BlueprintAnalyzer.PlayerCount(_currentLevel);

            var screen = new GDGameScreen_Display(MainGame.Inst, MainGame.Inst.Graphics, _currentLevel);

            _displayScreen.ChangeScreen(screen);
        }
Пример #2
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            AddElement(new HUDLabel(1)
            {
                TextAlignment    = HUDAlignment.CENTER,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(0, 0),
                Size             = new FSize(WIDTH, 96),

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                L10NText  = _server.ConnType == MultiplayerConnectionType.PROXY ? L10NImpl.STR_MENU_CAP_CGAME_PROX : L10NImpl.STR_MENU_CAP_CGAME_P2P,
                TextColor = FlatColors.Clouds,
            });

            AddElement(new MultiplayerConnectionStateControl(_server)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(16, 16)
            });

            var screen = new GDGameScreen_Display(MainGame.Inst, MainGame.Inst.Graphics, _currentLevel);

            AddElement(_displayScreen = new HUDSubScreenProxyRenderer(screen)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((2 / 3f) * GDConstants.TILE_WIDTH, 3.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(6 * GDConstants.TILE_WIDTH, 3.75f * GDConstants.TILE_WIDTH),
            });


            AddElement(new HUDImageButton
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((5 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(32, 48),

                Image        = Textures.TexHUDIconChevronLeft,
                ImagePadding = 4,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 8f, true, false, true, false),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 8f, true, false, true, false),

                Click = (s, a) => ChangeID1(-1),
            });

            AddElement(_lblLevelID1 = new HUDClickableLabel
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((8 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),

                Size     = new FSize(96, 48),
                FontSize = 48,
                Font     = Textures.HUDFontRegular,

                Text          = "?",
                TextAlignment = HUDAlignment.CENTER,
                TextColor     = FlatColors.Clouds,

                Background = HUDBackgroundDefinition.CreateSimple(FlatColors.BackgroundHUD2),

                Click      = (s, a) => ChangeID1(+1),
                ClickSound = true,
            });

            AddElement(new HUDImageButton
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((17 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(32, 48),

                Image        = Textures.TexHUDIconChevronRight,
                ImagePadding = 4,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 8f, false, true, false, true),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 8f, false, true, false, true),

                Click = (s, a) => ChangeID1(+1),
            });


            AddElement(new HUDImageButton
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((24 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(32, 48),

                Image        = Textures.TexHUDIconChevronLeft,
                ImagePadding = 4,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 8f, true, false, true, false),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 8f, true, false, true, false),

                Click = (s, a) => ChangeID2(-1),
            });

            AddElement(_lblLevelID2 = new HUDClickableLabel
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((27 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),

                Size     = new FSize(96, 48),
                FontSize = 48,
                Font     = Textures.HUDFontRegular,

                Text          = "?",
                TextAlignment = HUDAlignment.CENTER,
                TextColor     = FlatColors.Clouds,

                Background = HUDBackgroundDefinition.CreateSimple(FlatColors.BackgroundHUD2),

                Click      = (s, a) => ChangeID2(+1),
                ClickSound = true,
            });

            AddElement(new HUDImageButton
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((36 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(32, 48),

                Image        = Textures.TexHUDIconChevronRight,
                ImagePadding = 4,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 8f, false, true, false, true),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 8f, false, true, false, true),

                Click = (s, a) => ChangeID2(+1),
            });


            AddElement(new HUDLambdaLabel
            {
                TextAlignment    = HUDAlignment.BOTTOMLEFT,
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(100 + 8, 375),
                Size             = new FSize(200, 32),

                Font     = Textures.HUDFontRegular,
                FontSize = 32,

                Lambda    = () => L10N.TF(L10NImpl.STR_MENU_MP_LOBBY_USER_FMT, _levelUserCount),
                TextColor = Color.White,
            });

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.BOTTOMLEFT,
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(100 + 8, 331),
                Size             = new FSize(200, 32),

                Font     = Textures.HUDFontRegular,
                FontSize = 32,

                L10NText  = L10NImpl.STR_MENU_MP_MUSIC,
                TextColor = Color.White,
            });

            int initialMusic = FloatMath.GetRangedIntRandom(5);

            AddElement(_music1 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(37, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 0,
                Selected         = initialMusic == 0,
            });

            AddElement(_music2 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(109, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 1,
                Selected         = initialMusic == 1,
            });

            AddElement(_music3 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(179, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 2,
                Selected         = initialMusic == 2,
            });

            AddElement(_music4 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(249, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 3,
                Selected         = initialMusic == 3,
            });

            AddElement(_music5 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(319, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 4,
                Selected         = initialMusic == 4,
            });

            AddElement(_music6 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(389, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 5,
                Selected         = initialMusic == 5,
            });

            _music1.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music2.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music3.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music4.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music5.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music6.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };

            var initialSpeed = MainGame.Inst.Profile.LastMultiplayerHostedSpeed;

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.BOTTOMLEFT,
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(100 + 8, 221),
                Size             = new FSize(200, 32),

                Font     = Textures.HUDFontRegular,
                FontSize = 32,

                L10NText  = L10NImpl.STR_MENU_MP_GAMESPEED,
                TextColor = Color.White,
            });

            AddElement(_speed1 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(37, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.SUPERSLOW,
                Selected         = initialSpeed == GameSpeedModes.SUPERSLOW,
            });

            AddElement(_speed2 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(109, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.SLOW,
                Selected         = initialSpeed == GameSpeedModes.SLOW,
            });

            AddElement(_speed3 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(179, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.NORMAL,
                Selected         = initialSpeed == GameSpeedModes.NORMAL,
            });

            AddElement(_speed4 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(249, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.FAST,
                Selected         = initialSpeed == GameSpeedModes.FAST,
            });

            AddElement(_speed5 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(319, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.SUPERFAST,
                Selected         = initialSpeed == GameSpeedModes.SUPERFAST,
            });

            _speed1.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };
            _speed2.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };
            _speed3.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };
            _speed4.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };
            _speed5.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };

            AddElement(new HUDRectangle(0)
            {
                Alignment = HUDAlignment.BOTTOMRIGHT,
                Size      = new FSize(WIDTH, FOOTER_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateRounded(FlatColors.BackgroundHUD2, 16, false, false, true, true),
            });

            AddElement(_btnCreate = new HUDIconTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 0.5f * GDConstants.TILE_WIDTH),
                Size             = new FSize(5.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH),

                Icon = null,
                IconRotationSpeed = 0.25f,

                L10NText      = L10NImpl.STR_MENU_MP_CREATE,
                TextColor     = Color.White,
                Font          = Textures.HUDFontBold,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.PeterRiver, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.BelizeHole, 16),

                Click = OnClickCreateLobby,
            });

            AddElement(new HUDTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 0.5f * GDConstants.TILE_WIDTH),
                Size             = new FSize(5.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH),

                L10NText      = L10NImpl.STR_MENU_CANCEL,
                TextColor     = Color.White,
                Font          = Textures.HUDFontBold,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Asbestos, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.MidnightBlue, 16),

                Click = OnClickCancel,
            });

            //---------------------

            if (!Levels.LEVELS.TryGetValue(MainGame.Inst.Profile.LastMultiplayerHostedLevel, out _currentLevel))
            {
                _currentLevel = Levels.LEVELS[Levels.LEVELID_1_3];
            }

            _currentWorld = Levels.WORLDS_MULTIPLAYER.FirstOrDefault(w => w.AllNodes.Any(n => n.ConnectionID == _currentLevel.UniqueID));
            if (_currentWorld == null)
            {
                _currentWorld = Levels.WORLD_001;
                _currentLevel = Levels.LEVELS[Levels.LEVELID_1_3];
            }

            UpdateLabels();
        }