void FixedUpdate() { if (PlayerPrefs.GetInt("SetScore") == 1 && InternetChecker.Instance.internetConnectBool && PlayerPrefs.GetString("Username") != "") { MainLeaderBoardEvent Event = new MainLeaderBoardEvent(GameManager.Instance.stateData.HighScore, GameManager.Instance.stateData.lvl); Event.SendInBackground(null); PlayerPrefs.SetInt("SetScore", 0); } if (CurrentCoin != GameManager.Instance.currencyData.Coin && GameManager.Instance.currencyData.Coin != 0) { CurrentCoin = Mathf.MoveTowards(CurrentCoin, GameManager.Instance.currencyData.Coin, (GameManager.Instance.currencyData.Coin / 1.5f) * Time.fixedDeltaTime); } else if (GameManager.Instance.currencyData.Coin == 0) { CurrentCoin = 0; } CurrentGem = GameManager.Instance.currencyData.Gem; if (currentXP != GameManager.Instance.stateData.EXP && GameManager.Instance.stateData.EXP != 0) { currentXP = Mathf.MoveTowards(currentXP, GameManager.Instance.stateData.EXP, GameManager.Instance.stateData.EXP * Time.fixedDeltaTime); } else if (GameManager.Instance.stateData.EXP == 0) { currentXP = 0; } CoinAmount.text = "X " + GameManager.NumberPersian(((int)CurrentCoin).ToString(), CoinAmount).ToString(); GemAmount.text = "X " + GameManager.NumberPersian(((int)CurrentGem).ToString(), GemAmount).ToString(); XPSlider.value = currentXP; expText.text = GameManager.NumberPersian(((int)currentXP).ToString(), expText) + "/" + GameManager.NumberPersian(GameManager.Instance.expNeed().ToString(), expText); if (PlayerPrefs.GetInt("LevelUp") == 1 && !LevelUpPanel.Instance.On) { LevelUpPanel.Instance.Repaint(); } if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } //quitPanel MissionName.text = GameManager.Language("ماموریت ها", "Missions", MissionName); PlayText.text = GameManager.Language("شروع", "Start", PlayText); }
public void SignUp() { playSound("Button"); if (InputValidCheck(username.text, 4, false, false)) { if (InputValidCheck(email.text, 8, true, false)) { if (InputValidCheck(password.text, 8, false, false)) { //openpanel LoadingPanel.gameObject.SetActive(true); BacktoryUser newUser = new BacktoryUser { Username = username.text, Email = email.text, Password = password.text, }; // Registring user to backtory (in background) newUser.RegisterInBackground(response => { // Checking result of operation if (response.Successful) { LoadingPanel.gameObject.SetActive(true); Debug.Log("Register Success; new username is " + response.Body.Username); PlayerPrefs.SetString("Username", username.text); PlayerPrefs.SetString("PassWord", password.text); BacktoryUser.LoginInBackground(username.text, password.text, loginResponse => { // Login operation done (fail or success), handling it: if (loginResponse.Successful) { // Login successful Debug.Log("Welcome " + username); signUpPanel.SetTrigger("Idle"); MainLeaderBoardEvent Event = new MainLeaderBoardEvent(GameManager.Instance.stateData.HighScore, GameManager.Instance.stateData.lvl); Event.SendInBackground(null); PlayerPrefs.SetInt("SetScore", 0); UploadData(); ShowLeaderBoard(); } else if (loginResponse.Code == (int)BacktoryHttpStatusCode.Unauthorized) { // Username 'mohx' with password '123456' is wrong Debug.Log("Either username or password is wrong."); } else { // Operation generally failed, maybe internet connection issue Debug.Log("Login failed for other reasons like network issues."); } }); } else if (response.Code == (int)BacktoryHttpStatusCode.Conflict) { // Username is invalid Debug.Log("Bad username; a user with this username already exists."); SignUpLogText.text = PlayerPrefs.GetString("Language") == "Persian" ? "این نام کاربری وجود دارد" : "username already exists."; LoadingPanel.gameObject.SetActive(false); } else { // General failure Debug.Log("Registration failed; for network or some other reasons."); SignUpLogText.text = PlayerPrefs.GetString("Language") == "Persian" ? "ثبت نام با خطلا مواجه شد" : "Registration failed"; LoadingPanel.gameObject.SetActive(false); } }); //closepanel } else { SignUpLogText.text = PlayerPrefs.GetString("Language") == "Persian" ? "رمزعبور اشتباه است، حداقل 8 حرف" : "Password Is invalid"; //password } } else { SignUpLogText.text = PlayerPrefs.GetString("Language") == "Persian" ? "ایمیل اشتباه است" : "Email Is invalid"; //email } } else { SignUpLogText.text = PlayerPrefs.GetString("Language") == "Persian" ? "نام کاربری اشتباه است، حداقل 8 حرف" : "UserName Is invalid"; //username SignUpLogText.text = "UserName Is invalid"; } }