private void LogInViaDatabase() { // IF ABLE TO (SETTINGS IN APPLICATIONMANAGER AND DATABASEMANAGER), // TRY LOGGING IN BY CHECKING USERNAME AND PASSWORD AGAINST THE DATABASE. #if USES_DATABASEMANAGER if (Database.ClientsCanUse && App.CanWorkOffline) { if (App.GameUser != null) { string strUsername = UsernameInput.GetComponent <InputField>().text.Trim(); string strPassword = PasswordInput.GetComponent <InputField>().text.Trim(); if (strUsername == "" || (App.UserLoginType == 1 && strPassword == "")) { StatusMessage = "All Fields must be Completed."; } else { App.GameUser.LogUserIntoDatabase(strUsername, strPassword); } } else { StatusMessage = "Unable to Communicate with the Database"; } } else { StatusMessage = "Clients are not authorized to Connect in Offline Mode."; } #else StatusMessage = "Database is not Available"; #endif }
private void SignUpViaNetwork() { // ENCRYPT THE USERNAME, PASSWORD AND EMAIL ADDRESS. // SEND TO THE SERVER TO CREATE A NEW USER ACCOUNT. if (Net.IsConnected) { if (App.GameUser != null) { string strUsername = UsernameInput.GetComponent <InputField>().text.Trim(); string strPassword = PasswordInput.GetComponent <InputField>().text.Trim(); string strEmail = EmailAddressInput.GetComponent <InputField>().text.Trim(); if (strUsername == "" || strPassword == "" || strEmail == "") { StatusMessage = "All Fields must be Completed."; } else { strUsername = Crypto.Encrypt(strUsername); strPassword = Crypto.Encrypt(strPassword); strEmail = Crypto.Encrypt(strEmail); App.GameUser.CmdNewUserSignUp(strUsername, strPassword, strEmail); } } else { StatusMessage = "Unable to Communicate with the Server"; } } else { StatusMessage = "Not Connected to the Server"; } }
private void LogInViaNetwork() { // ENCRYPT THE USERNAME AND PASSWORD, SEND TO THE SERVER TO LOG IN if (Net.IsConnected) { if (App.GameUser != null) { string strUsername = UsernameInput.GetComponent <InputField>().text.Trim(); string strPassword = PasswordInput.GetComponent <InputField>().text.Trim(); if (strUsername == "" || (App.UserLoginType == 1 && strPassword == "")) { StatusMessage = "All Fields must be Completed."; } else { strUsername = Crypto.Encrypt(strUsername); strPassword = Crypto.Encrypt(strPassword); App.GameUser.CmdLogUserIn(strUsername, strPassword); } } else { StatusMessage = "Unable to Communicate with the Server"; } } else { StatusMessage = "Not Connected to the Server"; } }
public void DisplayPanel(bool blnClearFields = false) { #if USES_STATUSMANAGER Status.UpdateStatus(); #endif if (blnClearFields) { if (UsernameInput.GetComponent <InputField>().interactable) { UsernameInput.GetComponent <InputField>().text = ""; } PasswordInput.GetComponent <InputField>().text = ""; EmailAddressInput.GetComponent <InputField>().text = ""; } if (Net == null || !Net.IsConnected || App.IsLoggedIn) { // TURN EVERYTHING OFF this.GetComponent <Image>().enabled = false; for (int i = 0; i < this.transform.childCount; i++) { this.transform.GetChild(0).GetChild(i).gameObject.SetActive(false); } } else { // TURN EVERYTHING ON this.GetComponent <Image>().enabled = true; for (int i = 0; i < this.transform.childCount - 1; i++) { this.transform.GetChild(0).GetChild(i).gameObject.SetActive(true); } // MODIFY WHICH BUTTONS/INPUTFIELDS ARE ACTIVE BASED ON THE STATE if (App.UserLoginType == 2) // WINDOWS USERNAME LOGIN TYPE { UsernameInput.GetComponent <InputField>().interactable = false; PasswordContainer.SetActive(false); EmailAddressContainer.SetActive(false); ResetPasswordLabel.SetActive(false); ForgotPasswordContainer.SetActive(false); SignUpButton.SetActive(false); LoginButton.SetActive(!App.IsWorkingOffline && !Net.ForceOffline); UsernameInput.GetComponent <InputField>().text = App.GetWindowsUsername(); UsernameInput.GetComponent <InputField>().MoveTextEnd(false); UsernameInput.GetComponent <InputField>().DeactivateInputField(); EventSystem.current.SetSelectedGameObject(UsernameInput.GetComponent <InputField>().gameObject, null); UsernameInput.GetComponent <InputField>().OnPointerClick(new PointerEventData(EventSystem.current)); } else { UsernameInput.GetComponent <InputField>().interactable = true; UsernameContainer.SetActive(!_blnIsForgetting); PasswordContainer.SetActive(!_blnIsForgetting); EmailAddressContainer.SetActive(_blnIsSigningUp || _blnIsForgetting); ForgotPasswordContainer.SetActive(!_blnIsForgetting && !_blnIsSigningUp); ResetPasswordLabel.SetActive(_blnIsForgetting); LoginButton.SetActive(!App.IsWorkingOffline && !Net.ForceOffline); SignUpButton.SetActive(App.AllowSignUp || _blnIsForgetting || _blnIsSigningUp); } bool blnCanOffline = (App != null && App.CanWorkOffline && App.IsWorkingOffline && !_blnIsForgetting && !_blnIsSigningUp); #if USES_DATABASEMANAGER blnCanOffline = blnCanOffline && Database != null && Database.ClientsCanUse; #else blnCanOffline = false; #endif OfflineButton.SetActive(blnCanOffline); // ACTIVATE/DEACTIVATE BUTTONS BASED ON ACTIVE LOGIN (IE, GAME VERSION IS UP TO DATE) LoginButton.GetComponent <Button>().interactable = LoginIsActive && !Net.IsWorkingOffline; ForgotPasswordButton.GetComponent <Button>().interactable = LoginIsActive && !Net.IsWorkingOffline; SignUpButton.GetComponent <Button>().interactable = LoginIsActive && !Net.IsWorkingOffline && (App.AllowSignUp || _blnIsForgetting || _blnIsSigningUp); OfflineButton.GetComponent <Button>().interactable = LoginIsActive; } }