using UnityEngine; using System.Collections; using UnityEngine.UI; using TMPro; using ICTS.Localization; public class ChallengeRequestItem : MonoBehaviour { public TextMeshProUGUI label; public RawImage avatar; ChallengeRequestUIData _challengeRequestData; public void SetData(RequestInfo challengeRequestInfo) { _challengeRequestData = new ChallengeRequestUIData(challengeRequestInfo); label.text = string.Format(Localization.instance.Get("challengeRequests.requestText"), _challengeRequestData.name, _challengeRequestData.score, _challengeRequestData.levelId + 1); SocialManager.Instance.GetFacebookProfilePicture(challengeRequestInfo.senderID, SocialManager.ProfilePicSettings.square, (isSuccessful, texture) => { avatar.texture = texture; }); } void OnDeclineButtonMsg() { //UIUtils.EnableWidgets(gameObject, false); FacebookHelper.Instance.DeclineChallenge(_challengeRequestData, (isSuccessful) => { if (!isSuccessful) { //re-enable for retrying //UIUtils.EnableWidgets(gameObject, true); } }); } void OnAcceptButtonMsg() { if (LivesManager.Instance.CanPlay) { #if UNITY_EDITOR NotificationCenter.Post(NotificationType.SelectNextLevel, 0); #else FacebookHelper.Instance.AcceptChallenge(_challengeRequestData); #endif } else { NotificationCenter.Post(NotificationType.TriedPlayingWithoutLivesLeft); } } }