private PlayerLBEntity GetOrCreatePlayer(string playerId) { PlayerLBEntity playerLBEntity = this.GetCachedPlayer(playerId); if (playerLBEntity == null) { playerLBEntity = new PlayerLBEntity(playerId); this.cachedPlayers.Add(playerLBEntity); } return(playerLBEntity); }
private PlayerLBEntity GetCachedPlayer(string playerId) { int i = 0; int count = this.cachedPlayers.Count; while (i < count) { PlayerLBEntity playerLBEntity = this.cachedPlayers[i]; if (playerLBEntity.PlayerID == playerId) { return(playerLBEntity); } i++; } return(null); }
private AbstractLeaderboardRowView AddPlayerRow(PlayerLBEntity player, SocialTabs tab, FactionToggle faction, string planetUid, int position) { if (player == null || string.IsNullOrEmpty(player.PlayerName)) { return(null); } if (!this.IsFactionToggleValidFactionType(faction, player.Faction) || position >= 51) { return(null); } if (player.PlayerID == Service.CurrentPlayer.PlayerId) { this.currentPlayerTileIndex = position; } return(new LeaderboardRowPlayerView(this, this.gridLoadHelper.GetGrid(), this.itemTemplate, tab, faction, position, player, planetUid)); }
private void OnGetFriendsData(bool success) { if (!success) { this.CommonFriendDataActions(); return; } if (this.Friends == null) { this.CallFriendsDetailsCB(); return; } List <PlayerLBEntity> list = Service.LeaderboardController.Friends.List; Dictionary <string, PlayerLBEntity> dictionary = new Dictionary <string, PlayerLBEntity>(); int i = 0; int count = list.Count; while (i < count) { PlayerLBEntity playerLBEntity = list[i]; if (!string.IsNullOrEmpty(playerLBEntity.SocialID) && !dictionary.ContainsKey(playerLBEntity.SocialID)) { dictionary.Add(playerLBEntity.SocialID, playerLBEntity); } i++; } int j = 0; int count2 = this.Friends.Count; while (j < count2) { SocialFriendData socialFriendData = this.Friends[j]; if (dictionary.ContainsKey(socialFriendData.Id)) { socialFriendData.PlayerData = dictionary[socialFriendData.Id]; if (!this.PlayerIdToFriendData.ContainsKey(socialFriendData.PlayerData.PlayerID)) { this.PlayerIdToFriendData.Add(socialFriendData.PlayerData.PlayerID, socialFriendData); } } j++; } dictionary.Clear(); this.CommonFriendDataActions(); }
protected void OnPlayersListLoaded(List <PlayerLBEntity> playerList, Action populateItemsCallback) { if (playerList != null && GameConstants.SQUAD_INVITES_ENABLED && Service.Get <SquadController>().StateManager.GetCurrentSquad() != null) { FactionType faction = Service.Get <CurrentPlayer>().Faction; List <string> list = new List <string>(); int i = 0; int count = playerList.Count; while (i < count) { PlayerLBEntity playerLBEntity = playerList[i]; if (string.IsNullOrEmpty(playerLBEntity.SquadID) && playerLBEntity.Faction == faction) { list.Add(playerLBEntity.PlayerID); } i++; } Service.Get <SquadController>().CheckSquadInvitesSentToPlayers(list, populateItemsCallback); return; } populateItemsCallback.Invoke(); }
private void ParsePlayerResponse(List <object> players, LeaderboardList <PlayerLBEntity> leaderboardList) { if (players != null && players.Count > 0) { leaderboardList.List.Clear(); int i = 0; int count = players.Count; while (i < count) { Dictionary <string, object> dictionary = players[i] as Dictionary <string, object>; if (dictionary != null) { string text = null; if (dictionary.ContainsKey("_id")) { text = Convert.ToString(dictionary["_id"]); } if (text != null) { PlayerLBEntity orCreatePlayer = this.GetOrCreatePlayer(text); if (orCreatePlayer.FromObject(dictionary) != null) { leaderboardList.List.Add(orCreatePlayer); if (orCreatePlayer.PlayerID == Service.CurrentPlayer.PlayerId) { leaderboardList.AlwaysRefresh = true; } } else { Service.Logger.Warn("Player Leaderboard Entry Failed to parse."); } } } i++; } } }
public LeaderboardRowPlayerView(AbstractLeaderboardScreen screen, UXGrid grid, UXElement templateItem, SocialTabs tab, FactionToggle faction, int position, PlayerLBEntity player, string planetUid) : base(screen, grid, templateItem, tab, faction, position, true) { this.player = player; this.planetUid = planetUid; this.InitView(); }