using UnityEngine; using System.Collections; public class ChallengeRequestItem : MonoBehaviour { public UILabel label; public UITexture 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.mainTexture = 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); } } }