GoodsItemTipsView.cs 8.3 KB

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