UITrophyItem.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using UnityEngine;
  3. public class UITrophyItem : MonoBehaviour
  4. {
  5. public int TrophyId
  6. {
  7. get
  8. {
  9. return this._trophyId;
  10. }
  11. set
  12. {
  13. this._trophyId = value;
  14. this.DataBind();
  15. }
  16. }
  17. public string TrophyIconSpriteName
  18. {
  19. get
  20. {
  21. return this._trophyIcon.spriteName;
  22. }
  23. set
  24. {
  25. this._trophyIcon.spriteName = value;
  26. }
  27. }
  28. public string TrophyName
  29. {
  30. get
  31. {
  32. return this._trophyName.text;
  33. }
  34. set
  35. {
  36. this._trophyName.text = value;
  37. }
  38. }
  39. public string TrophyDetail
  40. {
  41. get
  42. {
  43. return this._trophyDetail.text;
  44. }
  45. set
  46. {
  47. this._trophyDetail.text = value;
  48. }
  49. }
  50. private void Awake()
  51. {
  52. this._widget = base.GetComponent<UIWidget>();
  53. }
  54. private void OnEnable()
  55. {
  56. this.DataBind();
  57. }
  58. private void DataBind()
  59. {
  60. AchievementManager.AchievementInfo achievementInfo = SingletonMono<AchievementManager>.Instance.GetAchievementInfo(this.TrophyId);
  61. bool achievementUnlockState = SingletonMono<AchievementManager>.Instance.GetAchievementUnlockState(this.TrophyId);
  62. this.TrophyName = achievementInfo.Name;
  63. this.TrophyDetail = achievementInfo.Detail;
  64. this.TrophyIconSpriteName = string.Format("{0}{1}", this.TrophyId, (!achievementUnlockState) ? "_l" : string.Empty);
  65. this._widget.alpha = ((!achievementUnlockState) ? 0.5f : 1f);
  66. }
  67. [SerializeField]
  68. private UISprite _trophyIcon;
  69. [SerializeField]
  70. private UILabel _trophyName;
  71. [SerializeField]
  72. private UILabel _trophyDetail;
  73. private int _trophyId;
  74. private UIWidget _widget;
  75. }