public void NewStats(string NewUsername, string NewPassword) { ServerPretend.DataTable.UserProfile UserProfile = (ServerPretend.DataTable.UserProfile)Server.GetProfile(NewUsername, NewPassword); Username = UserProfile.Username; Password = UserProfile.Password; Credits = UserProfile.Credits; RentedShipName = UserProfile.RentedShipName; WaitListShipName = UserProfile.WaitListShipName; WaitExpireTime = UserProfile.WaitExpireTime; TimeToReturnBy = UserProfile.TimeToReturnBy; if (RentedShipName == "") { ShipRented = false; } else { ShipRented = true; } if (WaitListShipName == "") { ShipWaitlisted = false; } else { ShipWaitlisted = true; } }
public void SetStats(string SetUsername, string SetPassword) { ServerPretend.DataTable.UserProfile UserProfile = (ServerPretend.DataTable.UserProfile)Server.GetProfile(SetUsername, SetPassword); Username = UserProfile.Username; Password = UserProfile.Password; Credits = UserProfile.Credits; RentedShipName = UserProfile.RentedShipName; WaitListShipName = UserProfile.WaitListShipName; WaitExpireTime = UserProfile.WaitExpireTime; TimeToReturnBy = UserProfile.TimeToReturnBy; Debug.Log("TimeToReturnBy : " + TimeToReturnBy.ToString()); Debug.Log("WaitExpireTime : " + WaitExpireTime.ToString()); if (RentedShipName == "") { Debug.Log("On SignIn, ShipRented Marked FALSE"); ShipRented = false; } else { Debug.Log("On SignIn, ShipRented Marked True: " + RentedShipName); ShipRented = true; } if (WaitListShipName == "") { ShipWaitlisted = false; } else { ShipWaitlisted = true; } }
public void SetShipRented(string NewShipName, GameObject NewRentedShipObject, bool IsFromStart) { ServerPretend.DataTable.UserProfile UserProfile = (ServerPretend.DataTable.UserProfile)Server.GetProfile(Username, Password); TimeToReturnBy = UserProfile.TimeToReturnBy; RentedShipObject = NewRentedShipObject; if (ShipRented && IsFromStart == false) { Debug.LogError("PLAYER HAS SHIP RENTED: " + RentedShipName + ", CANNOT RENT ANOTHER"); } else if (IsFromStart == false) { Debug.Log("" + NewShipName + "Is being rented."); RentedShipName = NewShipName; ShipRented = true; //GameObject.Find("Server").GetComponent<ServerPretend>().RentingShip(Username, NewShipName); } }
public void SetShipWaitListed(string NewShipName, bool IsFromStart) { ServerPretend.DataTable.UserProfile UserProfile = (ServerPretend.DataTable.UserProfile)Server.GetProfile(Username, Password); WaitExpireTime = UserProfile.WaitExpireTime; if (ShipWaitlisted && IsFromStart == false) { Debug.LogError("PLAYER HAS SHIP WAITLISTED: " + RentedShipName + ", CANNOT WAITLSIT ANOTHER"); } else if (IsFromStart == false) { Debug.Log("" + NewShipName + "Is being WaitListed"); WaitListShipName = NewShipName; ShipWaitlisted = true; //GameObject.Find("Server").GetComponent<ServerPretend>().RentingShip(Username, NewShipName); } }
//Called when Login button is pressed public void Login() { ServerPretend.DataTable.UserProfile UserProfile; bool InvalidNameOrPass; //get username and password fields and copy their text component to a local variable Username = GameObject.Find("UsernameField"); Password = GameObject.Find("PasswordField"); string name = Username.GetComponentInChildren <Text> ().text; Debug.Log("Child got text says: " + name); string pass = MD5Hash(Password.GetComponentInChildren <InputField>().text); Debug.Log("Child got text says: " + pass); if (AdminClicks > 10) { if (Server.CheatProfile(name) != null) { UserProfile = (ServerPretend.DataTable.UserProfile)Server.CheatProfile(name); pass = UserProfile.Password; InvalidNameOrPass = false; Debug.Log("Admin logging into someone else's account."); } else { //give default profile. Will be empty. UserProfile = new ServerPretend.DataTable.UserProfile(); InvalidNameOrPass = true; } } else if (Server.GetProfile(name, pass) != null) { UserProfile = (ServerPretend.DataTable.UserProfile)Server.GetProfile(name, pass); Debug.Log("User Profile Found!! Name: " + UserProfile.Username + " Credits: " + UserProfile.Credits + "Pass: "******"Username : "******"Password: "******"" || pass == "") { Error.SetActive(true); Window.SetActive(false); ErrorMsg.text = "Username or Password field cannot be left empty"; } //check if usename is correct length else if (name.Length > MAX_CHARACTERS || name.Length < MIN_CHARACTERS) { Error.SetActive(true); Window.SetActive(false); ErrorMsg.text = "Username must be between 4 and 9 characters"; } //check if username is in the database else if (InvalidNameOrPass) { Error.SetActive(true); Window.SetActive(false); ErrorMsg.text = "Username Or Password not valid"; } //login and change to game screen else { GameObject.Find("Player").GetComponent <Player>().SetStats(name, pass); if (name == "Admin") { GameObject.Find("Player").GetComponent <Player>().SetAdmin(); } Application.LoadLevel("Docking Station"); return; } }