public Popup_ProfileInfo Setup(Online.Friends.Friendship friend, string userdata, int rank) { avatar.Setup(friend.avatar); nicknameLabel.SetText(friend.nickname); statusLabel.SetText(friend.status); scoreLabel.SetText(friend.level); rankLabel.SetText(rank.ToString()); int leagueIndex = GlobalFactory.Friends.GetLeagueIndex(friend.level.ToInt()); medalImage.sprite = GlobalFactory.Friends.GetMedalSprite(leagueIndex); medalLabel.SetText(GlobalFactory.Friends.GetMedalName(leagueIndex)); 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); }
public UIFriendItem Setup(Online.Friends.Friendship friend, int rank) { if (avatar) { avatar.Setup(friend.avatar); } if (nicknameLabel) { nicknameLabel.SetText(friend.nickname); } if (descLabel) { descLabel.SetText(friend.status); } if (levelLabel) { levelLabel.SetText(friend.level); } if (rankLabel) { rankLabel.SetText(rank.ToString()); } if (cupImage && rank < 4) { cupImage.material = null; } if (background && friend.username == Profile.Username) { background.color = Color.green; } int leagueIndex = GlobalFactory.Friends.GetLeagueIndex(friend.level.ToInt()); medalImage.sprite = GlobalFactory.Friends.GetMedalSprite(leagueIndex); if (friend.username == Profile.Username || Profile.IsFriendRewarded(friend.id.ToInt(), friend.level.ToInt())) { descLabel.gameObject.SetActive(true); medalImage.gameObject.SetActive(true); cupImage.gameObject.SetActive(true); rewardButton.transform.parent.gameObject.SetActive(false); } else if (friend.level.ToInt() < GlobalConfig.Friends.minRewardLevel) { descLabel.gameObject.SetActive(false); medalImage.gameObject.SetActive(false); cupImage.gameObject.SetActive(false); rewardButton.transform.parent.gameObject.SetActive(true); rewardButton.SetInteractable(false); rewardDescLabel.gameObject.SetActive(true); rewardDescLabel.SetFormatedText(friend.level.ToInt(), GlobalConfig.Friends.minRewardLevel); } else { descLabel.gameObject.SetActive(false); medalImage.gameObject.SetActive(false); cupImage.gameObject.SetActive(false); rewardButton.transform.parent.gameObject.SetActive(true); rewardButton.SetInteractable(true); rewardDescLabel.gameObject.SetActive(true); rewardDescLabel.SetFormatedText(friend.level.ToInt(), GlobalConfig.Friends.minRewardLevel); rewardButton.onClick.AddListener(() => { rewardButton.gameObject.SetActive(false); Profile.EarnGems(GlobalConfig.Friends.rewardGems); Profile.SetFriendRewarded(friend.id.ToInt(), GlobalConfig.Friends.rewardGems); Game.Instance.OpenPopup <Popup_Rewards>().Setup(0, GlobalConfig.Friends.rewardGems, 0, 0, 0, true, false, () => { descLabel.gameObject.SetActive(true); medalImage.gameObject.SetActive(true); cupImage.gameObject.SetActive(true); rewardButton.transform.parent.gameObject.SetActive(false); }); GlobalAnalytics.SourceGem(GlobalConfig.Friends.rewardGems, "friend"); }); } if (friend.username == Profile.Username) { return(this); } button.onClick.AddListener(() => { Loading.Show(); button.SetInteractable(false); Online.Userdata.GetPublic(friend.username, (succeed, data) => { Loading.Hide(); button.SetInteractable(true); if (succeed) { Game.Instance.OpenPopup <Popup_ProfileInfo>().Setup(friend, data, rank); } else { Game.Instance.OpenPopup <Popup_Confirm>().SetText(111010, friend.nickname).Setup(false, true, null); } }); }); return(this); }