GoodsItemTipsView.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using FairyGUI;
  2. using UI.CommonGame;
  3. using System.Collections;
  4. namespace GFGGame
  5. {
  6. public class GoodsItemTipsView : BaseWindow
  7. {
  8. private UI_GoodsItemTips _ui;
  9. // private ItemView itemView;
  10. private ApproachView approachView;
  11. private ItemCfg itemCfg;
  12. public override void Dispose()
  13. {
  14. base.Dispose();
  15. // itemView.Dispose();
  16. if (approachView != null)
  17. {
  18. approachView.Dispose();
  19. approachView = null;
  20. }
  21. if (_ui != null)
  22. {
  23. _ui.Dispose();
  24. _ui = null;
  25. }
  26. }
  27. protected override void OnInit()
  28. {
  29. base.OnInit();
  30. _ui = UI_GoodsItemTips.Create();
  31. this.viewCom = _ui.target;
  32. this.viewCom.Center();
  33. this.modal = true;
  34. }
  35. protected override void AddEventListener()
  36. {
  37. base.AddEventListener();
  38. EventAgent.AddEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. int itemID = (int)(viewData as object[])[0];
  44. object[] sourceDatas = (viewData as object[])[1] as object[];
  45. itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
  46. UpdateBase();
  47. UpdateScore();
  48. UpdateSourec(sourceDatas);
  49. }
  50. protected override void OnHide()
  51. {
  52. if (approachView != null)
  53. {
  54. approachView.OnHide();
  55. }
  56. base.OnHide();
  57. }
  58. protected override void RemoveEventListener()
  59. {
  60. base.RemoveEventListener();
  61. EventAgent.RemoveEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  62. }
  63. private void UpdateBase()
  64. {
  65. _ui.m_comTipsBase.m_txtName.text = itemCfg.name;
  66. _ui.m_comTipsBase.m_txtOwned.SetVar("count", "" + ItemDataManager.GetItemNum(itemCfg.id)).FlushVars();
  67. _ui.m_comTipsBase.m_txtDesc.text = string.IsNullOrEmpty(itemCfg.desc) ? "暂无描述" : itemCfg.desc;
  68. _ui.m_comTipsBase.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  69. RarityIconController.UpdateRarityIcon(_ui.m_comTipsBase.m_loaRarity, itemCfg.id, false);
  70. }
  71. private void UpdateScore()
  72. {
  73. bool isDressUp = itemCfg.itemType == ConstItemType.DRESS_UP;
  74. _ui.m_comTipsBase.m_loaRarity.visible = isDressUp;
  75. _ui.m_comTipsBase.m_grpScore.visible = isDressUp;
  76. if (!isDressUp) return;
  77. _ui.m_comTipsBase.m_txtGong.text = "" + itemCfg.score1;
  78. _ui.m_comTipsBase.m_txtShang.text = "" + itemCfg.score2;
  79. _ui.m_comTipsBase.m_txtJue.text = "" + itemCfg.score3;
  80. _ui.m_comTipsBase.m_txtZhi.text = "" + itemCfg.score4;
  81. }
  82. private void UpdateSourec(object[] sourceDatas)
  83. {
  84. _ui.m_comTipsApproach.target.visible = sourceDatas != null;
  85. if (sourceDatas == null) return;
  86. if (approachView == null)
  87. {
  88. approachView = new ApproachView();
  89. }
  90. approachView.OnShow(_ui.m_comTipsApproach.target, sourceDatas);
  91. }
  92. }
  93. }