TrophyInfo.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. this.get_item_label_.text = this.trophy_data_.bonusText;
  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. }
  69. private void OnClickCardButton()
  70. {
  71. Vector3 position = this.card_sprite_.transform.position;
  72. if (this.onClickCardButton != null)
  73. {
  74. this.onClickCardButton(this.trophy_data_, position);
  75. }
  76. }
  77. public Trophy.Data trophy_data
  78. {
  79. get
  80. {
  81. return this.trophy_data_;
  82. }
  83. }
  84. public bool have_visible
  85. {
  86. get
  87. {
  88. return this.have_visible_;
  89. }
  90. }
  91. public Action<Trophy.Data, Vector3> onClickCardButton;
  92. private UISprite trophy_image_sprite_;
  93. private UISprite bg_;
  94. private UILabel title_label_;
  95. private UILabel comment_label_;
  96. private UILabel get_item_label_;
  97. private UILabel maid_point_label_;
  98. private UIButton card_button_;
  99. private UI2DSprite card_sprite_;
  100. private Trophy.Data trophy_data_;
  101. private bool have_visible_;
  102. }