private void OnLevelWasLoaded(int level) { if (level == MAINMENU_SCENE_NUMBER) { // Skip login from other scenes if already logged in if (IsLogedIn) { GameObject.Find("Canvas").transform.FindChild("Login").gameObject.SetActive(false); GameObject.Find("Canvas").transform.FindChild("MainMenu").gameObject.SetActive(true); } // Update the profile to the server if not updated yet if (IsLogedIn && !AlreadyUpdated) { Profile oldProfile = ProfileMessenger.GetProfileByEmail(UserName); oldProfile.numGamesPlayed += 1; oldProfile.numDeath += Death; oldProfile.numPlayerKilled += Kill; if (Won) { oldProfile.numGamesWon++; } else { oldProfile.numGamesLost++; } ResetStats(); ProfileMessenger.SubmitNewProfile(oldProfile); } } // Inform RandomMatchMaker if the player has chosen to load from save file if (level == MATCHING_SCENE_NUMBER) { RandomMatchmaker rm = GameObjectFinder.FindRandomMatchMaker(); rm.LoadedFromFile = LoadedFromFile; } if (level == RESULT_SCENE_NUMBER) { // Display stats in result scene ResultPageController rpc = GameObjectFinder.FindResultPageController(); rpc.IsWinner = Won; rpc.UserName = UserName; rpc.Kill = Kill; rpc.Death = Death; } }
public void RegisterSubmit() { string userName = RegisterUserNameField.text; string email = RegisterEmailField.text; try { int?uid = ProfileMessenger.CreateNewUser(userName, email); if (uid == null) { Debug.LogWarning("register failed"); } else { GlobalState.LoadProfileWithUid((int)uid); GameObjectFinder.FindProfileHandler().LoggedIn(email); GoToMainMenu(); } } catch (ProfileMessagingException e) { DisplayError(e); } }
// Gets the latest version of the given profile form the server public static Profile GetNewProfileFromServer(Profile currentProfile) { int uid = currentProfile.uid; return(ProfileMessenger.GetProfileById(uid)); }
public static bool LoadProfileWithEmail(string email) { GlobalState.Instance._profile = ProfileMessenger.GetProfileByEmail(email); return(true); }
public static bool LoadProfileWithUid(int userid) { GlobalState.Instance._profile = ProfileMessenger.GetProfileById(userid); return(true); }