GoodsItemTipsView.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using FairyGUI;
  2. using UI.CommonGame;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. namespace GFGGame
  6. {
  7. public class GoodsItemTipsView : BaseWindow
  8. {
  9. private UI_GoodsItemTips _ui;
  10. // private ItemView itemView;
  11. private ApproachView approachView;
  12. private ItemCfg itemCfg;
  13. public override void Dispose()
  14. {
  15. base.Dispose();
  16. // itemView.Dispose();
  17. if (approachView != null)
  18. {
  19. approachView.Dispose();
  20. approachView = null;
  21. }
  22. if (_ui != null)
  23. {
  24. _ui.Dispose();
  25. _ui = null;
  26. }
  27. }
  28. protected override void OnInit()
  29. {
  30. base.OnInit();
  31. _ui = UI_GoodsItemTips.Create();
  32. this.viewCom = _ui.target;
  33. this.viewCom.Center();
  34. this.modal = true;
  35. approachView = new ApproachView();
  36. approachView.OnInit(_ui.m_comTipsApproach.target);
  37. _ui.m_comTipsBase.m_listTag.itemRenderer = RenderListTagItem;
  38. }
  39. protected override void AddEventListener()
  40. {
  41. base.AddEventListener();
  42. EventAgent.AddEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  43. }
  44. protected override void OnShown()
  45. {
  46. base.OnShown();
  47. int itemID = (int)(viewData as object[])[0];
  48. object[] sourceDatas = (viewData as object[])[1] as object[];
  49. itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
  50. UpdateBase();
  51. UpdateScore();
  52. UpdateTags();
  53. UpdateSourec(sourceDatas);
  54. // this.viewCom.height = _ui.m_grpTips.height;
  55. // this.viewCom.Center();
  56. Timers.inst.AddUpdate(CheckGuide);
  57. }
  58. protected override void OnHide()
  59. {
  60. if (approachView != null)
  61. {
  62. approachView.OnHide();
  63. }
  64. Timers.inst.Remove(CheckGuide);
  65. base.OnHide();
  66. }
  67. protected override void RemoveEventListener()
  68. {
  69. base.RemoveEventListener();
  70. EventAgent.RemoveEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  71. }
  72. private void UpdateBase()
  73. {
  74. if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
  75. {
  76. _ui.m_comTipsBase.m_txtName.text = string.Format("{0} _{1}", itemCfg.name, itemCfg.id);
  77. }
  78. else
  79. {
  80. _ui.m_comTipsBase.m_txtName.text = itemCfg.name;
  81. }
  82. _ui.m_comTipsBase.m_txtOwned.SetVar("count", "" + ItemDataManager.GetItemNum(itemCfg.id)).FlushVars();
  83. _ui.m_comTipsBase.m_txtDesc.text = string.IsNullOrEmpty(itemCfg.desc) ? "暂无描述" : itemCfg.desc;
  84. _ui.m_comTipsBase.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  85. RarityIconController.UpdateRarityIcon(_ui.m_comTipsBase.m_loaRarity, itemCfg.id, false);
  86. ET.Log.Debug(itemCfg.name + " itemId:" + itemCfg.id);
  87. }
  88. private void UpdateScore()
  89. {
  90. bool isDressUp = itemCfg.itemType == ConstItemType.DRESS_UP;
  91. _ui.m_comTipsBase.m_loaRarity.visible = isDressUp;
  92. _ui.m_comTipsBase.m_grpScore.visible = isDressUp;
  93. if (!isDressUp) return;
  94. _ui.m_comTipsBase.m_txtGong.text = "" + itemCfg.score1;
  95. _ui.m_comTipsBase.m_txtShang.text = "" + itemCfg.score2;
  96. _ui.m_comTipsBase.m_txtJue.text = "" + itemCfg.score3;
  97. _ui.m_comTipsBase.m_txtZhi.text = "" + itemCfg.score4;
  98. }
  99. private void UpdateTags()
  100. {
  101. _ui.m_comTipsBase.m_listTag.visible = itemCfg.tagsArr.Length > 0;
  102. _ui.m_comTipsBase.m_listTag.numItems = itemCfg.tagsArr.Length;
  103. }
  104. private void RenderListTagItem(int index, GObject obj)
  105. {
  106. UI_ListTagItem item = UI_ListTagItem.Proxy(obj);
  107. ItemUtil.UpdateTag(item.m_comTag.target, itemCfg.tagsArr[index][0]);
  108. item.m_txtTagScore.text = itemCfg.tagsArr[index][1].ToString();
  109. UI_ListTagItem.ProxyEnd();
  110. }
  111. private void UpdateSourec(object[] sourceDatas)
  112. {
  113. _ui.m_comTipsApproach.target.visible = sourceDatas != null;
  114. if (sourceDatas == null) return;
  115. approachView.OnShow(sourceDatas);
  116. }
  117. private void CheckGuide(object param)
  118. {
  119. if (_ui.m_comTipsApproach.m_list.numItems > 0 && GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0)
  120. {
  121. UpdateToCheckGuide(null);
  122. }
  123. else
  124. {
  125. Timers.inst.Remove(CheckGuide);
  126. }
  127. }
  128. protected override void UpdateToCheckGuide(object param)
  129. {
  130. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  131. List<string[]> _approachDatas = _ui.m_comTipsApproach.m_list.data as List<string[]>;
  132. if (_approachDatas == null) return;
  133. GComponent obj = null;
  134. for (int i = 0; i < _approachDatas.Count; i++)
  135. {
  136. if (_approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_DIAN)
  137. {
  138. _ui.m_comTipsApproach.m_list.ScrollToView(i);
  139. UI_ListSourceItem item = UI_ListSourceItem.Proxy(_ui.m_comTipsApproach.m_list.GetChildAt(i));
  140. obj = item.m_btnGo.target;
  141. UI_ListSourceItem.ProxyEnd();
  142. break;
  143. }
  144. }
  145. GuideController.TryGuide(obj, ConstGuideId.BUY_CLOTHING, 4, "该物品可以在服装店购买,点开服装店看看。");
  146. }
  147. }
  148. }