private void assignListenersButtons() { ok.onClick.AddListener(() => { PlayerPersistenceProvider.addNewPlayer(username.text, password.text); EditorUtility.DisplayDialog("Registered!", "You were successfully registered", "Okay"); GUIManager.switchFrames(GlobalStrings.loginCanvas); }); cancel.onClick.AddListener(() => { GUIManager.switchFrames(GlobalStrings.loginCanvas); }); }
private void assignListenersInputFields() { username.onValueChanged.AddListener((string value) => { usernameAlert.text = (username.text.Contains(" ")) ? GlobalStrings.registerUserNameBlankMessage : GlobalStrings.registerCriteriaFulfilled; setAlertsColor(usernameAlert); setOKButtonStatus(); }); username.onEndEdit.AddListener((string value) => { usernameAlert.text = !PlayerPersistenceProvider.playerDoesNotExist(value) ? GlobalStrings.registerUserNameExistsMessage : GlobalStrings.registerCriteriaFulfilled; setAlertsColor(usernameAlert); setOKButtonStatus(); }); password.onValueChanged.AddListener((string value) => { int numb; passwordAlert.text = ( value.Length > 8 && !int.TryParse(value, out numb) && value.Any(c => char.IsDigit(c)) ) ? GlobalStrings.registerCriteriaFulfilled : GlobalStrings.registerPasswordCriteriaMessage; setAlertsColor(passwordAlert); passwordReAlert.text = (password.text == passwordRe.text) && passwordAlert.text == GlobalStrings.registerCriteriaFulfilled ? GlobalStrings.registerCriteriaFulfilled : GlobalStrings.registerPasswordsMustMatchMessage; setAlertsColor(passwordReAlert); setOKButtonStatus(); }); passwordRe.onValueChanged.AddListener((string value) => { int numb; passwordReAlert.text = ( value.Length > 8 && !int.TryParse(value, out numb) && value.Any(c => char.IsDigit(c)) && (password.text == passwordRe.text) ) ? GlobalStrings.registerCriteriaFulfilled : GlobalStrings.registerPasswordsMustMatchMessage; setAlertsColor(passwordReAlert); setOKButtonStatus(); }); }
private void assignListenersButtons() { ok.onClick.AddListener(() => { //Login the user if (string.IsNullOrEmpty(username.text) || string.IsNullOrEmpty(password.text)) { credentialsInvalidAlert.text = GlobalStrings.loginErrorMessage; credentialsInvalidAlert.color = Color.red; } else { if (PlayerPersistenceProvider.getSpecificPlayer(username.text, password.text) != null) { LoggedInPlayer.Player = PlayerPersistenceProvider.getSpecificPlayer(username.text, password.text); //GUIManager.setFrame(PlayersPersistenceProvider.doesPlayerHaveAPlayername(LoggedInPlayer.Player) ? GUIManager.frames[]) if (LoggedInPlayer.Player != null) { GUIManager.switchFrames((PlayerPersistenceProvider.doesPlayerHaveAPlayername(LoggedInPlayer.Player)) ? GlobalStrings.lobbyCanvas : GlobalStrings.playerLoginCanvas); } else { credentialsInvalidAlert.text = GlobalStrings.loginErrorMessage; credentialsInvalidAlert.color = Color.red; } } else { credentialsInvalidAlert.text = GlobalStrings.loginErrorMessage; credentialsInvalidAlert.color = Color.red; } } }); register.onClick.AddListener(() => { //Off to register GUIManager.switchFrames(GlobalStrings.registerCanvas); }); }
private void assignListenersButtons() { ok.onClick.AddListener(() => { playernameAlert.text = string.IsNullOrEmpty(playername.text) ? GlobalStrings.playerLoginEmptyMessage : PlayerPersistenceProvider.doesThePlayernameAlreadyExist(playername.text) ? GlobalStrings.playerLoginAlreadyExistsMessage : ""; if (playernameAlert.text == "") { PlayerPersistenceProvider.setPlayerName(LoggedInPlayer.Player, playername.text); GUIManager.switchFrames(GlobalStrings.lobbyCanvas); } }); cancel.onClick.AddListener(() => { LoggedInPlayer.Player = null; GUIManager.switchFrames(GlobalStrings.loginCanvas); }); }