ChallengeResultItem.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using UnityEngine;
  2. using System.Collections;
  3. /// <summary>
  4. /// This component is both used for the WhoWonChallenge screen and also for the Challenge Results screen items
  5. /// </summary>
  6. public class ChallengeResultItem : MonoBehaviour
  7. {
  8. public UILabel whoWonLabel;
  9. public UILabel playerScoreLabel;
  10. public UILabel otherScoreLabel;
  11. public UISprite playerCrown;
  12. public UISprite otherCrown;
  13. public UITexture playerAvatar;
  14. public UITexture otherAvatar;
  15. public virtual void SetData(ChallengeResultUIData data)
  16. {
  17. string textKey;
  18. if (data.playerScore > data.otherScore)
  19. {
  20. textKey = "whoWonChallenge.wonText";
  21. playerCrown.enabled = true;
  22. otherCrown.enabled = false;
  23. } else
  24. if (data.playerScore < data.otherScore)
  25. {
  26. textKey = "whoWonChallenge.lostText";
  27. playerCrown.enabled = false;
  28. otherCrown.enabled = true;
  29. } else
  30. {
  31. textKey = "whoWonChallenge.noWinnerText";
  32. playerCrown.enabled = false;
  33. otherCrown.enabled = false;
  34. }
  35. playerScoreLabel.text = data.playerScore.ToString(",000");
  36. otherScoreLabel.text = data.otherScore.ToString(",000");
  37. whoWonLabel.text = string.Format(Localization.instance.Get(textKey), data.otherName);
  38. //player avatar
  39. SocialManager.Instance.GetFacebookProfilePicture(SocialManager.Instance.userID, SocialManager.ProfilePicSettings.square, (isSuccessful, texture) =>
  40. {
  41. playerAvatar.mainTexture = texture;
  42. });
  43. //other avatar
  44. SocialManager.Instance.GetFacebookProfilePicture(data.otherFacebookId, SocialManager.ProfilePicSettings.square, (isSuccessful, texture) =>
  45. {
  46. otherAvatar.mainTexture = texture;
  47. });
  48. }
  49. }