/// <summary> /// Charge this with PlayerProfileData. /// </summary> public PlayerProfile FromData(PlayerProfileData _data) { Uuid = _data.Uuid; AvatarId = _data.AvatarId; Age = _data.Age; Gender = _data.Gender; Tint = _data.Tint; IsDemoUser = _data.IsDemoUser; HasFinishedTheGame = _data.JourneyCompleted; HasFinishedTheGameWithAllStars = _data.HasFinishedTheGameWithAllStars(); ProfileCompletion = _data.ProfileCompletion; TotalNumberOfBones = _data.TotalBones; HasMaxStarsInCurrentPlaySessions = _data.GetAdditionalData().HasMaxStarsInCurrentPlaySessions; ConsecutivePlayDays = _data.GetAdditionalData().ConsecutivePlayDays; CurrentShopState = AnturaSpace.ShopState.CreateFromJson(_data.GetAdditionalData().CurrentShopStateJSON); FirstContactState = JsonUtility.FromJson <FirstContactState>(_data.FirstContactStateJSON); SetCurrentJourneyPosition(_data.GetCurrentJourneyPosition(), false); SetMaxJourneyPosition(_data.GetMaxJourneyPosition(), false); // Antura customization save only customization data jsonAnturaCustomizationData = _data.CurrentAnturaCustomization; return(this); }
public void ImportPlayerProfile(string filePath) { PlayerProfileData importedPlayerProfileData = AppManager.I.DB.ImportDynamicDatabase(filePath); if (importedPlayerProfileData != null) { PlayerProfile importedPlayerProfile = new PlayerProfile().FromData(importedPlayerProfileData); AppManager.I.AppSettings.SavedPlayers.Add(importedPlayerProfile.GetPlayerIconData()); } }
/// <summary> /// Converts this instance to PlayerProfileData. /// </summary> /// <returns></returns> public PlayerProfileData ToData() { PlayerProfileData newProfileData = new PlayerProfileData( Uuid, AvatarId, Gender, Tint, IsDemoUser, HasFinishedTheGame, HasFinishedTheGameWithAllStars, HasMaxStarsInCurrentPlaySessions, Age, TotalNumberOfBones, ProfileCompletion, this.CurrentAnturaCustomizations.GetJsonListOfIds(), ConsecutivePlayDays, CurrentShopState, FirstContactState ); newProfileData.SetCurrentJourneyPosition(this.CurrentJourneyPosition); newProfileData.SetMaxJourneyPosition(this.MaxJourneyPosition); return(newProfileData); }
/// <summary> /// Gets the player profile from db by UUID. /// </summary> /// <param name="playerUUID">The player UUID.</param> /// <returns></returns> public PlayerProfile GetPlayerProfileByUUID(string playerUUID) { PlayerProfileData playerProfileDataFromDB = AppManager.I.DB.LoadDatabaseForPlayer(playerUUID); // If null, the player does not exist. // The DB got desynced. Remove this player! if (playerProfileDataFromDB == null) { Debug.LogError("ERROR: no profile data for player UUID " + playerUUID); } return(new PlayerProfile().FromData(playerProfileDataFromDB)); }
public async Task GetPlayerBio(Player p) { if (p.Rank < 11) { playerProfileData = await playerService.GetPlayerBio(p.PlayerId); } else { playerProfileData = null; } StateHasChanged(); }
private void Load() { XmlSerializer serializer = new XmlSerializer(typeof(PlayerProfileData)); string text = PlayerPrefs.GetString(keyString); if (text.Length == 0) { Debug.Log("Did not find PlayerProfileData in PlayerPrefs. Creating new profile."); playerProfileData = new PlayerProfileData(); } else { using (var reader = new System.IO.StringReader(text)) { playerProfileData = serializer.Deserialize(reader) as PlayerProfileData; } } }
private void LoadCustomProfile(string profileID) { dbManager.LoadDatabaseForPlayer(profileID); PlayerProfileData playerProfile = dbManager.GetPlayerProfileData(); Debug.LogWarning(playerProfile.ToString()); Debug.LogWarning(playerProfile.AppVersion); Debug.LogWarning(playerProfile.Edition); Debug.LogWarning(playerProfile.Tint); Debug.LogWarning(playerProfile.Gender); Debug.LogWarning(dbManager.GetAllRewardPackUnlockData().ToJoinedString()); // Fake wrong JP /*var pp = AppManager.I.PlayerProfileManager.SetPlayerAsCurrentByUUID(profileID); * pp.SetMaxJourneyPosition(new JourneyPosition(1,2,2), _forced:true); * pp.SetCurrentJourneyPosition(new JourneyPosition(1,2,2)); */ }
/// <summary> /// Reloads all the settings and, optionally, the current player /// TODO: rebuild database only for desynchronized profile /// </summary> public void LoadPlayerSettings(bool alsoLoadCurrentPlayerProfile = true) { AppManager.I.AppSettingsManager.LoadSettings(); if (alsoLoadCurrentPlayerProfile) { // No last active? Get the first one. if (AppManager.I.AppSettings.LastActivePlayerUUID == string.Empty) { if (AppManager.I.AppSettings.SavedPlayers.Count > 0) { //UnityEngine.Debug.Log("No last! Get the first."); AppManager.I.AppSettings.LastActivePlayerUUID = AppManager.I.AppSettings.SavedPlayers[0].Uuid; } else { AppManager.I.Player = null; Debug.Log("Actual Player == null!!"); } } else { string playerUUID = AppManager.I.AppSettings.LastActivePlayerUUID; // Check whether the SQL DB is in-sync first PlayerProfileData profileFromDB = AppManager.I.DB.LoadDatabaseForPlayer(playerUUID); // If null, the player does not actually exist. // The DB got desyinced. Do not load it! if (profileFromDB != null) { //UnityEngine.Debug.Log("DB in sync! OK!"); SetPlayerAsCurrentByUUID(playerUUID); } else { //UnityEngine.Debug.Log("DB OUT OF SYNC. RESET"); ResetEverything(); LoadPlayerSettings(); } } } }
//saving only inventory data public void SavePlayerInventory() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/playerInfo.dat"); PlayerProfileData tempData = new PlayerProfileData (); tempData.Init(); tempData.bits = bits; for(int i = 0; i < megaBytesPerLevel.Length; i++) { for(int j = 0; j < megaBytesPerLevel[i].Length; j++) { //Debug.Log(i + " : " + megaBytesPerLevel[i][j]); tempData.megaBytesPerLevel[i][j] = megaBytesPerLevel[i][j]; } } bf.Serialize(file, tempData); file.Close(); }
//saving only level data public void SavePlayerLevelUnlocks() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/playerInventory.dat"); PlayerProfileData tempData = new PlayerProfileData (); tempData.lastLevelCompleted = lastLevelCompleted; for(int index = 0; index < levelUnlocks.Length; index++) tempData.levelUnlocks[index] = levelUnlocks[index]; bf.Serialize(file, tempData); file.Close(); }
public void ResetProfile() { playerProfileData = new PlayerProfileData(); playerProfile.Save(); }
public string GetPlayerProfileHeader(PlayerProfileData bio) { return($"{bio.LastName}, {bio.FirstName} - Rank no.{bio.HeroRank}"); }