123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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);
- }
- }
- }
|