private void UpdatePlayerToList(Online.League.Leaderboard board) { var leaguescore = PlayModel.GetScore(); if (leaguescore < 1) { return; } board.current.Sort((x, y) => y.score - x.score); if (board.current.Count < 1 || leaguescore < board.current.LastOne().score) { return; } var mine = board.current.Find(x => x.username == Profile.Username); if (mine == null) { board.current.RemoveAt(board.current.LastIndex()); mine = new Online.League.Profile() { avatar = Profile.Avatar.Json, nickname = Profile.Nickname, status = Profile.Status, username = Profile.Username, score = leaguescore }; board.current.Add(mine); } else if (mine.score < leaguescore) { mine.score = leaguescore; } }
public Popup_LeagueInfo Setup(int leagueIndex, Online.League.Leaderboard board) { LeagueLogics.data = null; LeagueLogics.LeagueIndex = leagueIndex; LeagueLogics.leaderboard = board; return(this); }
private void Start() { Loading.Show(); UIBackground.Show(); var info = GlobalConfig.Leagues[leagueIndex]; title.SetText(info.name); prefabItem.gameObject.SetActive(false); playButton.onClick.AddListener(() => Game.Instance.OpenPopup <Popup_LeagueInfo>().Setup(leagueIndex, leaderboard)); Online.League.GetLeaderboard(info.id, 0, 100, (succeed, board) => { Loading.Hide(); if (succeed) { UpdatePlayerToList(board); board.last.Sort((x, y) => y.score - x.score); board.current.Sort((x, y) => y.score - x.score); for (int i = 0; i < board.last.Count; i++) { board.last[i].rank = i + 1; } for (int i = 0; i < board.current.Count; i++) { board.current[i].rank = i + 1; } for (int i = 0; i < legends.Length; i++) { legends[i].Setup(info.id, i < board.last.Count ? board.last[i] : new Online.League.Profile(), false); } foreach (var item in board.current) { prefabItem.Clone <UiLeaderboardItem>().Setup(info.id, item).gameObject.SetActive(true); } Destroy(prefabItem.gameObject); leaderboard = board; UiShowHide.ShowAll(transform); } else { Back(); return; } }); }