private void Announce_LoginSuccess(PlayerProfileModel profile) { if (LoginSuccess != null) { LoginSuccess(profile); } }
//TODO Once finished use flatbuffer to save player game data public void SaveProfileToFlat(PlayerProfileModel prof) { float start = Time.realtimeSinceStartup; List <Offset <CharacterModelFlat> > charList = new List <Offset <CharacterModelFlat> >(); FlatBufferBuilder fbb = new FlatBufferBuilder(1); StringOffset item = fbb.CreateString(prof.itemString); foreach (CharacterModel model in prof.characters) { charList.Add(AddCharacterToFlat(fbb, model)); } VectorOffset charVector = fbb.CreateVectorOfTables <CharacterModelFlat>(charList.ToArray()); PlayerProfileFlat.StartPlayerProfileFlat(fbb); PlayerProfileFlat.AddGold(fbb, prof.Gold); PlayerProfileFlat.AddItems(fbb, item); PlayerProfileFlat.AddCharacters(fbb, charVector); Offset <PlayerProfileFlat> offset = PlayerProfileFlat.EndPlayerProfileFlat(fbb); PlayerProfileFlat.FinishPlayerProfileFlatBuffer(fbb, offset); MemoryStream ms = new MemoryStream(fbb.DataBuffer.Data, fbb.DataBuffer.Position, fbb.Offset); File.WriteAllBytes(XmlSaver.PersistentDataPath() + "/SAVEDATA", ms.ToArray()); Debug.Log("Flat Saving time " + (Time.realtimeSinceStartup - start)); }
private void CheckForPrizes(PlayerProfileModel profile) { PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(), result => { if (result.Inventory.Count > 0) { for (int i = 0; i < result.Inventory.Count; i++) { if (result.Inventory[i].ItemClass == itemClass) { prizeInstanceID = result.Inventory[i].ItemInstanceId; SetItemData(result.Inventory[i].ItemId); } } } else { canvas.FadeCanvasGroup(0); } }, error => { Debug.Log("Got error getting inventory"); Debug.Log(error.GenerateErrorReport()); } ); }
public async Task <IActionResult> Put([FromBody] PlayerProfileModel playerProfile) { PlayerProfile profileEntity = _mapper.CreateMapper().Map <PlayerProfile>(playerProfile); await _playerProfileService.WeakUpdate(profileEntity).ConfigureAwait(false); return(Ok()); }
/// <summary> /// Successfunction that is called after the combinedInfoRequest was successfull /// </summary> /// <param name="result"></param> public void CombinedInfoSuccess(GetPlayerCombinedInfoResult result) { CurrentPlayer = result.InfoResultPayload.PlayerProfile; CurrentPlayerAccount = result.InfoResultPayload.AccountInfo; if (result.InfoResultPayload.UserVirtualCurrency.TryGetValue("CR", out int balance)) { GameInstance.instance.credits = balance; Credits = balance.ToString(); } else { GameInstance.instance.credits = 0; Credits = "0"; } var statisticList = new List <StatisticModel>(); foreach (var statisticValue in result.InfoResultPayload.PlayerStatistics) { var model = new StatisticModel { Value = statisticValue.Value, Name = statisticValue.StatisticName }; statisticList.Add(model); } CurrentPlayer.Statistics = statisticList; fullyLoaded = true; }
public bool LoadSession() { player = manager.LoadProfile(); if (player != null) { player.ParseItemToList(); } equipments = manager.LoadEquipments(); return(player == null); }
public void SetUp(PlayerIndexProfileData _data) { profileData = _data; Debug.Assert(!string.IsNullOrEmpty(profileData.profileModel)); profileModel = GameUtil.ConvertToPlayFabPlayerProfilemodel(profileData.profileModel); player_name_txt.text = profileModel.DisplayName; Debug.Log(player_name_txt.text + "time " + profileData.playerFinishTime); var TimeSpan = System.TimeSpan.FromTicks(System.Convert.ToInt64(profileData.playerFinishTime)); player_time_txt.text = TimeSpan.ToString(@"mm\:ss\:fff"); }
private string FixUserName(PlayerProfileModel profileToFix) { string username = profileToFix.PlayerId; if (profileToFix.DisplayName != null) { username = profileToFix.DisplayName; username = username.Substring(0, username.Length - nameSuffixLength); } return(username); }
private bool IsOnline(PlayerProfileModel playerProfile) { if (string.IsNullOrEmpty(playerProfile.ContactEmailAddresses[0].EmailAddress)) { return(false); } else { var _str = PlayfabConstants.Instance.StringSplitter(playerProfile.ContactEmailAddresses[0].EmailAddress); if (_str.Length < 7) { return(false); } else { string _lastLogin = _str[2] + "/" + _str[3] + "/" + _str[1] + " " + _str[4] + ":" + _str[5]; DateTime _lastLoginDateTime = DateTime.ParseExact(_lastLogin, "MM/dd/yyyy HH:mm", null); Debug.Log("456 Last Login Time: " + _lastLoginDateTime); Debug.Log("456 Servers Time: " + ServerTime); Debug.Log("456 Server Time Difference" + (ServerTime - _lastLoginDateTime).TotalMinutes); if ((ServerTime - _lastLoginDateTime).TotalSeconds <= 90) { return(true); } else { if ((ServerTime - _lastLoginDateTime).TotalMinutes < 60) { ActivityText.text = Convert.ToInt32((ServerTime - _lastLoginDateTime).TotalMinutes) + " Minutes Ago"; } else if ((ServerTime - _lastLoginDateTime).TotalHours < 24) { ActivityText.text = Convert.ToInt32((ServerTime - _lastLoginDateTime).TotalHours) + " Hours Ago"; } else { ActivityText.text = "A While Ago"; } return(false); } } } }
public PlayerProfileModel CreateNewProfile(CharacterModel mainChara) { PlayerProfileModel profile = new PlayerProfileModel(); profile.itemsId = new List <string>(); profile.itemsOwned = new List <int>(); mainChara.isMainCharacter = true; profile.mainChara = new MainCharaModel(); profile.mainChara.fame = 10; profile.mainChara.leadership = 10; profile.Gold = 100; profile.characters = new List <CharacterModel>(); profile.characters.Add(mainChara); return(profile); }
public PlayFabAccountData(LoginResult loginResult) { playFabId = loginResult.PlayFabId; lastLoginTime = loginResult.LastLoginTime ?? DateTime.Now; playerProfileModel = loginResult.InfoResultPayload.PlayerProfile; userAccountInfo = loginResult.InfoResultPayload.AccountInfo; playerStatistics = new List <StatisticValue>(loginResult.InfoResultPayload.PlayerStatistics); titleData = loginResult.InfoResultPayload.TitleData; userData = loginResult.InfoResultPayload.UserData; userDataVersion = loginResult.InfoResultPayload.UserDataVersion; userInventory = new List <ItemInstance>(loginResult.InfoResultPayload.UserInventory); userReadOnlyData = loginResult.InfoResultPayload.UserReadOnlyData; userReadOnlyDataVersion = loginResult.InfoResultPayload.UserReadOnlyDataVersion; userVirtualCurrency = loginResult.InfoResultPayload.UserVirtualCurrency; userVirtualCurrencyRechargeTimes = loginResult.InfoResultPayload.UserVirtualCurrencyRechargeTimes; }
private void GetPlayerStatsResult(GetLeaderboardAroundPlayerResult result) { if (result.Leaderboard.Count > 1) { Debug.LogError("too much profiles returned"); } if (PlayerProfileComponent != null) { PlayerProfileModel Prof = result.Leaderboard [0].Profile; PlayerData data = new PlayerData(); data.dispName = Prof.DisplayName; data.avatar = Prof.AvatarUrl; LocalPlayer.ParsePlayfabStats(Prof.Statistics, data); PlayerProfileComponent.LoadPlayerProfile(data); } }
public void OnLoggedIn() { GetPlayerProfileRequest getProfileRequest = new GetPlayerProfileRequest { PlayFabId = LoginRegister.instance.playFabId, ProfileConstraints = new PlayerProfileViewConstraints { ShowDisplayName = true } }; PlayFabClientAPI.GetPlayerProfile(getProfileRequest, result => { profile = result.PlayerProfile; Debug.Log("Loaded in player: " + profile.DisplayName); }, error => Debug.Log(error.ErrorMessage) ); }
public void SetData(Player playerData, Color color) { Debug.Log("player " + playerData.CustomProperties); if (!playerData.CustomProperties.ContainsKey(PlayerPropertiesKey.PLAYFAB_PROFILE)) { Debug.LogError(PlayerPropertiesKey.PLAYFAB_PROFILE + "Key not found"); return; } var playerProfileJson = playerData.CustomProperties[PlayerPropertiesKey.PLAYFAB_PROFILE] as string; if (!string.IsNullOrEmpty(playerProfileJson)) { profilemodel = GameUtil.ConvertToPlayFabPlayerProfilemodel(playerProfileJson.ToString()); } else { Debug.LogError("playerProfileJson is string empty or null"); } userId = playerData.UserId; playername_text.text = profilemodel.DisplayName; playerColor = color; // bg_image.color = color; }
public IActionResult Profile(int id) { int offset = 0; if (Request.Headers.ContainsKey("X-Timezone-Offset")) { int n = 0; if (int.TryParse(Request.Headers["X-Timezone-Offset"], out n)) { offset = n; } } var player = _data.PlayerProfile(_casino, id).Result; var notes = _data.PlayerNotes(_casino, id).Result; var data = new PlayerProfileModel { Player = player, Notes = notes, TimezoneOffset = offset, }; return(View(data)); }
private bool IsOnline(PlayerProfileModel playerProfile, DateTime serverTime) { if (string.IsNullOrEmpty(playerProfile.ContactEmailAddresses[0].EmailAddress)) { return(false); } else { var _str = PlayfabConstants.Instance.StringSplitter(playerProfile.ContactEmailAddresses[0].EmailAddress); if (_str.Length < 7) { return(false); } else { string _lastLogin = _str[2] + "/" + _str[3] + "/" + _str[1] + " " + _str[4] + ":" + _str[5]; DateTime _lastLoginDateTime = DateTime.ParseExact(_lastLogin, "MM/dd/yyyy HH:mm", null); Debug.Log("456 Last Login Time: " + _lastLoginDateTime); Debug.Log("456 Servers Time: " + serverTime); Debug.Log("456 Server Time Difference" + (serverTime - _lastLoginDateTime).TotalMinutes); if ((serverTime - _lastLoginDateTime).TotalSeconds <= 90) { return(true); } else { return(false); } } } }
public void SetPlayerInfo(PlayerProfileModel profile) { if (profile == null) { Destroy(gameObject); } if (profile.ContactEmailAddresses.Count > 0 && !string.IsNullOrEmpty(profile.ContactEmailAddresses[0].EmailAddress)) { var _str = PlayfabConstants.Instance.StringSplitter(profile.ContactEmailAddresses[0].EmailAddress); // if (string.IsNullOrEmpty(profile.DisplayName)) // playerDisplayName.text = profile.DisplayName; int _avatarIndex = Int32.Parse(_str[0]); if (_avatarIndex != 0) { playerProfilePic.sprite = HazariPlayersCountryFlag.Instance.LocalAvatars[_avatarIndex - 1]; } else { if (String.IsNullOrEmpty(profile.AvatarUrl)) { playerProfilePic.sprite = HazariPlayersCountryFlag.Instance.LocalAvatars[0]; } else { Davinci.get().load(profile.AvatarUrl).setFadeTime(0f).into(playerProfilePic).start(); } } } CountryFlag.sprite = HazariPlayersCountryFlag.Instance.GetCountryFlag((int)profile.Locations[0].CountryCode); }
public void LoggedIn() { GetPlayerProfileRequest getProfReq = new GetPlayerProfileRequest { PlayFabId = UIManager.loginInstance.playFabId, ProfileConstraints = new PlayerProfileViewConstraints { ShowDisplayName = true } }; PlayFabClientAPI.GetPlayerProfile(getProfReq, result => { profile = result.PlayerProfile; Debug.Log("Logged in as :" + profile.DisplayName); }, error => { Debug.Log(error.ErrorMessage); } ); }
public void SetPlayer(PlayerProfileModel player) { _player = player; }
public void SetPlayerInfo(PlayerProfileModel profile) { if (profile == null) { Destroy(gameObject); } ChallengeButtonText.text = IsOnline ? "Challenge" : "Invite"; if (PlayfabConstants.Instance.MyPlayfabID != null && PlayfabID == PlayfabConstants.Instance.MyPlayfabID) { Destroy(gameObject); } if (profile.ContactEmailAddresses.Count <= 0) { Destroy(gameObject); } else { if (string.IsNullOrEmpty(profile.ContactEmailAddresses[0].EmailAddress)) { Destroy(gameObject); } else { var _str = PlayfabConstants.Instance.StringSplitter(profile.ContactEmailAddresses[0].EmailAddress); // if (!(_str[6] == "0" || _str[6] == "4" || _str[6] == "5")) { }// Destroy(gameObject); //else if (true) { //if (IsOnline && !(_str[6] == "0" || _str[6] == "4" || _str[6] == "5")) { ChallengeButton.gameObject.SetActive(false); } PlayerName.text = profile.DisplayName; int _avatarIndex = Int32.Parse(_str[0]); if (_avatarIndex != 0) { PlayerAvatar.sprite = HazariPlayersCountryFlag.Instance.LocalAvatars[_avatarIndex - 1]; } else { if (String.IsNullOrEmpty(profile.AvatarUrl)) { PlayerAvatar.sprite = HazariPlayersCountryFlag.Instance.LocalAvatars[0]; } else { Davinci.get().load(profile.AvatarUrl).setFadeTime(0f).into(PlayerAvatar).start(); } } PlayerCountryFlag.sprite = HazariPlayersCountryFlag.Instance.GetCountryFlag((int)profile.Locations[0].CountryCode); No.text = PlayfabConstants.Instance.OnlineFriendCounter.ToString(); PlayfabConstants.Instance.OnlineFriendCounter++; if (IsOnline && _str.Length >= 7) { SetCurrentOnlineState(_str[6]); } else { string _lastLogin = _str[2] + "/" + _str[3] + "/" + _str[1] + " " + _str[4] + ":" + _str[5]; DateTime _lastLoginDateTime = DateTime.ParseExact(_lastLogin, "MM/dd/yyyy HH:mm", null); if ((ServerTime - _lastLoginDateTime).TotalMinutes < 60) { PlayerActivityStatus.text = Convert.ToInt32((ServerTime - _lastLoginDateTime).TotalMinutes) + " Minutes Ago"; ChallengeButton.gameObject.SetActive(true); } else if ((ServerTime - _lastLoginDateTime).TotalHours < 24) { PlayerActivityStatus.text = Convert.ToInt32((ServerTime - _lastLoginDateTime).TotalHours) + " Hours Ago"; ChallengeButton.gameObject.SetActive(true); } else { PlayerActivityStatus.text = "A While Ago"; ChallengeButton.gameObject.SetActive(true); } } } } } }
public void CreateNewSession(CharacterModel model) { player = manager.CreateNewProfile(model); equipments = new PlayerEquipments(); equipments.list = new List <Equipment>(); }
public void SetPlayerInfo(PlayerProfileModel profile) { if (profile == null) { Destroy(gameObject); } if (PlayfabConstants.Instance.MyPlayfabID != null && PlayfabID == PlayfabConstants.Instance.MyPlayfabID) { Destroy(gameObject); } if (profile.ContactEmailAddresses.Count <= 0) { Destroy(gameObject); } else { if (string.IsNullOrEmpty(profile.ContactEmailAddresses[0].EmailAddress)) { Destroy(gameObject); } else { bool _isOnline = IsOnline(profile); ActivityIcon.color = _isOnline ? onlineColor : offlineColor; var _str = PlayfabConstants.Instance.StringSplitter(profile.ContactEmailAddresses[0].EmailAddress); if (_str.Length < 7) { Destroy(gameObject); } if (_isOnline) { SetCurrentOnlineState(_str[6]); } PlayerName.text = profile.DisplayName; int _avatarIndex = Int32.Parse(_str[0]); if (_avatarIndex != 0) { PlayerAvatar.sprite = HazariPlayersCountryFlag.Instance.LocalAvatars[_avatarIndex - 1]; } else { if (String.IsNullOrEmpty(profile.AvatarUrl)) { PlayerAvatar.sprite = HazariPlayersCountryFlag.Instance.LocalAvatars[0]; } else { Davinci.get().load(profile.AvatarUrl).setFadeTime(0f).into(PlayerAvatar).start(); } } PlayerCountryFlag.sprite = HazariPlayersCountryFlag.Instance.GetCountryFlag((int)profile.Locations[0].CountryCode); //No.text = PlayfabConstants.Instance.OnlineFriendCounter.ToString(); } } }
/// <summary> /// PlayFab から Client へデータを同期する。 /// </summary> /// <param name="profile"></param> /// <param name="statistics"></param> public static void SyncPlayFabToClient(PlayerProfileModel profile, List <StatisticValue> statistics) { // 初回ログイン時は null なので new しておく Profile = profile ?? new PlayerProfileModel(); Statistics = statistics; }
private void EventHandler_LoginSuccess(PlayerProfileModel received_profile) { PlayFabLogin.LoginSuccess -= EventHandler_LoginSuccess; playerProfile = received_profile; }
public void SaveProfile(PlayerProfileModel model) { XmlSaver.SaveXmlToFile <PlayerProfileModel>("/MainSave.xml", model); //SaveProfileToFlat(model); }