private void OnPlayerDataLoaded(SocialProfile profile) { User user = new User(); user.UserName = profile.Name; user.Avatar = profile.Avatar; user.UserId = profile.Id; UsersManager.CurrentUser = user; ServerRequests.UpdateUserInfo(UsersManager.CurrentUser, null, null); ServerRequests.GetUsersData(new List <User> { UsersManager.CurrentUser }, AddUserView, () => Debug.Log("GetUsersData Fail")); StartCoroutine(NetworkImage.TryLoadTexturesToCache(new[] { profile.Avatar })); }
private void OnUserFriendsLoaded(string data) { List <User> friendsUsers = JsonConvert.DeserializeObject <VkUserData[]>(data).Select(u => u.ConvertToUser()).ToList(); friendsUsers.RemoveAll(x => x.UserName.ToLower() == "deleted "); friendsUsers.Where(x => string.IsNullOrEmpty(x.Avatar) || x.Avatar == "https://vk.com/images/deactivated_200.png" || x.Avatar == "https://vk.com/images/camera_200.png?ava=1").ToList().ForEach(x => x.Avatar = "noAvatar"); UsersManager.FriendsUsers = friendsUsers; if (UsersManager.FriendsUsers.Count > 0) { StartCoroutine(NetworkImage.TryLoadTexturesToCache(friendsUsers.Select(x => x.Avatar).ToArray())); ServerRequests.GetUsersData(friendsUsers, UpdateUsersData, () => Debug.Log("GetUsersData Fail")); } }
void Awake() { NetworkImage.AddToCahe("noAvatar", _noAvatarSprite); UsersManager = new UsersManager(); Current = this; SocialAPIManager = new SocialAPIManager(_socialAPIJSBridge); SocialAPIManager.Initialize(); SocialAPIManager.UserProfileLoaded += (x) => OnPlayerDataLoaded(x); SocialAPIManager.UserProfileLoadingFailed += (x) => Debug.Log("UserProfileLoadingFailed"); SocialAPIManager.LoadUserProfile(); SocialAPIManager.UserFriendsLoading += OnUserFriendsLoaded; SocialAPIManager.UserFriendsLoadingFailed += OnUserFriendsLoaded; SocialAPIManager.LoadUserFriends(); SocialAPIManager.ProductPurchased += OnProductPurchased; SocialAPIManager.ProductPurchaseFailed += OnProductPurchasedFail; ServerRequests.GetAllUsers(GetAllUsersCallBack, () => Debug.Log("GetAllUsersError")); }
private void GetAllUsersCallBack(string responce) { List <User> bdUsers = JsonConvert.DeserializeObject <User[]>(responce).ToList(); bdUsers.Remove(bdUsers.FirstOrDefault(user => user.UserId == UsersManager.CurrentUser.UserId)); bdUsers.RemoveAll(x => x.UserName.ToLower() == "deleted "); bdUsers.Where(x => string.IsNullOrEmpty(x.Avatar) || x.Avatar == "https://vk.com/images/deactivated_200.png" || x.Avatar == "https://vk.com/images/camera_200.png?ava=1").ToList().ForEach(x => x.Avatar = "noAvatar"); UsersManager.WorldTopUsers = bdUsers; if (UsersManager.WorldTopUsers.Count > 0) { StartCoroutine(NetworkImage.TryLoadTexturesToCache(bdUsers.Select(x => x.Avatar).ToArray())); } if (UsersManager.WorldTopUsers.Count > 0) { _playersFactory.SetWorldUsers(); } }