Ejemplo n.º 1
0
        public GameState Update(MouseState mouseState, KeyboardState keyboardState, GameState currentGS)
        {
            _play.SetPosition(new Vector2(Config.Width / 16 * 11 - _play.GetWidth / 2, (float)(Config.Height - _btnTexMid.Height * 1.5)));
            _play.Update(mouseState);

            _exit.SetPosition(new Vector2(Config.Width / 16 * 5 - _exit.GetWidth / 2, (float)(Config.Height - _btnTexMid.Height * 1.5)));
            _exit.Update(mouseState);

            _userName.SetPosition(new Vector2(Config.Width / 16 * 5 - _userName.GetWidth / 2, (float)(Config.Height - _btnTexMid.Height * 4.5)));
            _userName.Update(mouseState, keyboardState);

            _password.SetPosition(new Vector2(Config.Width / 16 * 11 - _password.GetWidth / 2, (float)(Config.Height - _btnTexMid.Height * 4.5)));
            _password.Update(mouseState, keyboardState);

            _server.SetBtnWidth((Config.Width - (Config.Width / 8 * 5 - _exit.GetWidth)) / 8 - 2);
            _server.SetPosition(new Vector2(Config.Width / 16 * 5 - _exit.GetWidth / 2, Config.Height - _btnTexMid.Height * 3));
            _server.Update(mouseState, keyboardState);

            _logo.SetPosition(new Vector2(Config.Width / 2 - _logo.GetWidth / 2, Config.Height / 16 * 4 - _logo.GetHeight / 2));

            _password.Update(mouseState, keyboardState);
            _server.Update(mouseState, keyboardState);

            if (_exit.IsClicked)
            {
                return(GameState.Exit);
            }

            if (_play.IsClicked)
            {
                string serverText = _server.GetText();
                if (serverText.Contains(':'))
                {
                    Storage.Network.Server = serverText.Split(':').First();
                    Storage.Network.Port   = Convert.ToUInt16(serverText.Split(':').Last());
                }
                else
                {
                    Storage.Network.Server = serverText;
                    Storage.Network.Port   = 25565;
                }
                Storage.Network.UserName = _userName.GetText();
                Storage.Network.Password = _password.GetText();
                return(GameState.InGame);
            }
            return(currentGS);
        }