Пример #1
0
    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;
        }
    }
Пример #2
0
    public Popup_ProfileInfo Setup(int leagueId, Online.League.Profile profile, string userdata)
    {
        avatar.Setup(profile.avatar);
        nicknameLabel.SetText(profile.nickname);
        statusLabel.SetText(profile.status);
        scoreLabel.SetText(profile.score.ToString());
        rankLabel.SetText(profile.rank > 0 ? profile.rank.ToString() : "-");

        var league    = GlobalFactory.Leagues.GetById(leagueId);
        var subleague = GlobalFactory.Leagues.GetByScore(league, profile.score);

        medalImage.sprite = GlobalFactory.Leagues.GetMedal(league, profile.score);
        medalLabel.SetText(subleague.name);
        medalButton.onClick.AddListener(() => Game.Instance.OpenPopup <Popup_MedalInfo>().Setup(league));

        if (userdata != null)
        {
            var data = JsonUtility.FromJson <ProfileData.PublicData>(Utilities.DecompressString(userdata, "{}"));
            data.balls.Reverse();
            foreach (var ballId in data.balls)
            {
                ballPrefab.Clone <Image>().sprite = GlobalFactory.Balls.GetSprite(ballId);
            }
            Destroy(ballPrefab.gameObject);
        }
        else
        {
            ballPrefab.sprite = GlobalFactory.Balls.GetSprite(0);
        }

        return(this);
    }
Пример #3
0
 public static Online.League.Profile GetNextNearProfile(int score, int maxScoreDistance)
 {
     Online.League.Profile res = null;
     foreach (var item in leaderboard.current)
     {
         if (item.score <= score)
         {
             continue;
         }
         var delta = item.score - score;
         if (delta >= maxScoreDistance)
         {
             continue;
         }
         res = item;
     }
     return(res);
 }
Пример #4
0
    public UiLeaderboardItem Setup(int leagueId, Online.League.Profile profile, bool setCupMaterial = true)
    {
        var info = GlobalFactory.Leagues.GetById(leagueId);

        if (background)
        {
            background.color = profile.username == Profile.Username ? playerColor : Color.white;
        }
        if (avatar)
        {
            avatar.Setup(profile.avatar);
        }
        if (nicknameLabel)
        {
            nicknameLabel.SetText(profile.nickname);
        }
        if (descLabel)
        {
            descLabel.SetText(profile.status);
        }
        if (scoreLabel)
        {
            scoreLabel.SetText(profile.score.ToString());
        }
        if (rankLabel)
        {
            rankLabel.SetText(profile.rank > 0 ? profile.rank.ToString() : "-");
        }
        if (medalImage)
        {
            medalImage.sprite = GlobalFactory.Leagues.GetMedal(info, profile.score);
        }

        if (cupImage)
        {
            cupImage.sprite = GlobalFactory.Leagues.GetCupSprite(info.playType);
            if (setCupMaterial && profile.rank < 4)
            {
                cupImage.material = null;
            }
        }

        button.onClick.AddListener(() =>
        {
            Loading.Show();
            button.SetInteractable(false);
            Online.Userdata.GetPublic(profile.username, (succeed, data) =>
            {
                Loading.Hide();
                button.SetInteractable(true);
                if (succeed)
                {
                    Game.Instance.OpenPopup <Popup_ProfileInfo>().Setup(leagueId, profile, data);
                }
                else
                {
                    Game.Instance.OpenPopup <Popup_Confirm>().SetText(111010, profile.nickname).Setup(false, true, null);
                }
            });
        });

        return(this);
    }