public IEnumerator Iterate(Action <string> outcome) { // Run the command sequence called 'Get Data' on the database name which has been retrieved in the start method.Sends the username and password(from the ui input fields) as parameters IEnumerator e = DCP.RunCS(databaseName, "Iterate", new string[1] { iterating.ToString() }); //IEnumerator e = DCF.GetUserData(playerUsername, playerPassword); // << Send request to get the player's data string. Provides the username and password while (e.MoveNext()) { yield return(e.Current); } var response = e.Current as string; // << The returned string from the request if (response == "Error") { Debug.Log("Error Fetching Data"); } else { // Debug.Log(response); iterating++; outcome.Invoke(response.ToString()); Run(); } }
IEnumerator CheckInDevelopmentCo() { IEnumerator e = DCP.RunCS(databaseName, "CheckInDe"); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(CheckInDevelopmentCo()); yield break; } int tmp = int.Parse(returnText); if (tmp == 1) { shopButton.gameObject.SetActive(true); } else { shopButton.gameObject.SetActive(false); } }
public IEnumerator GetData(Action <string> outcome) { // Run the command sequence called 'Get Data' on the database name which has been retrieved in the start method.Sends the username and password(from the ui input fields) as parameters IEnumerator e = DCP.RunCS(databaseName, "Get Data", new string[2] { playerUsername, playerPassword }); //IEnumerator e = DCF.GetUserData(playerUsername, playerPassword); // << Send request to get the player's data string. Provides the username and password while (e.MoveNext()) { yield return(e.Current); } string response = e.Current as string; // << The returned string from the request if (response == "Error") { Debug.Log("Error Fetching Data"); } else { /* * //The player's data was retrieved. Goes back to loggedIn UI and displays the retrieved data in the InputField * loadingParent.gameObject.SetActive(false); * loggedInParent.gameObject.SetActive(true); * LoggedIn_DataOutputField.text = response; */ if (OnDataRecieved != null) // Just a Unity Event { OnDataRecieved.Invoke(); } outcome.Invoke(response); } }
IEnumerator RegisterUser() { //Initialise data string data; playerPropJson.username = playerUsername; playerPropJson.carbonfootprint = 0; data = JsonUtility.ToJson(playerPropJson); // Run the command sequence called 'Register' on the database name which has been retrieved in the start method.Sends the username and password(from the ui input fields) as parameters IEnumerator e = DCP.RunCS(databaseName, "Register", new string[3] { playerUsername, playerPassword, data }); //IEnumerator e = DCF.RegisterUser(playerUsername, playerPassword, "Hello World"); // << Send request to register a new user, providing submitted username and password. It also provides an initial value for the data string on the account, which is "Hello World". while (e.MoveNext()) { yield return(e.Current); } string response = e.Current as string; // << The returned string from the request if (response == "Success") { //Username and Password were valid. Account has been created. Stop showing 'Loading...' and show the loggedIn UI and set text to display the username. ResetAllUIElements(); loadingParent.gameObject.SetActive(false); loggedInParent.gameObject.SetActive(true); LoggedIn_DisplayUsernameText.text = "Logged In As: " + playerUsername; if (loadsceneonlogin) { UserAccountManager.instance.Login(playerUsername, playerPassword); SceneManager.LoadScene(sceneToLoadOnLogin); } } else { //Something went wrong logging in. Stop showing 'Loading...' and go back to RegisterUI loadingParent.gameObject.SetActive(false); registerParent.gameObject.SetActive(true); if (response == "username in use") { //The username has already been taken. Player needs to choose another. Shows error message. Register_ErrorText.text = "Error: Username Already Taken"; } else { //There was another error. This error message should never appear, but is here just in case. Login_ErrorText.text = "Error: Unknown Error. Please try again later."; } } }
//Called by Button Pressed Methods. These use DatabaseControl namespace to communicate with server. IEnumerator LoginUser() { //Run the command sequence called 'Login' on the database name which has been retrieved in the start method. Sends the username and password (from the ui input fields) as parameters IEnumerator e = DCP.RunCS(databaseName, "Login", new string[2] { playerUsername, playerPassword }); // IEnumerator e = DCP.Login(playerUsername, playerPassword); // << Send request to login, providing username and password while (e.MoveNext()) { yield return(e.Current); } string response = e.Current as string; // << The returned string from the request if (response == "Success") { //Username and Password were correct. Stop showing 'Loading...' and show the LoggedIn UI. And set the text to display the username. ResetAllUIElements(); loadingParent.gameObject.SetActive(false); loggedInParent.gameObject.SetActive(true); LoggedIn_DisplayUsernameText.text = "Logged In As: " + playerUsername; if (loadsceneonlogin) { UserAccountManager.instance.Login(playerUsername, playerPassword); SceneManager.LoadScene(sceneToLoadOnLogin); } } else { //Something went wrong logging in. Stop showing 'Loading...' and go back to LoginUI loadingParent.gameObject.SetActive(false); loginParent.gameObject.SetActive(true); if (response == "UserError") { //The Username was wrong so display relevent error message Login_ErrorText.text = "Error: Username not Found"; } else { if (response == "PassError") { //The Password was wrong so display relevent error message Login_ErrorText.text = "Error: Password Incorrect"; } else { //There was another error. This error message should never appear, but is here just in case. Login_ErrorText.text = "Error: Unknown Error. Please try again later."; } } } }
IEnumerator SetCo() { while (internetchecker.instance.internet == false) { yield return(new WaitForSeconds(0.5f)); if (internetchecker.instance.internet == true) { break; } } IEnumerator e = DCP.RunCS(PlayerPrefs.GetString("dtb"), "Set"); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if ((returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!')) { StartCoroutine(SetCo()); yield break; } int pos = int.Parse(returnText); PlayerPrefs.SetInt("pos1", pos); StartCoroutine(SetOldDayCo("123")); yield return(new WaitForSeconds(0.5f)); getNextDay(); Debug.Log(PlayerPrefs.GetString("dtb") + " " + PlayerPrefs.GetInt("pos1").ToString()); gamemanager.instance.SetHighScore(0); gamemanager.instance.SetSecurity2(); gamemanager.instance.SetMoney(10); gamemanager.instance.SetSecurity3(); menuhighscoretext.text = "0"; menumoneyearnedtext.text = "1.0$"; }
IEnumerator UpdateActiveCo() { IEnumerator e = DCP.RunCS(databaseName, "UpdateActivePlayers"); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if ((returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!')) { StartCoroutine(UpdateActiveCo()); yield break; } }
IEnumerator SetOldDayCo(string ttt) { IEnumerator e = DCP.RunCS(PlayerPrefs.GetString("dtb"), "SetOldDay", new string[2] { PlayerPrefs.GetInt("pos1").ToString(), ttt }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(SetOldDayCo(ttt)); yield break; } }
IEnumerator GetMoneyCo() { IEnumerator e = DCP.RunCS(databaseName, "gettotalmoney"); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if ((returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!')) { StartCoroutine(GetMoneyCo()); yield break; } gamemanager.instance.totalmoney = int.Parse(returnText); gamemanager.instance.totalmoneytxt.text = gamemanager.instance.totalmoney.ToString(); }
IEnumerator AddMoneyCo() { IEnumerator e = DCP.RunCS(databaseName, "addmoney", new string[1] { "1" }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if ((returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!')) { StartCoroutine(AddMoneyCo()); yield break; } }
IEnumerator GetPrizeCo() { IEnumerator e = DCP.RunCS(databaseName, "GetPrize"); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if ((returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!')) { StartCoroutine(GetPrizeCo()); yield break; } prizetext.text = returnText; }
IEnumerator SaveCo() { IEnumerator e = DCP.RunCS(PlayerPrefs.GetString("dtb"), "Save", new string[2] { PlayerPrefs.GetInt("pos1").ToString(), gamemanager.instance.GetHighScore().ToString() + "^$" + gamemanager.instance.GetMoney().ToString() + "^$" + gamemanager.instance.GetBought() + "^$" + PlayerPrefs.GetString("myname") + PlayerPrefs.GetInt("myid").ToString() }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(GetCo()); yield break; } }
IEnumerator GetOldDayCo() { IEnumerator e = DCP.RunCS(PlayerPrefs.GetString("dtb"), "GetOldDay", new string[1] { PlayerPrefs.GetInt("pos1").ToString() }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(GetOldDayCo()); yield break; } beforeday = returnText; t9 = true; if (string.Compare(beforeday, thisday) != 0) { while (t5 == false) { yield return(new WaitForSeconds(0.5f)); if (t5 == true) { break; } } yield return(new WaitForSeconds(0.5f)); menuhighscoretext.text = gamemanager.instance.GetHighScore().ToString(); t10 = true; } StartCoroutine(SetOldDayCo(thisday)); }
IEnumerator GetActiveCo() { IEnumerator e = DCP.RunCS(databaseName, "GetActivePlayers"); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if ((returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!')) { StartCoroutine(GetActiveCo()); yield break; } numberactivetext.text = (int.Parse(returnText) + 1).ToString(); StartCoroutine(GetPrizeCo()); }
IEnumerator FAKEAICO(int i) { IEnumerator e = DCP.RunCS(databaseName, "AI", new string[5] { i.ToString(), PlayerPrefs.GetString("p" + i.ToString() + "nam"), PlayerPrefs.GetString("p" + i.ToString() + "cou"), PlayerPrefs.GetInt("p" + i.ToString() + "mon").ToString(), PlayerPrefs.GetInt("p" + i.ToString() + "hs").ToString() }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(GetOldDayCo()); yield break; } isIR = false; Debug.Log("done " + i); }
IEnumerator CheckCo() { string dtbcheck = "mydatabase" + gamemanager.instance.whichdatabasecheck.ToString(); IEnumerator e = DCP.RunCS(dtbcheck, "Get", new string[1] { gamemanager.instance.whichpositioncheck.ToString() }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if ((returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!')) { StartCoroutine(CheckCo()); yield break; } gamemanager.instance.identitycheck = returnText; gamemanager.instance.resulttxtcheck.text = gamemanager.instance.identitycheck; }
IEnumerator SetDataCourotine(string data) { //Run the command sequence called 'Set Data' on the database name which has been retrieved in the start method. Sends the username, password and data string (from the ui input fields) as parameters IEnumerator e = DCP.RunCS(databaseName, "Set Data", new string[3] { playerUsername, playerPassword, data }); //IEnumerator e = DCF.SetUserData(playerUsername, playerPassword, data); // << Send request to set the player's data string. Provides the username, password and new data string while (e.MoveNext()) { yield return(e.Current); } string response = e.Current as string; // << The returned string from the request if (response == "Success") { Debug.Log("Data Synced To Player ID"); } else { Debug.Log("Error Sending Data"); } }
IEnumerator caltimeday() { IEnumerator e = DCP.RunCS(databaseName, "caltimeday", new string[6] { secondnext2.ToString(), minutenext2.ToString(), hournext2.ToString(), daynext2.ToString(), (monthnext2 - 1).ToString(), yearnext2.ToString() }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(caltimeday()); yield break; } sremainday = float.Parse(returnText); sremainday *= -1; if (sremainday < 0) { StartCoroutine("setNextDateCo"); gamemanager.instance.stop = true; } else { StartCoroutine(CheckingBonnusCo()); } clockday.gameObject.SetActive(true); t2 = true; }
public IEnumerator GetNumOfRows() { // Run the command sequence called 'Get Data' on the database name which has been retrieved in the start method.Sends the username and password(from the ui input fields) as parameters IEnumerator e = DCP.RunCS(databaseName, "GetNumberOfRows"); //IEnumerator e = DCF.GetUserData(playerUsername, playerPassword); // << Send request to get the player's data string. Provides the username and password while (e.MoveNext()) { yield return(e.Current); } var response = e.Current; currentrows = int.Parse(response.ToString()); // Debug.Log(currentrows); iterating = 1; if (numbersofrowsinLastCheck != currentrows) { Run(); } numbersofrowsinLastCheck = currentrows; PlayerScoreList.Clear(); }
IEnumerator setNextDateCo() { int secondnext3, hournext3, minutenext3, daynext3, monthnext3, yearnext3; daynext3 = daynext2; monthnext3 = monthnext2; yearnext3 = yearnext2; if (daynext2 == 31 && monthnext2 == 12) { daynext3 = 1; monthnext3 = 1; yearnext3 = yearnext2 + 1; } else { if ((yearnext2 % 4 == 0 && yearnext2 % 100 != 0) || yearnext2 % 400 == 0) { int[] nmonth = new int[12] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (daynext2 == nmonth[monthnext2 - 1]) { daynext3 = 1; monthnext3 = monthnext2 + 1; } else { daynext3 = daynext2 + 1; monthnext3 = monthnext2; } } else { int[] nmonth = new int[12] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (daynext2 == nmonth[monthnext2 - 1]) { daynext3 = 1; monthnext3 = monthnext2 + 1; } else { daynext3 = daynext2 + 1; monthnext3 = monthnext2; } } } string tmp = "0:0:0"; tmp += ":" + daynext3.ToString() + ":" + monthnext3.ToString() + ":" + yearnext3.ToString(); IEnumerator e = DCP.RunCS(databaseName, "setNextDate", new string[1] { tmp }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(setNextDateCo()); yield break; } DeleteActive(); }
IEnumerator getNextDateCo() { IEnumerator e = DCP.RunCS(databaseName, "getNextDate"); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(getNextDateCo()); yield break; } PlayerPrefs.SetString("thisday", returnText); thisday = returnText; int tmp = 0, i = 0; for (; i <= returnText.Length - 1; i++) { if (returnText [i] == ':') { break; } else { tmp = tmp * 10 + (returnText [i] - '0'); } } i++; secondnext2 = tmp; tmp = 0; for (; i <= returnText.Length - 1; i++) { if (returnText [i] == ':') { break; } else { tmp = tmp * 10 + (returnText [i] - '0'); } } i++; minutenext2 = tmp; tmp = 0; for (; i <= returnText.Length - 1; i++) { if (returnText [i] == ':') { break; } else { tmp = tmp * 10 + (returnText [i] - '0'); } } i++; hournext2 = tmp; tmp = 0; for (; i <= returnText.Length - 1; i++) { if (returnText [i] == ':') { break; } else { tmp = tmp * 10 + (returnText [i] - '0'); } } i++; daynext2 = tmp; tmp = 0; for (; i <= returnText.Length - 1; i++) { if (returnText [i] == ':') { break; } else { tmp = tmp * 10 + (returnText [i] - '0'); } } i++; monthnext2 = tmp; tmp = 0; for (; i <= returnText.Length - 1; i++) { if (returnText [i] == ':') { break; } else { tmp = tmp * 10 + (returnText [i] - '0'); } } i++; yearnext2 = tmp; tmp = 0; t8 = true; }
IEnumerator GetCo() { IEnumerator e = DCP.RunCS(PlayerPrefs.GetString("dtb"), "Get", new string[1] { PlayerPrefs.GetInt("pos1").ToString() }); while (e.MoveNext()) { yield return(e.Current); } string returnText = e.Current as string; if (returnText.Length > 1 && returnText [0] == '<' && returnText [1] == '!') { StartCoroutine(GetCo()); yield break; } string tmp1 = PlayerPrefs.GetString("myname") + PlayerPrefs.GetInt("myid").ToString(); if (!(string.Compare(returnText, "0") == 0 || returnText.Contains(tmp1))) { Application.Quit(); } int res = 0, res2 = 0; Debug.Log(returnText + "-123"); if ((string.Compare(returnText, "0") == 0)) { gamemanager.instance.SetHighScore(0); gamemanager.instance.SetSecurity2(); gamemanager.instance.SetMoney(10); gamemanager.instance.SetSecurity3(); gamemanager.instance.SetBought(0); gamemanager.instance.SetSecurity4(); Debug.Log(returnText + "-123"); } else { res = 0; res2 = 0; int i; for (i = 0; i < returnText.Length; i++) { if (returnText[i] == '^') { break; } else { res = res * 10 + (returnText[i] - '0'); } } Debug.Log(res + " " + PlayerPrefs.GetInt("pos1") + " " + PlayerPrefs.GetString("dtb")); gamemanager.instance.SetHighScore(res); gamemanager.instance.SetSecurity2(); i += 2; for (; i < returnText.Length; i++) { if (returnText[i] == '^') { break; } else { res2 = res2 * 10 + (returnText[i] - '0'); } } gamemanager.instance.SetMoney(res2); gamemanager.instance.SetSecurity3(); i += 2; if (i + 1 >= returnText.Length || returnText[i + 1] != '^') { gamemanager.instance.SetBought(0); gamemanager.instance.SetSecurity4(); } else { res2 = 0; for (; i < returnText.Length; i++) { if (returnText[i] == '^') { break; } else { res2 = res2 * 10 + (returnText[i] - '0'); } } gamemanager.instance.SetBought(res2); gamemanager.instance.SetSecurity4(); } } menuhighscoretext.text = gamemanager.instance.GetHighScore().ToString(); menumoneyearnedtext.text = System.Math.Round(gamemanager.instance.GetMoney() * 0.1f, 1).ToString() + "$"; gamemanager.instance.SetAll(); //StartCoroutine (CheckInDevelopmentCo()); t5 = true; }