TrophyInfo.cs 4.2 KB

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