Beispiel #1
0
    // OnGUI
    void OnGUI()
    {
        if (disconnected)
        {
            GUIHelper.BeginBox(400, 72);
            GUILayout.Label("Disconnected from the game server.");
            if (server != null)
            {
                using (new GUIHorizontalCenter()) {
                    if (GUIHelper.Button("Reconnect"))
                    {
                        LogManager.General.Log("Reconnecting to " + server.ToString());

                        if (InGameLobby.instance != null)
                        {
                            // Real server
                            InGameLobby.instance.ConnectToGameServerByIPEndPoint(server);
                        }
                        else
                        {
                            // Test server
                            Application.LoadLevel("Client");
                            uLink.Network.Connect(server);
                        }
                    }
                }
            }

            GUIHelper.EndBox();
        }
    }
Beispiel #2
0
 // Footer
 void DrawFooter(int x, int y, int width, int height)
 {
     GUIHelper.BeginBox(x, y, width, height);
     using (new GUIHorizontal(GUILayout.MaxWidth(GUIArea.width))) {
         ArenaGUI.instance.DrawMatchmakingQueues();
         lobbyChat.Draw();
     }
     GUIHelper.EndBox();
 }
Beispiel #3
0
    void PleaseUpdateGUI()
    {
        GUIHelper.BeginBox(600, 140);
        GUILayout.Label("Your client version is out of date, you need to update your client.\n\nClient version: " + clientVersionNumber + "\nServer version: " + serverVersionNumber);
#if UNITY_WEBPLAYER
        GUILayout.Label("\nPlease refresh the website.");
#else
        GUILayout.Label("Alternatively you can go to http://battle-of-mages.com and play with the latest client.");
#endif
        GUIHelper.EndBox();
    }
Beispiel #4
0
    public void DisconnectedGUI()
    {
        GUIHelper.BeginBox(400, 80);

        GUILayout.Label("Disconnected from lobby.");

        GUILayout.FlexibleSpace();

        if (GUIHelper.Button("Reconnect", GUILayout.Width(100)))
        {
            Sounds.instance.buttonClick.Play();
            ConnectToLobby();
        }

        GUIHelper.EndBox();
    }
