123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// This component is both used for the WhoWonChallenge screen and also for the Challenge Results screen items
- /// </summary>
- public class ChallengeResultItem : MonoBehaviour
- {
- public UILabel whoWonLabel;
- public UILabel playerScoreLabel;
- public UILabel otherScoreLabel;
- public UISprite playerCrown;
- public UISprite otherCrown;
- public UITexture playerAvatar;
- public UITexture otherAvatar;
- public virtual void SetData(ChallengeResultUIData data)
- {
- string textKey;
- if (data.playerScore > data.otherScore)
- {
- textKey = "whoWonChallenge.wonText";
- playerCrown.enabled = true;
- otherCrown.enabled = false;
- } else
- if (data.playerScore < data.otherScore)
- {
- textKey = "whoWonChallenge.lostText";
- playerCrown.enabled = false;
- otherCrown.enabled = true;
- } else
- {
- textKey = "whoWonChallenge.noWinnerText";
- playerCrown.enabled = false;
- otherCrown.enabled = false;
- }
- playerScoreLabel.text = data.playerScore.ToString(",000");
- otherScoreLabel.text = data.otherScore.ToString(",000");
- whoWonLabel.text = string.Format(Localization.instance.Get(textKey), data.otherName);
- //player avatar
- SocialManager.Instance.GetFacebookProfilePicture(SocialManager.Instance.userID, SocialManager.ProfilePicSettings.square, (isSuccessful, texture) =>
- {
- playerAvatar.mainTexture = texture;
- });
- //other avatar
- SocialManager.Instance.GetFacebookProfilePicture(data.otherFacebookId, SocialManager.ProfilePicSettings.square, (isSuccessful, texture) =>
- {
- otherAvatar.mainTexture = texture;
- });
- }
- }
|