Advertisement
Guest User

Untitled

a guest
Apr 1st, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.24 KB | None | 0 0
  1. public void RegisterButton()
  2.     {
  3.         if (CreateStepOne() == "01")
  4.         {
  5.             NoticePanel.SetActive(true);
  6.             NoticePanel.transform.GetChild(0).GetComponent<Text>().text = "Please enter username";
  7.             return;
  8.         }
  9.         else if (CreateStepOne() == "02")
  10.         {
  11.             NoticePanel.SetActive(true);
  12.             NoticePanel.transform.GetChild(0).GetComponent<Text>().text = "Please enter password";
  13.             return;
  14.         }
  15.         else if (CreateStepOne() == "03")
  16.         {
  17.             NoticePanel.SetActive(true);
  18.             NoticePanel.transform.GetChild(0).GetComponent<Text>().text = "Your username is dupilcated";
  19.             return;
  20.         }
  21.         else
  22.         {
  23.             newRequest = URL + "user/add/user?" + CreateStepOne();
  24.         }
  25.  
  26.         createPanel.SetActive(true);
  27.  
  28.     }
  29.  
  30.     public void CreateNameButton()
  31.     {
  32.         if (SetName() == "04")
  33.         {
  34.             NoticePanel.SetActive(true);
  35.             createPanel.SetActive(false);
  36.             NoticePanel.transform.GetChild(0).GetComponent<Text>().text = "Please Enter Your Name";
  37.             return;
  38.         }
  39.         else if (SetName() == "05")
  40.         {
  41.             NoticePanel.SetActive(true);
  42.             createPanel.SetActive(false);
  43.             NoticePanel.transform.GetChild(0).GetComponent<Text>().text = "Your name is dupilcated to someone";
  44.             return;
  45.         }
  46.         else
  47.         {
  48.             int newScore = Random.Range(0, 999999999);
  49.             newRequest = URL + "user/add/user?" + CreateStepOne() + SetName() + "score=" + newScore;
  50.             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(newRequest);
  51.             HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  52.             Stream stream = response.GetResponseStream();
  53.             string responseBody = new StreamReader(stream).ReadToEnd();
  54.  
  55.             print(responseBody);
  56.         }
  57.     }
  58.  
  59.     public string CreateStepOne()
  60.     {
  61.         string newText = "";
  62.         if (userText.text != null)
  63.         {
  64.             for (int i = 0; i < players.Length; i++)
  65.             {
  66.                 if (userText.text == players[i].username)
  67.                 {
  68.                     return "03";
  69.                 }
  70.             }
  71.             newText += ("username=" + userText.text + "&");
  72.             newUser = userText.text;
  73.         }
  74.         else
  75.         {
  76.             return "01";
  77.         }
  78.         if (passText.text != null)
  79.         {
  80.             newText += ("pass=" + passText.text + "&");
  81.             newPassword = passText.text;
  82.             createPanel.SetActive(true);
  83.             return newText;
  84.         }
  85.         else
  86.         {
  87.             return "02";
  88.         }
  89.     }
  90.  
  91.     public string SetName() {
  92.         string newText;
  93.         if (nameText.text != null)
  94.         {
  95.             for (int i = 0; i < players.Length; i++)
  96.             {
  97.                 if (nameText.text == players[i].name)
  98.                 {
  99.                     return "05";
  100.                 }
  101.             }
  102.             newName = nameText.text;
  103.             newText = ("name=" + nameText.text + "&");
  104.             return newText;
  105.         }
  106.         else
  107.         {
  108.             return "04";
  109.         }
  110.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement