private void Start() { if (Instance == null) { Instance = this; } SlicingObjectName = SecurePlayerPrefs.GetString("SlicingObject"); GameMode = (GameType)Enum.Parse(typeof(GameType), Scenes.GetString("GameMode")); StartGame(5, GameMode); GameObject.Find("OpponentName").GetComponent <Text>().text = "You vs. " + Scenes.GetString("OpponentName"); }
public bool Login(string clientName, string clientPassword, bool showPopups = true) { if (!IsUsernameAllowed(clientName)) { return(false); } if (clientName != SecurePlayerPrefs.GetString("ClientName") || clientPassword != SecurePlayerPrefs.GetString("ClientPassword")) { // Set new Login Credentials SecurePlayerPrefs.SetString("ClientName", clientName); SecurePlayerPrefs.SetString("ClientPassword", clientPassword); } // Send request string rawResponse = SendRequest(new MpRequest.Login(), CallbackType.None, false); // We dont need a token for this request -> ignore if token is expired // Check if request failed if (RequestFailed(rawResponse)) { MpResponse.Status statusResponse = JsonUtility.FromJson <MpResponse.Status>(rawResponse); if (statusResponse.ErrorLevel == "InvalidLogin" && showPopups) { Other.Tools.CreatePopup(Other.Tools.Messages.InvalidLogin); } return(false); } // Handle response MpResponse.Token response = JsonUtility.FromJson <MpResponse.Token>(rawResponse); SecurePlayerPrefs.SetString("ClientToken", response.ClientToken); // Set new token SecurePlayerPrefs.SetInt("ClientTokenExpire", CurrentTimestamp() + 3600); // We add 3600 seconds because the token will be valid for one hour LoggedIn = true; // Set status SecurePlayerPrefs.SetInt("IsRegistered", 1); if (showPopups) { Other.Tools.CreatePopup(Other.Tools.Messages.LoggedIn); } return(true); }
public bool Login(bool showPopups = true) { return(Login(SecurePlayerPrefs.GetString("ClientName"), SecurePlayerPrefs.GetString("ClientPassword"), showPopups)); }