GoodsItemTipsView.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  36. approachView = new ApproachView();
  37. approachView.OnInit(_ui.m_comTipsApproach.target);
  38. _ui.m_comTipsBase.m_listTag.itemRenderer = RenderListTagItem;
  39. _ui.m_comTipsBase.m_comScaleList.m_listItem.itemRenderer = ListItemRenderer;
  40. _ui.m_comBg.m_btnClose.onClick.Add(Hide);
  41. }
  42. protected override void AddEventListener()
  43. {
  44. base.AddEventListener();
  45. EventAgent.AddEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  46. }
  47. protected override void OnShown()
  48. {
  49. base.OnShown();
  50. int itemID = (int)(viewData as object[])[0];
  51. object[] sourceDatas = (viewData as object[])[1] as object[];
  52. itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
  53. UpdateBase();
  54. UpdateScore();
  55. UpdateTags();
  56. UpdateItems();
  57. UpdateSourec(sourceDatas);
  58. // this.viewCom.height = _ui.m_grpTips.height;
  59. // this.viewCom.Center();
  60. Timers.inst.AddUpdate(CheckGuide);
  61. }
  62. protected override void OnHide()
  63. {
  64. if (approachView != null)
  65. {
  66. approachView.OnHide();
  67. }
  68. Timers.inst.Remove(CheckGuide);
  69. base.OnHide();
  70. }
  71. protected override void RemoveEventListener()
  72. {
  73. base.RemoveEventListener();
  74. EventAgent.RemoveEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  75. }
  76. private void UpdateBase()
  77. {
  78. if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
  79. {
  80. _ui.m_comBg.m_txtTitle.text = string.Format("{0} _{1}", itemCfg.name, itemCfg.id);
  81. }
  82. else
  83. {
  84. _ui.m_comBg.m_txtTitle.text = itemCfg.name;
  85. }
  86. _ui.m_comTipsBase.m_txtOwned.SetVar("count", "" + ItemDataManager.GetItemNum(itemCfg.id)).FlushVars();
  87. _ui.m_comTipsBase.m_txtDesc.text = string.IsNullOrEmpty(itemCfg.desc) ? "暂无描述" : itemCfg.desc;
  88. _ui.m_comTipsBase.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  89. _ui.m_comTipsBase.m_txtType.visible = itemCfg.itemType == ConstItemType.DRESS_UP;
  90. if (itemCfg.itemType == ConstItemType.DRESS_UP)
  91. {
  92. _ui.m_comTipsBase.m_txtType.text = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).name;
  93. }
  94. if ((viewData as object[]).Length >= 2)
  95. {
  96. _ui.m_comTipsBase.m_unlock.visible = !(bool)(viewData as object[])[2];
  97. }
  98. RarityIconController.UpdateRarityIcon(_ui.m_comTipsBase.m_loaRarity, itemCfg.id, false);
  99. ET.Log.Debug(itemCfg.name + " itemId:" + itemCfg.id);
  100. }
  101. private void UpdateScore()
  102. {
  103. bool isDressUpOrCard = itemCfg.itemType == ConstItemType.DRESS_UP || itemCfg.itemType == ConstItemType.CARD;
  104. _ui.m_comTipsBase.m_loaRarity.visible = isDressUpOrCard;
  105. _ui.m_comTipsBase.m_grpScore.visible = isDressUpOrCard;
  106. if (!isDressUpOrCard) return;
  107. _ui.m_comTipsBase.m_txtGong.text = "" + itemCfg.score1;
  108. _ui.m_comTipsBase.m_txtShang.text = "" + itemCfg.score2;
  109. _ui.m_comTipsBase.m_txtJue.text = "" + itemCfg.score3;
  110. _ui.m_comTipsBase.m_txtZhi.text = "" + itemCfg.score4;
  111. }
  112. private void UpdateTags()
  113. {
  114. _ui.m_comTipsBase.m_listTag.visible = itemCfg.tagsArr.Length > 0;
  115. _ui.m_comTipsBase.m_listTag.numItems = itemCfg.tagsArr.Length;
  116. }
  117. private void RenderListTagItem(int index, GObject obj)
  118. {
  119. UI_ListTagItem item = UI_ListTagItem.Proxy(obj);
  120. ItemUtil.UpdateTag(item.m_comTag.target, itemCfg.tagsArr[index][0]);
  121. item.m_txtTagScore.text = itemCfg.tagsArr[index][1].ToString();
  122. UI_ListTagItem.ProxyEnd();
  123. }
  124. private void UpdateItems()
  125. {
  126. _ui.m_comTipsBase.m_grpComScaleList.visible = itemCfg.itemsArr.Length > 0;
  127. _ui.m_comTipsBase.m_comScaleList.m_listItem.visible = itemCfg.itemsArr.Length > 0;
  128. _ui.m_comTipsBase.m_comScaleList.m_listItem.numItems = itemCfg.itemsArr.Length;
  129. }
  130. private void ListItemRenderer(int index, GObject obj)
  131. {
  132. ItemData itemData = ItemUtil.createItemData(itemCfg.itemsArr[index]);
  133. if (obj.data == null)
  134. {
  135. obj.data = new ItemView(obj as GComponent);
  136. }
  137. (obj.data as ItemView).SetData(itemData);
  138. (obj.data as ItemView).ChangeTxtCountStyle();
  139. }
  140. private void UpdateSourec(object[] sourceDatas)
  141. {
  142. _ui.m_comTipsApproach.target.visible = sourceDatas != null;
  143. if (sourceDatas == null) return;
  144. approachView.OnShow(sourceDatas);
  145. }
  146. private void CheckGuide(object param)
  147. {
  148. if (_ui.m_comTipsApproach.m_list.numItems > 0 && GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0)
  149. {
  150. UpdateToCheckGuide(null);
  151. }
  152. else
  153. {
  154. Timers.inst.Remove(CheckGuide);
  155. }
  156. }
  157. protected override void UpdateToCheckGuide(object param)
  158. {
  159. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  160. List<string[]> _approachDatas = _ui.m_comTipsApproach.m_list.data as List<string[]>;
  161. if (_approachDatas == null) return;
  162. GComponent obj = null;
  163. for (int i = 0; i < _approachDatas.Count; i++)
  164. {
  165. if (_approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_DIAN)
  166. {
  167. _ui.m_comTipsApproach.m_list.ScrollToView(i);
  168. UI_ListSourceItem item = UI_ListSourceItem.Proxy(_ui.m_comTipsApproach.m_list.GetChildAt(i));
  169. obj = item.m_btnGo.target;
  170. UI_ListSourceItem.ProxyEnd();
  171. break;
  172. }
  173. }
  174. GuideController.TryGuide(obj, ConstGuideId.BUY_CLOTHING, 4, "该物品可以在服装店购买,点开服装店看看。");
  175. }
  176. }
  177. }