Advertisement
Guest User

Untitled

a guest
Mar 10th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.97 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Text.RegularExpressions;
  4. using Steamworks;
  5.  
  6. public class bl_SignUp : MonoBehaviour
  7. {
  8.     [Header("Settings")]
  9.     public int MaxNameLenght = 15;
  10.     public bool RegexSymbols = true;
  11.     [Header("References")]
  12.     public InputField UserNameInput = null;
  13.     public InputField NickNameInput = null;
  14.     public InputField EmailInput = null;
  15.     public InputField PasswordInput = null;
  16.     public InputField RePasswordInput = null;
  17.     private bl_LoginPro Login;
  18.  
  19.     /// <summary>
  20.     ///
  21.     /// </summary>
  22.     void Awake()
  23.     {
  24.         Login = FindObjectOfType<bl_LoginPro>();
  25.         if (UserNameInput != null)
  26.         {
  27.             UserNameInput.characterLimit = MaxNameLenght;
  28.         }
  29.     }
  30.  
  31.     /// <summary>
  32.     ///
  33.     /// </summary>
  34.     void Update()
  35.     {
  36.         if (UserNameInput != null)
  37.         {
  38.             UserNameInput.text = Regex.Replace(UserNameInput.text, @"[^a-zA-Z0-9 ]", "");//not permit simbols
  39.         }
  40.     }
  41.  
  42.     /// <summary>
  43.     ///
  44.     /// </summary>
  45.     public void SignUp()
  46.     {
  47.         string user = SteamFriends.GetPersonaName();
  48.         string nick = SteamFriends.GetPersonaName();
  49.         string pass = PasswordInput.text;
  50.         string repass = RePasswordInput.text;
  51.         string email = EmailInput.text;
  52.         CSteamID steamid = SteamUser.GetSteamID();
  53.         Debug.Log(steamid);
  54.  
  55.         if (!AllFill(user,nick, pass, repass, email))
  56.             return;
  57.         if(pass.Length < bl_LoginProDataBase.Instance.MinPasswordLenght)
  58.         {
  59.             Login.SetLogText(string.Format("your password must be at least <b>{0}</b> characters", bl_LoginProDataBase.Instance.MinPasswordLenght));
  60.             return;
  61.         }
  62.         if(repass != pass)
  63.         {
  64.             Login.SetLogText("Passwords doesn't match.");
  65.             return;
  66.         }
  67.  
  68.         Login.SinUp(user,nick, pass, email, steamid);
  69.     }
  70.  
  71.     /// <summary>
  72.     ///
  73.     /// </summary>
  74.     private bool AllFill(string u,string n,string p,string r,string e)
  75.     {
  76.         if (string.IsNullOrEmpty(u))
  77.         {
  78.             Debug.Log("Login name is empty");
  79.             Login.SetLogText("Login name is empty");
  80.             return false;
  81.         }
  82.         if (string.IsNullOrEmpty(n))
  83.         {
  84.             Debug.Log("Nick Name is empty");
  85.             Login.SetLogText("Nick name is empty");
  86.             return false;
  87.         }
  88.         if (string.IsNullOrEmpty(p))
  89.         {
  90.             Debug.Log("Password is empty");
  91.             Login.SetLogText("Password is empty");
  92.             return false;
  93.         }
  94.         if (string.IsNullOrEmpty(r))
  95.         {
  96.             Debug.Log("Re-password is empty");
  97.             Login.SetLogText("Re-password is empty");
  98.             return false;
  99.         }
  100.         if (string.IsNullOrEmpty(e))
  101.         {
  102.             Debug.Log("Email is empty");
  103.             Login.SetLogText("Email is empty");
  104.             return false;
  105.         }
  106.  
  107.         return true;
  108.     }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement