public void BuyItem() { if (PlayerInfo.instance.currency > itemPrice) { bool freeslot = false; foreach (InventorySlot slot in inventorySlots) { if (slot.itemID == 0) { freeslot = true; } } if (freeslot == true) { statsHelper.Stats("remove", PlayerInfo.instance.ID, itemPrice); invHelper.AddItem(PlayerInfo.instance.ID, itemID); PlayerInfo.instance.gameObject.GetComponent <InfoUpdater>().UpdateInfo(PlayerInfo.instance.ID); navigationBar.UpdateNavBar(); string message = itemType + " item purchased for " + itemPrice + " vinyl!"; alertController.CreateAlert("Item Received!", message); } else { Debug.Log("Inventory full"); alertController.CreateAlert("Inventory Full!", "Please removed something and try again."); } } else { Debug.Log("Not enough money"); alertController.CreateAlert("Not enough currency", "Try collecting some Vinyl!"); } }
private IEnumerator LoginRoutine(string username, string password, AlertController ac) { string escapedUsername = UnityWebRequest.EscapeURL(username); string escapedpassword = UnityWebRequest.EscapeURL(password); string phpURL = baseURL + "username="******"&password="******"There was an error with UnityWebRequest"); ac.CreateAlert("Login Failed", "Could not connect to server"); } else if (uwrLogin.downloadHandler.text == "MySQL failed to execute") { ac.CreateAlert("Account Creation Failed", "Could not connect to server"); } else if (uwrLogin.downloadHandler.text == "Email or password incorrect") { ac.CreateAlert("Login Failed", "Email or password incorrect"); } // Assign the information to the player after a succesful Debug.LogWarning string[] items = uwrLogin.downloadHandler.text.Split(' '); // Format: "username email ID" // Assign to the PlayerInfo script PlayerInfo playerInfo = GameObject.Find("Player Information").GetComponent <PlayerInfo>(); playerInfo.userName = items[0]; playerInfo.ID = int.Parse(items[2]); playerInfo.currency = int.Parse(items[5]); playerInfo.level = int.Parse(items[6]); while (true) { if (uwrLogin.isDone) { // check if the login was successful if (items[3] == "Successful") { playerInfo.loggedIn = true; success = true; } else { success = false; playerInfo.loggedIn = false; } done = true; Destroy(this); break; } } }
private IEnumerator CARoutine(string email, string username, string password, AlertController ac) { string escapedEmail = UnityWebRequest.EscapeURL(email); string escapedUsername = UnityWebRequest.EscapeURL(username); string escapedpassword = UnityWebRequest.EscapeURL(password); string phpURL = baseURL + "email=" + escapedEmail + "&username="******"&password="******"There was an error with UnityWebRequest"); ac.CreateAlert("Account Creation Failed", "Could not connect to server"); } else if (uwrCreateAccount.downloadHandler.text == "Invalid email address") { ac.CreateAlert("Account Creation Failed", "Email address is invalid!"); } else if (uwrCreateAccount.downloadHandler.text == "Email already exists") { ac.CreateAlert("Account Creation Failed", "Email in use already!"); } else if (uwrCreateAccount.downloadHandler.text == "Username already exists") { ac.CreateAlert("Account Creation Failed", "Username in use already!"); } else if (uwrCreateAccount.downloadHandler.text == "MySQL failed to execute") { ac.CreateAlert("Account Creation Failed", "Could not connect to server"); } while (true) { if (uwrCreateAccount.isDone) { done = true; //Debug.Log("Done"); Destroy(this); break; } } }
// Update is called once per frame void Update() { if (PlayerInfo.instance.loggedIn == true && activated == false) { activated = true; // Let the user know the login was successful string message = "Welcome, " + PlayerInfo.instance.userName + "!"; ac.CreateAlert("Login Succeeded", message); // Move them to the logged in page mN.SelectPage(mN.pages[3]); cosmeticHelper.ShowCosmeticsLoginScreen(PlayerInfo.instance.ID); } }