TrophyInfo.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using UnityEngine;
  3. using wf;
  4. public class TrophyInfo : MonoBehaviour
  5. {
  6. private void Awake()
  7. {
  8. this.bg_ = UTY.GetChildObject(base.gameObject, "BG", false).GetComponent<UISprite>();
  9. this.trophy_image_sprite_ = UTY.GetChildObject(base.gameObject, "TrophyImage/Image", false).GetComponent<UISprite>();
  10. this.title_label_ = UTY.GetChildObject(base.gameObject, "TitleLabel", false).GetComponent<UILabel>();
  11. this.comment_label_ = UTY.GetChildObject(base.gameObject, "CommentParent/CommentLabel", false).GetComponent<UILabel>();
  12. this.get_item_label_ = UTY.GetChildObject(base.gameObject, "CommentParent/GetItemLabel", false).GetComponent<UILabel>();
  13. this.maid_point_label_ = UTY.GetChildObject(base.gameObject, "MaidPoint/PointLabel", false).GetComponent<UILabel>();
  14. this.card_button_ = UTY.GetChildObject(base.gameObject, "Card", false).GetComponentInChildren<UIButton>();
  15. this.card_sprite_ = UTY.GetChildObject(base.gameObject, "Card", false).GetComponentInChildren<UI2DSprite>();
  16. this.card_sprite_.gameObject.SetActive(false);
  17. EventDelegate.Add(this.card_button_.onClick, new EventDelegate.Callback(this.OnClickCardButton));
  18. }
  19. private void OnDestroy()
  20. {
  21. if (this.card_sprite_.sprite2D != null && this.card_sprite_.sprite2D.texture != null)
  22. {
  23. UnityEngine.Object.DestroyImmediate(this.card_sprite_.sprite2D.texture);
  24. }
  25. }
  26. public void SetData(Trophy.Data trophy_data)
  27. {
  28. this.trophy_data_ = trophy_data;
  29. this.maid_point_label_.text = string.Empty + this.trophy_data_.maidPoint;
  30. this.comment_label_.text = this.trophy_data_.infoText;
  31. Utility.SetLocalizeTerm(this.comment_label_, this.trophy_data_.infoTextTerm);
  32. this.trophy_image_sprite_.spriteName = trophy_data.trophySpriteName;
  33. this.SetHaveVisible(GameMain.Instance.CharacterMgr.status.IsHaveTrophy(this.trophy_data_.id));
  34. if (this.card_sprite_.sprite2D != null && this.card_sprite_.sprite2D.texture != null)
  35. {
  36. UnityEngine.Object.DestroyImmediate(this.card_sprite_.sprite2D.texture);
  37. }
  38. this.card_sprite_.sprite2D = null;
  39. if (!string.IsNullOrEmpty(trophy_data.miniCardTextureFileName))
  40. {
  41. Sprite sprite2D = Utility.CreateTextureSprite(trophy_data.miniCardTextureFileName);
  42. this.card_sprite_.sprite2D = sprite2D;
  43. }
  44. }
  45. public void SetHaveVisible(bool value)
  46. {
  47. this.have_visible_ = value;
  48. if (value)
  49. {
  50. this.title_label_.text = this.trophy_data_.name;
  51. this.title_label_.color = new Color(0.25f, 0.25f, 0.25f);
  52. this.maid_point_label_.color = new Color(0.25f, 0.25f, 0.25f);
  53. this.trophy_image_sprite_.alpha = 1f;
  54. this.bg_.alpha = 1f;
  55. this.card_button_.GetComponent<BoxCollider>().enabled = true;
  56. this.card_sprite_.gameObject.SetActive(true);
  57. }
  58. else
  59. {
  60. this.title_label_.text = ((!this.trophy_data_.titleMask) ? this.trophy_data_.name : "????????");
  61. this.title_label_.color = new Color(0.5f, 0.5f, 0.5f);
  62. this.maid_point_label_.color = new Color(0.5f, 0.5f, 0.5f);
  63. this.trophy_image_sprite_.alpha = 0.3f;
  64. this.bg_.alpha = 0.8f;
  65. this.card_button_.GetComponent<BoxCollider>().enabled = false;
  66. this.card_sprite_.gameObject.SetActive(false);
  67. }
  68. if (!this.trophy_data_.titleMask)
  69. {
  70. Utility.SetLocalizeTerm(this.title_label_, this.trophy_data_.nameTerm);
  71. }
  72. }
  73. private void OnClickCardButton()
  74. {
  75. Vector3 position = this.card_sprite_.transform.position;
  76. if (this.onClickCardButton != null)
  77. {
  78. this.onClickCardButton(this.trophy_data_, position);
  79. }
  80. }
  81. public Trophy.Data trophy_data
  82. {
  83. get
  84. {
  85. return this.trophy_data_;
  86. }
  87. }
  88. public bool have_visible
  89. {
  90. get
  91. {
  92. return this.have_visible_;
  93. }
  94. }
  95. public Action<Trophy.Data, Vector3> onClickCardButton;
  96. private UISprite trophy_image_sprite_;
  97. private UISprite bg_;
  98. private UILabel title_label_;
  99. private UILabel comment_label_;
  100. private UILabel get_item_label_;
  101. private UILabel maid_point_label_;
  102. private UIButton card_button_;
  103. private UI2DSprite card_sprite_;
  104. private Trophy.Data trophy_data_;
  105. private bool have_visible_;
  106. }