Beispiel #5
0
    void LicenseGUI()
    {
        GUIHelper.BeginBox(460, 300);
        GUILayout.Label(@"You hereby agree to the following conditions:

1. Understand that most graphics are simply dummy graphics used in the development process and do not represent the quality of the final product.

2. Your character will be reset at the start of the Closed Beta.

3. You will receive an Alpha Tester title in the future.
");
        GUILayout.FlexibleSpace();
        using (new GUIHorizontalCenter()) {
            if (GUIHelper.Button("I agree.") || (Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.Return))
            {
                Sounds.instance.buttonClick.Play();
                ChangeState(State.Lobby);
                gameLobby.UpdateAccountInfo();
            }
        }
        GUIHelper.EndBox();
    }
Beispiel #6
0
    // Main menu
    void DrawMainMenu()
    {
        /*int chatHeight = (int)(GUIArea.height * 0.3f);
         * if(chatHeight < 250)
         *      chatHeight = 250;*/

        int chatYPos;

        if (_currentState == GameLobbyState.Game || !chatEnabled)
        {
            chatYPos = (int)GUIArea.height;
        }
        else
        {
            chatYPos = (int)GUIArea.height - chatHeight - 4;
        }

        GUIHelper.BeginBox(4, 4, (int)GUIArea.width - 8, chatYPos - 8);

        // Header
        DrawHeader();

        GUILayout.Space(4);

        // Body
        DrawBody();

        GUIHelper.EndBox();

        // Footer with chat and matchmaking buttons
        if (_currentState != GameLobbyState.Game && chatEnabled)
        {
            DrawFooter(4, chatYPos, (int)GUIArea.width - 8, chatHeight);
        }

        // Navigation for game pads
        GamePadNavigation();
    }
Beispiel #7
0
 public void ConnectingToLobbyGUI()
 {
     GUIHelper.BeginBox(400, 50);
     GUILayout.Label("Connecting to lobby...");
     GUIHelper.EndBox();
 }
Beispiel #8
0
    // Registration
    public void RegisterGUI()
    {
        GUIHelper.BeginBox(registerGUIDimensions.x, registerGUIDimensions.y);

        GUILayout.Label("Register a new account.");
        GUILayout.Space(10);

        int validationErrors = 0;

        // E-Mail
        GUILayout.Label("<b>E-Mail</b>");
        accountEmail = GUILayout.TextField(accountEmail, textFieldHeight);

        // Validate
        if (Validator.email.IsMatch(accountEmail))
        {
            GUI.contentColor = GUIColor.Validated;
        }
        else
        {
            GUI.contentColor  = GUIColor.NotValidated;
            validationErrors += 1;
        }
        GUILayout.Label("Please enter your email address, we will send you an account activation link and notify you when the Open Beta starts.");
        GUI.contentColor = Color.white;
        GUILayout.Space(5);

        // Password
        GUILayout.Label("<b>Password</b>");
        var newAccountPassword = GUILayout.PasswordField(accountPassword, '*', textFieldHeight);

        // User modified password
        if (accountPassword != newAccountPassword)
        {
            accountPasswordEncrypted = null;
            accountPassword          = newAccountPassword;
        }

        // Validate
        if (Validator.password.IsMatch(accountPassword))
        {
            GUI.contentColor = GUIColor.Validated;
        }
        else
        {
            GUI.contentColor  = GUIColor.NotValidated;
            validationErrors += 1;
        }
        GUILayout.Label("Your password should contain a minimum of 6 characters.");
        GUI.contentColor = Color.white;
        GUILayout.Space(5);

        // Register + status message
        using (new GUIHorizontal()) {
            GUI.enabled = (validationErrors == 0 || GameDB.IsTestAccount(accountEmail));
            if (GUIHelper.Button("Register", GUILayout.Width(80)))
            {
                Sounds.instance.buttonClick.Play();

                // Registers a new account. The OnAccountRegistered callback will be called if the account was registered -
                // otherwise, the OnRegisterFailed callback is called.
                //AccountManager.RegisterAccount(accountName, accountPassword, accountEmail);
                SendRegisterRequest(accountEmail, accountPassword);
            }
            GUI.enabled = true;

            GUI.contentColor = GUIColor.StatusMessage;

            GUILayout.Space(5);
            GUILayout.FlexibleSpace();

            // Status message
            GUILayout.Label(statusMessage);
            GUI.contentColor = Color.white;
        }

        GUILayout.FlexibleSpace();

        if (GUIHelper.Button("Back", GUILayout.Width(50)))
        {
            Sounds.instance.buttonClick.Play();
            ChangeState(State.LogIn);
        }

        GUIHelper.EndBox();
    }
Beispiel #9
0
    public void LoginGUI()
    {
        GUIHelper.BeginBox(loginGUIDimensions.x, loginGUIDimensions.y);

        GUILayout.Label("Enter your account name and password to log in.");
        GUILayout.Space(10);
        GUILayout.FlexibleSpace();

        // Disable GUI while trying to log in
        GUI.enabled = (loginRequests == loginRequestResponses);

        GUILayout.Label("<b>E-Mail</b>");
        GUI.SetNextControlName("AccountEmail");
        accountEmail = GUILayout.TextField(accountEmail, GameDB.maxEmailLength, textFieldHeight).Trim();

        // Focus
        if (!accountNameFocused && !accountNameLoaded)
        {
            GUIHelper.Focus("AccountEmail");
            accountNameFocused = true;
        }

        GUILayout.Label("<b>Password</b>");
        GUI.SetNextControlName("AccountPassword");
        var newAccountPassword = GUILayout.PasswordField(accountPassword, '*', textFieldHeight);

        // User modified password
        if (accountPassword != newAccountPassword)
        {
            accountPasswordEncrypted = null;
            accountPassword          = newAccountPassword;
        }

        // Focus
        if (!accountPasswordFocused && accountNameLoaded)
        {
            if (string.IsNullOrEmpty(accountPasswordEncrypted))
            {
                GUIHelper.Focus("AccountPassword");
            }
            accountPasswordFocused = true;
        }

        GUILayout.Space(5);
        GUILayout.FlexibleSpace();

        // Login button
        using (new GUIHorizontal()) {
            GUI.enabled = (
                GameDB.IsTestAccount(accountEmail) ||
                (
                    loginRequests == loginRequestResponses &&
                    Validator.email.IsMatch(accountEmail)                     //&&
                    //Validator.password.IsMatch(accountPassword)
                )
                );

            if (GUIHelper.Button("Log in", GUILayout.Width(80)) || (Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.Return))
            {
                Sounds.instance.buttonClick.Play();

                // Log in to an account. We will get a response in the form of either the OnAccountRegistered callback, or
                // OnLogInFailed if something went wrong.
                if (string.IsNullOrEmpty(accountPasswordEncrypted))
                {
                    SendLoginRequest(accountEmail, accountPassword);
                }
                else
                {
                    SendEncryptedLoginRequest(accountEmail, accountPasswordEncrypted);
                }
            }
            GUI.enabled = true;

            GUI.contentColor = GUIColor.StatusMessage;

            GUILayout.Space(5);
            GUILayout.FlexibleSpace();

            // Status message
            GUILayout.Label(statusMessage);
            GUI.contentColor = Color.white;
        }

        GUILayout.Space(10);
        GUILayout.FlexibleSpace();

        // Footer
        GUILayout.Label("Not registered?");

        using (new GUIHorizontal()) {
            // Register
            if (GUIHelper.Button("Register account", GUILayout.Width(140)))
            {
                Sounds.instance.buttonClick.Play();
                ChangeState(State.Register);
            }

            // Account activation mail
            if (accountNotActivated && accountEmail == inactiveEmail)
            {
                GUILayout.FlexibleSpace();
                if (GUIHelper.Button("Resend activation mail", GUILayout.Width(180)))
                {
                    Sounds.instance.buttonClick.Play();
                    Lobby.RPC("ResendActivationMail", Lobby.lobby, inactiveEmail);
                }
            }
        }

        GUIHelper.EndBox();
    }
Beispiel #10
0
    // Ask for player name
    void AskingPlayerName()
    {
        GUIHelper.BeginBox(400, 250);
        GUILayout.Label("Please enter your player name.");

        GUI.SetNextControlName("PlayerNameInput");
        playerNameRequest = GUIHelper.PlayerNameField(playerNameRequest);

        if (!playerNameFocused)
        {
            GUIHelper.Focus("PlayerNameInput");
            playerNameFocused = true;
        }

        // Validator
        bool validName = Validator.playerName.IsMatch(playerNameRequest);

        // We will not allow use of Return key when unicode characters are used
        // because Return is used in the IME input of eastern languages.
        bool imeInputUsed = playerNameRequest.ContainsUnicodeCharacter();

        if (currentKeyCode == KeyCode.Return && !imeInputUsed)
        {
            // We use keyboardControl because GetNameOfFocusedControl() is bugged in Unity
            if (GUIUtility.keyboardControl != 0)
            {
                if (validName)
                {
                    new Confirm(
                        _("Are you sure you want to change your name to <b>{0}</b>?", playerNameRequest),
                        SendPlayerNameChangeRequest
                        );
                }
            }
            else
            {
                GUIHelper.Focus("PlayerNameInput");
            }
        }

        // Check availability
        if (validName && playerNameRequest != lastPlayerNameChecked && Time.time - lastPlayerNameCheckedTime >= 0.5f)
        {
            Lobby.RPC("PlayerNameExists", Lobby.lobby, playerNameRequest);
            lastPlayerNameCheckedTime = Time.time;
            lastPlayerNameChecked     = playerNameRequest;
            nameAvailable             = false;
        }

        GUILayout.Label("You can only set it once and it will be visible for everyone, so think carefully about the name you choose.");
        GUILayout.FlexibleSpace();

        if (validName)
        {
            GUI.contentColor = GUIColor.Validated;
        }
        else
        {
            GUI.contentColor = GUIColor.NotValidated;
        }

        GUILayout.Label("Player name must contain letters and spaces only and each word needs to start with an uppercase letter.");
        GUILayout.FlexibleSpace();

        using (new GUIHorizontal()) {
            GUI.contentColor = GUIColor.StatusMessage;
            GUILayout.Label(statusMessage);

            GUILayout.FlexibleSpace();

            GUI.contentColor = Color.white;
            GUI.enabled      = validName && nameAvailable;
            if (GUIHelper.Button("Accept"))
            {
                SendPlayerNameChangeRequest();
            }
            GUI.enabled = true;
        }

        GUIHelper.EndBox();
    }
Beispiel #11
0
 // While waiting for account information
 void WaitingForAccountInfo()
 {
     GUIHelper.BeginBox(400, 50);
     GUILayout.Label("Loading account information...");
     GUIHelper.EndBox();
 }
Beispiel #12
0
 void DrawReady()
 {
     GUIHelper.BeginBox(300, 50);
     GUILayout.Label("Waiting for game server...");
     GUIHelper.EndBox();
 }