Esempio n. 1
0
        private void SendCredentials(bool register)
        {
            string username;
            string password;

            if (!TextFieldInput.TryGetText(UsernameInputName, out username))
            {
                Debug.LogError("Failed to get text from username field.");
                return;
            }
            if (!TextFieldInput.TryGetText(PasswordInputName, out password))
            {
                Debug.LogError("Failed to get text from password field.");
                return;
            }

            username = InputValidator.FmtAllLowercase(username);

            if (!InputValidator.IsValidEmail(username))
            {
                Debug.LogError("Username must be a valid email address.");
            }
            else if (!InputValidator.IsValidPassword(password))
            {
                Debug.LogError("Invalid password: Length must be between " +
                               InputValidator.MinPasswordLength + " and " + InputValidator.MaxPasswordLength + " characters long.");
            }
            else
            {
                socket.Send(register ? "CreateAccountRequest" : "LoginRequest", loginServer, username, password);
            }
        }
Esempio n. 2
0
 public void Selected() {
     currentlySelected = this;
     if (textMesh.text == initialValue) textMesh.text = "";
     textMesh.text += '|';
     InputHandler.Instance.ListenToKeyDown(Tab, KeyCode.Tab);
     InputHandler.Instance.ListenToKeyDown(Return, KeyCode.Return);
     Button.ListenForMissedClick(gameObject.name, MissedClick);
     InputHandler.Instance.ListenToChars(OnInput);
     InputHandler.Instance.ListenToKey(OnBackspace, KeyCode.Backspace);
 }
Esempio n. 3
0
 public void Selected()
 {
     currentlySelected = this;
     if (textMesh.text == initialValue)
     {
         textMesh.text = "";
     }
     textMesh.text += '|';
     InputHandler.Instance.ListenToKeyDown(Tab, KeyCode.Tab);
     InputHandler.Instance.ListenToKeyDown(Return, KeyCode.Return);
     Button.ListenForMissedClick(gameObject.name, MissedClick);
     InputHandler.Instance.ListenToChars(OnInput);
     InputHandler.Instance.ListenToKey(OnBackspace, KeyCode.Backspace);
 }
Esempio n. 4
0
        private void SubmitCreate()
        {
            string playerName;

            if (!TextFieldInput.TryGetText(PlayerNameInput, out playerName))
            {
                return;
            }
            if (!InputValidator.IsValidPlayerName(playerName))
            {
                Debug.LogError("Character name must be letters only and be " + InputValidator.MinPlayerNameLength + " to " + InputValidator.MaxPlayerNameLength + " characters long.");
                return;
            }

            playerName = InputValidator.FmtAllLowercase(playerName);
            socket.Send("CreateCharacter", characterServer, playerName);
            uiManager.CloseAllWindows();
        }
Esempio n. 5
0
 private void Deselected()
 {
     if (currentlySelected == this)
     {
         currentlySelected = null;
     }
     if (textMesh.text[textMesh.text.Length - 1] == '|')
     {
         textMesh.text = textMesh.text.Remove(textMesh.text.Length - 1);
     }
     if (backingText.Length == 0)
     {
         textMesh.text = initialValue;
     }
     InputHandler.Instance.StopListenToKeyDown(Tab, KeyCode.Tab);
     InputHandler.Instance.StopListenToKeyDown(Return, KeyCode.Return);
     Button.StopListenForMissedClick(gameObject.name, MissedClick);
     InputHandler.Instance.StopListenToChars(OnInput);
     InputHandler.Instance.StopListenToKey(OnBackspace, KeyCode.Backspace);
 }
Esempio n. 6
0
        private void Awake()
        {
            socket    = GetComponent <NetSocket>();
            uiManager = GetComponent <UiManager>();

            if (socket == null || uiManager == null)
            {
                Debug.LogError("Missing required component.");
                return;
            }

            socket.RegisterRpcListener(this);
            socket.Events.OnConnectedToServer      += ConnectedToServer;
            socket.Events.OnSocketStart            += ConnectToLoginServer;
            socket.Events.OnFailedToConnect        += ConnectFailed;
            socket.Events.OnDisconnectedFromServer += DisconnectedFromServer;

            Button.ListenForClick(LoginButtonName, LoginClicked);
            Button.ListenForClick(RegisterButtonName, RegisterClicked);
            TextFieldInput.ListenForSubmit(UsernameInputName, Submit);
            TextFieldInput.ListenForSubmit(PasswordInputName, Submit);
        }
Esempio n. 7
0
 void OnDisable()
 {
     Button.StopListenForClick(CreateButtonName, SubmitCreate);
     TextFieldInput.StopListenForSubmit(SubmitCreate);
 }
Esempio n. 8
0
 void OnEnable()
 {
     Button.ListenForClick(CreateButtonName, SubmitCreate);
     TextFieldInput.ListenForSubmit(PlayerNameInput, SubmitCreate);
 }
Esempio n. 9
0
 private void Deselected() {
     if (currentlySelected == this) currentlySelected = null;
     if (textMesh.text[textMesh.text.Length - 1] == '|') textMesh.text = textMesh.text.Remove(textMesh.text.Length - 1);
     if (backingText.Length == 0) textMesh.text = initialValue;
     InputHandler.Instance.StopListenToKeyDown(Tab, KeyCode.Tab);
     InputHandler.Instance.StopListenToKeyDown(Return, KeyCode.Return);
     Button.StopListenForMissedClick(gameObject.name, MissedClick);
     InputHandler.Instance.StopListenToChars(OnInput);
     InputHandler.Instance.StopListenToKey(OnBackspace, KeyCode.Backspace);
 }