Advertisement
Guest User

Untitled

a guest
Apr 17th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5.  
  6. public class landButton : MonoBehaviour
  7. {
  8.  
  9. //initialize constructers
  10. public static string email = "";
  11. public static string username = "";
  12. public static string stringer = "";
  13. public static int attack = 20, defense = 0, save = 0, death=0, playerID = 0, maxhealth = 0, maxmana = 0, health = 0, mana = 0, level = 0, experience = 0, gold = 0, prestige = 0, actions = 80, maxactions=0, food = 0, lootboxes = 0, lootkeys = 0, stones = 0, raids=0, bosses=0, strength = 0, agility=0, vitality=0, intelligence=0, wisdom=0, luck=0, fortitude=0;
  14. private string password = "", rePw = "", message = "";
  15. public static double NextLevelXP = 0;
  16. public bool register = false;
  17. public static string zoneName = "";
  18. public static float upStrength = .4f, upFort = .3f, upAgility = .1f, upVitality = .5f, upIntelligence = .3f, upWisdom = .07f, upLuck = .05f, upOnehand=5, upTwohand=5, upSword=5, upAxe=5, upClub=5, upAccuracy=5, upFiremagic=5, upEarthmagic=5, upWatermagic=5, upWindmagic=5, upBlock=2, upDodge=2, upCriticalstrike=1;
  19. public static int online;
  20. public static string[] monsters;
  21.  
  22. //Zone struct with sample zones
  23. public struct Zone
  24. {
  25. public string Name;
  26. public double MinLevel;
  27. public double MaxLevel;
  28. public string[] monsters;
  29.  
  30.  
  31. // setters
  32. public Zone(string Name, double MinLevel, double MaxLevel, string[] monsters)
  33. {
  34. this.Name = Name;
  35. this.MinLevel = MinLevel;
  36. this.MaxLevel = MaxLevel;
  37. this.monsters = monsters;
  38. }
  39.  
  40. }
  41. // Sample zone, load from xml later
  42. public static IList zoneList = new List<Zone>() {
  43. new Zone() {Name="Sewers", MinLevel=0, MaxLevel=500, monsters= new string[] {"Rat", "Sewer Rat", "Cave Rat", "Frenzied Rat", "Giant bug", "Swarm", "Scorpion", "Snake", "Antmen", "Mutated Turtle", "Mutated Human", "The Rat King"}}
  44.  
  45. };
  46.  
  47. public IList getList()
  48.  
  49. {
  50. return zoneList;
  51. }
  52.  
  53. private void OnGUI()
  54. {
  55. if (message != "")
  56. GUILayout.Box(message);
  57. //if they chose to register display registration
  58. if (register)
  59. {
  60. GUILayout.Label("Email");
  61. email = GUILayout.TextField(email);
  62. GUILayout.Label("Username");
  63. username = GUILayout.TextField(username);
  64. GUILayout.Label("Password");
  65. password = GUILayout.PasswordField(password, "*"[0]);
  66. GUILayout.Label("Confirm Password");
  67. rePw = GUILayout.PasswordField(rePw, "*"[0]);
  68.  
  69. GUILayout.BeginHorizontal();
  70.  
  71. if (GUILayout.Button("Back"))
  72. register = false;
  73.  
  74. if (GUILayout.Button("Register"))
  75. {
  76. message = "";
  77.  
  78. if (email == "" || username == "" || password == "")
  79. message += "Please enter all the fields \n";
  80. else
  81. {
  82. if (password == rePw)
  83. {
  84. WWWForm form = new WWWForm();
  85. form.AddField("email", email);
  86. form.AddField("username", username);
  87. form.AddField("password", password);
  88. WWW w = new WWW("http://tenthplanet.ddns.net/InsertUser.php", form);
  89. StartCoroutine(registerFunc(w));
  90. }
  91. else
  92. message += "Your Passwords do not match \n";
  93. }
  94. }
  95. GUILayout.EndHorizontal();
  96. }
  97. else
  98. {
  99. //If they do not register display login GUI
  100. GUILayout.BeginArea(new Rect(150, 335, 200, 200));
  101. GUILayout.Label("Username");
  102. username = GUILayout.TextField(username);
  103. GUILayout.Label("Password");
  104. password = GUILayout.PasswordField(password, "*"[0]);
  105.  
  106. GUILayout.BeginHorizontal();
  107.  
  108. if (GUILayout.Button("Load Character"))
  109. {
  110. message = "";
  111.  
  112. if (username == "" || password == "")
  113. message += "Please enter all the fields \n";
  114. else
  115. {
  116. WWWForm form = new WWWForm();
  117. form.AddField("username", username);
  118. form.AddField("password", password);
  119. // form.AddField("gold", "0");
  120.  
  121. WWW w = new WWW("http://tenthplanet.ddns.net/login.php", form);
  122. StartCoroutine(login(w));
  123. }
  124. }
  125.  
  126. if (GUILayout.Button("Register"))
  127. {
  128. register = true;
  129. }
  130.  
  131. GUILayout.EndHorizontal();
  132. GUILayout.EndArea();
  133. }
  134. }
  135.  
  136. IEnumerator login(WWW w)
  137. {
  138. yield return w;
  139. stringer = w.text;
  140. if (w.error == null)
  141. {
  142. if (w.text == "Success")
  143. {
  144. print("Like a boss?");
  145. }
  146. else
  147. message += w.text;
  148. }
  149. else
  150. {
  151. message += "ERROR: " + w.error + "\n";
  152. }
  153. }
  154.  
  155. IEnumerator registerFunc(WWW w)
  156. {
  157. yield return w;
  158. if (w.error == null)
  159. {
  160. message += w.text;
  161. }
  162. else
  163. {
  164. message += "ERROR: " + w.error + "\n";
  165. }
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement