示例#1
0
        /// <summary>
        /// @Author Steven
        /// </summary>
        /// <param name="game"></param>
        /// <param name="title"></param>
        public LobbyMenu(Game1 game, String title)
        {
            this.game = game;
            game.mainScreen.Desktop.Children.Clear(); //Clear the gui
            lobbyTitle = title;

            /* White background for UI */
            WhiteBackground = new Rectangle((int)game.mainScreen.Width / 2 - UIConstants.LOBBY_WHITE_BG.X, (int)game.mainScreen.Height / 2 - UIConstants.LOBBY_WHITE_BG.Y,
                                            UIConstants.LOBBY_WHITE_BG.Width, UIConstants.LOBBY_WHITE_BG.Height);

            /* Scrolling background */

            /* Menu's Banner */
            TexBanner = Game1.Assets.suMultiLobby;
            Banner    = new Rectangle((int)game.mainScreen.Width / 2 - UIConstants.SU_BANNER.X, (int)game.mainScreen.Height / 2 - UIConstants.SU_BANNER.Y,
                                      UIConstants.SU_BANNER.Width, UIConstants.SU_BANNER.Height);

            /* For constructing the list of players with LabelControls */
            playerLabelList = new List <LabelControl>();
            playerLabelList.Add(player1Label = GuiHelper.CreateLabel("Empty", 0, 0, UIConstants.LOBBY_PLAYER_LABEL.Width, UIConstants.LOBBY_PLAYER_LABEL.Height));
            playerLabelList.Add(player2Label = GuiHelper.CreateLabel("Empty", 0, 0, UIConstants.LOBBY_PLAYER_LABEL.Width, UIConstants.LOBBY_PLAYER_LABEL.Height));
            playerLabelList.Add(player3Label = GuiHelper.CreateLabel("Empty", 0, 0, UIConstants.LOBBY_PLAYER_LABEL.Width, UIConstants.LOBBY_PLAYER_LABEL.Height));
            playerLabelList.Add(player4Label = GuiHelper.CreateLabel("Empty", 0, 0, UIConstants.LOBBY_PLAYER_LABEL.Width, UIConstants.LOBBY_PLAYER_LABEL.Height));
            playerLabelList.Add(player5Label = GuiHelper.CreateLabel("Empty", 0, 0, UIConstants.LOBBY_PLAYER_LABEL.Width, UIConstants.LOBBY_PLAYER_LABEL.Height));
            playerLabelList.Add(player6Label = GuiHelper.CreateLabel("Empty", 0, 0, UIConstants.LOBBY_PLAYER_LABEL.Width, UIConstants.LOBBY_PLAYER_LABEL.Height));

            /* List of names used to correlate to the labels */
            playerNameList = new List <string>();
            playerNameList.Add("Player 1");
            playerNameList.Add("Player 2");
            playerNameList.Add("Player 3");
            playerNameList.Add("Player 4");
            playerNameList.Add("Player 5");
            playerNameList.Add("Player 6");

            /* List of Ships */
            shipSelectionList = new List <ShipButton>();
            shipSelectionList.Add(new ShipButton(new UFO(game)));
            shipSelectionList.Add(new ShipButton(new Scout(game)));
            shipSelectionList.Add(new ShipButton(new Zoid(game)));

            /* List of choices for ships */
            shipChoiceList = new List <ChoiceControl>();
            shipChoiceList.Add(shipChoice_1 = GuiHelper.CreateChoice("", 0, 0, UIConstants.LOBBY_CHOICE_RADIO.Width, UIConstants.LOBBY_CHOICE_RADIO.Height));
            shipChoiceList.Add(shipChoice_2 = GuiHelper.CreateChoice("", 0, 0, UIConstants.LOBBY_CHOICE_RADIO.Width, UIConstants.LOBBY_CHOICE_RADIO.Height));
            shipChoiceList.Add(shipChoice_3 = GuiHelper.CreateChoice("", 0, 0, UIConstants.LOBBY_CHOICE_RADIO.Width, UIConstants.LOBBY_CHOICE_RADIO.Height));

            /* Sets the default selected ship */
            lastButton = shipSelectionList[0];
            shipSelectionList[0].selected = true;
            shipChoiceList[0].Selected    = true;

            setGridDisplay(game.getScreenWidth() - UIConstants.LOBBY_SHIP_GRID.X, game.getScreenHeight() - UIConstants.LOBBY_SHIP_GRID.Y);

            CreateMenuControls(game.mainScreen);
            Background = Game1.Assets.guiRectangle;
            new Thread(updatePlayerList).Start();
        }