Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class landButton : MonoBehaviour
- {
- //initialize constructers
- public static string email = "";
- public static string username = "";
- public static string stringer = "";
- 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;
- private string password = "", rePw = "", message = "";
- public static double NextLevelXP = 0;
- public bool register = false;
- public static string zoneName = "";
- 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;
- public static int online;
- public static string[] monsters;
- //Zone struct with sample zones
- public struct Zone
- {
- public string Name;
- public double MinLevel;
- public double MaxLevel;
- public string[] monsters;
- // setters
- public Zone(string Name, double MinLevel, double MaxLevel, string[] monsters)
- {
- this.Name = Name;
- this.MinLevel = MinLevel;
- this.MaxLevel = MaxLevel;
- this.monsters = monsters;
- }
- }
- // Sample zone, load from xml later
- public static IList zoneList = new List<Zone>() {
- 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"}}
- };
- public IList getList()
- {
- return zoneList;
- }
- private void OnGUI()
- {
- if (message != "")
- GUILayout.Box(message);
- //if they chose to register display registration
- if (register)
- {
- GUILayout.Label("Email");
- email = GUILayout.TextField(email);
- GUILayout.Label("Username");
- username = GUILayout.TextField(username);
- GUILayout.Label("Password");
- password = GUILayout.PasswordField(password, "*"[0]);
- GUILayout.Label("Confirm Password");
- rePw = GUILayout.PasswordField(rePw, "*"[0]);
- GUILayout.BeginHorizontal();
- if (GUILayout.Button("Back"))
- register = false;
- if (GUILayout.Button("Register"))
- {
- message = "";
- if (email == "" || username == "" || password == "")
- message += "Please enter all the fields \n";
- else
- {
- if (password == rePw)
- {
- WWWForm form = new WWWForm();
- form.AddField("email", email);
- form.AddField("username", username);
- form.AddField("password", password);
- WWW w = new WWW("http://tenthplanet.ddns.net/InsertUser.php", form);
- StartCoroutine(registerFunc(w));
- }
- else
- message += "Your Passwords do not match \n";
- }
- }
- GUILayout.EndHorizontal();
- }
- else
- {
- //If they do not register display login GUI
- GUILayout.BeginArea(new Rect(150, 335, 200, 200));
- GUILayout.Label("Username");
- username = GUILayout.TextField(username);
- GUILayout.Label("Password");
- password = GUILayout.PasswordField(password, "*"[0]);
- GUILayout.BeginHorizontal();
- if (GUILayout.Button("Load Character"))
- {
- message = "";
- if (username == "" || password == "")
- message += "Please enter all the fields \n";
- else
- {
- WWWForm form = new WWWForm();
- form.AddField("username", username);
- form.AddField("password", password);
- // form.AddField("gold", "0");
- WWW w = new WWW("http://tenthplanet.ddns.net/login.php", form);
- StartCoroutine(login(w));
- }
- }
- if (GUILayout.Button("Register"))
- {
- register = true;
- }
- GUILayout.EndHorizontal();
- GUILayout.EndArea();
- }
- }
- IEnumerator login(WWW w)
- {
- yield return w;
- stringer = w.text;
- if (w.error == null)
- {
- if (w.text == "Success")
- {
- print("Like a boss?");
- }
- else
- message += w.text;
- }
- else
- {
- message += "ERROR: " + w.error + "\n";
- }
- }
- IEnumerator registerFunc(WWW w)
- {
- yield return w;
- if (w.error == null)
- {
- message += w.text;
- }
- else
- {
- message += "ERROR: " + w.error + "\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement