bots added
This commit is contained in:
@@ -12,6 +12,7 @@ public class NewLoginManager : MonoBehaviour
|
||||
public GameObject usernameWarning;
|
||||
public TMP_InputField usernameInput;
|
||||
public Button btn_login;
|
||||
public Button btn_login_google;
|
||||
public TMP_Text statusTxt;
|
||||
public static bool loginSaved {get{return PlayerPrefs.HasKey("username") && PlayerPrefs.HasKey("password");}}
|
||||
public static string savedUsername{get{return (loginSaved)? PlayerPrefs.GetString("username") : "";}}
|
||||
@@ -49,14 +50,30 @@ public class NewLoginManager : MonoBehaviour
|
||||
WWW www = new WWW(DBmanager.phpRoot + "register_instant.php",form);
|
||||
yield return www;
|
||||
|
||||
|
||||
|
||||
OnRegister(www.text);
|
||||
}
|
||||
|
||||
IEnumerator registerGoogle(string email){
|
||||
statusTxt.text = "Registering you in...";
|
||||
WWWForm form = new WWWForm();
|
||||
form.AddField("key", "#2CuV1Bit^S!sW1ZcgRv8BhrO");
|
||||
form.AddField("name", email + "#0");
|
||||
form.AddField("display_name", PlayerPrefs.GetString("displayname"));
|
||||
form.AddField("password", email + "#0");
|
||||
|
||||
WWW www = new WWW(DBmanager.phpRoot + "register.php",form);
|
||||
yield return www;
|
||||
|
||||
PlayerPrefs.SetString("username",email+"#0");
|
||||
PlayerPrefs.SetString("password", email+"#0");
|
||||
PlayerPrefs.Save();
|
||||
|
||||
Login(true);
|
||||
}
|
||||
|
||||
void OnRegister(string id){
|
||||
try{
|
||||
TutorialManager.justRegistered=true;
|
||||
// TutorialManager.justRegistered=true;
|
||||
int new_id = int.Parse(id);
|
||||
PlayerPrefs.SetString("username", usernameInput.text+"#"+ id);
|
||||
PlayerPrefs.SetString("password", id);
|
||||
@@ -72,34 +89,42 @@ public class NewLoginManager : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
void Login(){
|
||||
StartCoroutine(login());
|
||||
void Login(bool justRegistered = false){
|
||||
StartCoroutine(login(justRegistered));
|
||||
}
|
||||
|
||||
IEnumerator login(){
|
||||
IEnumerator login(bool googleSigned = false, bool justRegistered = false){
|
||||
statusTxt.text = "Logging you in...";
|
||||
|
||||
WWWForm form = new WWWForm();
|
||||
yield return new WaitForSeconds(1);
|
||||
form.AddField("name", savedUsername);
|
||||
form.AddField("password", savedPassword);
|
||||
form.AddField("google", googleSigned ? 1 : 0);
|
||||
WWW www = new WWW(DBmanager.phpRoot + "login.php",form);
|
||||
|
||||
yield return www;
|
||||
Debug.Log(www.text);
|
||||
|
||||
if(DBmanager.Login(www.text)==0){
|
||||
if(TutorialManager.justRegistered){
|
||||
// SceneManager.LoadScene("MinigameTutorial");
|
||||
LoadingScreen.instance.LoadLevel("MinigameTutorial");
|
||||
|
||||
// SceneManager.LoadScene("GameScene");
|
||||
if(justRegistered){
|
||||
LoadingScreen.instance.LoadLevel("Minigame");
|
||||
}else{
|
||||
// SceneManager.LoadScene("GameScene");
|
||||
LoadingScreen.instance.LoadLevel("GameScene");
|
||||
|
||||
|
||||
}
|
||||
|
||||
// if(TutorialManager.justRegistered){
|
||||
// // SceneManager.LoadScene("MinigameTutorial");
|
||||
// LoadingScreen.instance.LoadLevel("MinigameTutorial");
|
||||
|
||||
// // SceneManager.LoadScene("GameScene");
|
||||
// }else{
|
||||
// // SceneManager.LoadScene("GameScene");
|
||||
// // LoadingScreen.instance.LoadLevel("GameScene");
|
||||
|
||||
|
||||
// }
|
||||
}else{
|
||||
statusTxt.text = "Failed!";
|
||||
|
||||
@@ -112,6 +137,10 @@ public class NewLoginManager : MonoBehaviour
|
||||
MessageDialog.instance.ShowQuestion("Sorry", "Looks like there's been an issue logging you in\nPress yes to close the app and Try again later.", OnYes:()=>{Application.Quit();},onlyYes:true,OnNo:()=>{});
|
||||
}
|
||||
|
||||
public void OnGoogleSignComplete(){
|
||||
StartCoroutine(registerGoogle(GoogleLoginManager.loggedEmail));
|
||||
}
|
||||
|
||||
public void OnUsernameInputChanged(string newValue){
|
||||
btn_login.interactable= (usernameInput.text.Length > 2);
|
||||
usernameWarning.SetActive(usernameInput.text.Length< 2);
|
||||
|
||||
Reference in New Issue
Block a user