public void Login() { var loginData = new LoginData() { login = IF_Username.text, password = IF_Password.text }; StartCoroutine(LoginAPI(loginData, res => { if (res.downloadHandler.text != null && res.responseCode == 200) { var userData = JsonUtility.FromJson <UserData>(res.downloadHandler.text); PlayerPrefs.SetString("token", res.GetResponseHeaders()["x-auth"]); PlayerPrefs.SetString("user_id", userData.user_id); PlayerPrefs.SetString("telephone", userData.telephone); PlayerPrefs.SetString("name", userData.name); PlayerPrefs.SetString("email", userData.email); PlayerPrefs.SetString("username", userData.username); OneSignal.SetEmail(userData.email); SceneManager.LoadScene("MainPage"); } else if (res.responseCode == 400) { AndroidNativeFunctions.ShowAlert("Check your email or password and try again . . .", "Error !", "Ok", "", "", (action) => { }); } })); }
public void Signup() { var data = new SignupData() { username = Username.text, name = Fullname.text, email = Email.text, password = Password.text, telephone = Telephone.text }; if (Password.text == RePassword.text) { StartCoroutine(SignupAPI(data, res => { if (res.responseCode == 200) { AndroidNativeFunctions.ShowAlert("We will send email to you, please confirm", "Please follow instructer to reset your password", "Ok", "", "", (action) => { }); GameObject.Find("UIManager").GetComponent <LoginUIManager>().AnimateSigninGroup(); } else if (res.responseCode == 400) { AndroidNativeFunctions.ShowAlert("We will send email to you, please confirm", "Please follow instructer to reset your password", "Ok", "", "", (action) => { }); } })); } }
public void MakeMoneyPurchase(IndexData indexSelected) { int index = indexSelected.IndexValue; if (index < 0 || index >= prices.Count) { return; } var amountBought = prices[index].CoinAmount; // update the amount of potions the player has potionInstance.CoinAmount += amountBought; // setup an alert and say purchase has been made var message = "Thank you for your purchase you now have " + potionInstance.CoinAmount + " coins."; Debug.Log(message); // This is not my code, warpped in a try catch incase something fails try { AndroidNativeFunctions.ShowAlert(message: message, title: "Purchase Completed", positiveButton: "Ok", negativeButton: "", neutralButton: "", action: ShowAlertAction); } catch (System.Exception) {} coinAmountText.text = potionInstance.CoinAmount.ToString(); }
public void OnClick_SelectBook() { if (TextButtonSelectBook.text.Equals("Delete this book")) { AndroidNativeFunctions.ShowAlert("This action will delete your book information and orther people can't acess it", "Remove book from SwapBook", "Sure", "Cancel", "", action => { if (action == DialogInterface.Positive) { StartCoroutine(DeleteBookAPI(currentBookID.ToString(), callback => { var TemList = new List <Transform>(); int x = MarketPage.childCount; for (int i = 0; i < x; i++) { TemList.Add(MyBookPage.GetChild(i)); } for (int i = 0; i < x; i++) { Destroy(TemList[i].gameObject); } TemList.Clear(); x = MyBookSelectPage.childCount; for (int i = 0; i < x; i++) { TemList.Add(MyBookSelectPage.GetChild(i)); } for (int i = 0; i < x; i++) { Destroy(TemList[i].gameObject); } LoadBook(); UIManager.HideBookDetail(); })); } }); return; } if (int.Parse(MyBookNumber.text) > 0) { UIManager.OnClick_Offer(); } else { AndroidNativeFunctions.ShowToast("Your don't have any book to swap !"); } }
public void StartGame() { FindObjectOfType <AudioManager>().Play("button"); //set the name UserName = UserInput.text; //only for debugging: Debug.Log("UserName: "******"UserInput.text: " + UserInput.text); if (UserInput.text == "") { AndroidNativeFunctions.ShowAlert("you forgot to type your name :(", "whats your name?", "ok", "", "", action); //only for debugging: //UserName = "******"; //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } else { PlayerPrefs.SetString("UserName", UserName); //move to GamePlay scene SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } }
public void ForgotPassword() { if (IF_Email.text != null) { StartCoroutine(ForgetAPI(IF_Email.text, res => { if (res.responseCode == 200) { AndroidNativeFunctions.ShowAlert("We will send email to you, please confirm", "Please follow instructer to reset your password", "Ok", "", "", (action) => { }); } else if (res.responseCode == 400 || res.downloadHandler.text == null) { AndroidNativeFunctions.ShowAlert("Check your email and try again . . .", "ERROR !", "Ok", "", "", (action) => { }); } })); } }
void Window3() { if (GUI.Button(NewRect(5, 5, 40, 10), "Show Alert", style)) { AndroidNativeFunctions.ShowAlert("This Message", "This Title", "Ok", "Back", "Later", ShowAlertAction); } if (GUI.Button(NewRect(5, 20, 40, 10), "Show Alert Input", style)) { AndroidNativeFunctions.ShowAlertInput("This Text", "This Message", "This Title", "Ok", "Cancel", ShowAlertInputAction); } if (GUI.Button(NewRect(5, 35, 40, 10), "Show Alert List", style)) { AndroidNativeFunctions.ShowAlertList("This Title", new string[] { "Blue", "Red", "Green", "Yellow" }, ShowAlertListAction); } if (GUI.Button(NewRect(5, 50, 40, 10), "Set Max Volume Level", style)) { AndroidNativeFunctions.SetTotalVolume(15); // 15 Max } if (GUI.Button(NewRect(5, 65, 40, 10), "Set Min Volume Level", style)) { AndroidNativeFunctions.SetTotalVolume(0); //0 Min } if (GUI.Button(NewRect(55, 5, 40, 10), "Get Volume Level", style)) { print("Volume Level: " + AndroidNativeFunctions.GetTotalVolume()); } if (GUI.Button(NewRect(55, 20, 40, 10), "is Connect Internet", style)) { print("is Connect Internet: " + AndroidNativeFunctions.isConnectInternet()); } if (GUI.Button(NewRect(55, 35, 40, 10), "is Connect WiFi", style)) { print("is Connect Wifi: " + AndroidNativeFunctions.isConnectWifi()); } if (GUI.Button(NewRect(55, 50, 40, 10), "Get Battery Level", style)) { print("Battery Level: " + AndroidNativeFunctions.GetBatteryLevel()); } if (GUI.Button(NewRect(55, 65, 40, 10), "Send Email", style)) { AndroidNativeFunctions.SendEmail("Android Native Functions Super Unitypackage.", "Android Native Functions", "*****@*****.**"); } if (GUI.Button(NewRect(5, 80, 40, 10), "<<", style)) { window = 2; } if (GUI.Button(NewRect(55, 80, 40, 10), ">>", style)) { window = 1; } }
IEnumerator Start() { cs = Extensions.CloudSync(); // First, check if user has location service enabled if (!Input.location.isEnabledByUser) { txt.text = "Location service disabled! Enable location in settings!"; #if UNITY_EDITOR world.Initialize(currentPos); #endif // Windows store implementation here #if NETFX_CORE WSANativeDialog.ShowDialog("Wrong settings!", "Enable localization in settings!"); #endif #if UNITY_ANDROID AndroidNativeFunctions.ShowAlert("Please enable localization in settings.", "Alert!", "OK", null, null, null); #endif yield break; } // Start service before querying location Input.location.Start(0.5f, 0.5f); txt.text = "Initializing"; // Wait until service initializes while (Input.location.status == LocationServiceStatus.Initializing) { txt.text += "."; if (txt.text.Contains("....")) { txt.text = "Initializing"; } yield return(new WaitForSeconds(1)); } if (Input.location.status == LocationServiceStatus.Failed) { txt.text = "Positioning failed, check settings and relaunch application!"; // Windows store implementation here #if NETFX_CORE WSANativeDialog.ShowDialog("GPS error!", "Please check Your settings!"); #endif #if UNITY_ANDROID AndroidNativeFunctions.ShowAlert("Localization failed, please check Your settings.", "Alert!", "OK", null, null, null); #endif yield break; } // Wait for fix while (Input.location.lastData.horizontalAccuracy > 70) { txt.text = "Waiting for GPS fix..., " + "current GPS accuracy (needed < 70): " + Input.location.lastData.horizontalAccuracy + ", if it takes too long, try restarting MiCity!"; yield return(new WaitForSeconds(1)); } if (Input.location.status == LocationServiceStatus.Running) { world.Initialize(new Vector2(Input.location.lastData.longitude, Input.location.lastData.latitude)); currentPosLONLAT = new Vector2(Input.location.lastData.longitude, Input.location.lastData.latitude); cs.UserPathCoordinates.Add(new Vector2(Input.location.lastData.longitude, Input.location.lastData.latitude)); lastTimestamp = System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1)).TotalSeconds; txt.text = "Initialized!"; yield break; } }