GoodsItemTipsView.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using FairyGUI;
  2. using UI.CommonGame;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using cfg.GfgCfg;
  6. namespace GFGGame
  7. {
  8. public class GoodsItemTipsView : BaseWindow
  9. {
  10. private UI_GoodsItemTips _ui;
  11. // private ItemView itemView;
  12. private ApproachView approachView;
  13. private ItemCfg itemCfg;
  14. public override void Dispose()
  15. {
  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. base.Dispose();
  28. }
  29. protected override void OnInit()
  30. {
  31. base.OnInit();
  32. _ui = UI_GoodsItemTips.Create();
  33. this.viewCom = _ui.target;
  34. this.viewCom.Center();
  35. this.modal = true;
  36. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  37. approachView = new ApproachView();
  38. approachView.OnInit(_ui.m_comTipsApproach.target);
  39. _ui.m_comTipsBase.m_listTag.itemRenderer = RenderListTagItem;
  40. _ui.m_comTipsBase.m_comScaleList.m_listItem.itemRenderer = ListItemRenderer;
  41. _ui.m_comBg.m_btnClose.onClick.Add(Hide);
  42. }
  43. protected override void AddEventListener()
  44. {
  45. base.AddEventListener();
  46. EventAgent.AddEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  47. }
  48. protected override void OnShown()
  49. {
  50. base.OnShown();
  51. //防止引导检测之前触发点击事件
  52. GRoot.inst.touchable = false;
  53. int itemID = (int)(viewData as object[])[0];
  54. object[] sourceDatas = (viewData as object[])[1] as object[];
  55. itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemID);
  56. UpdateBase();
  57. UpdateScore();
  58. UpdateTags();
  59. UpdateItems();
  60. UpdateSourec(sourceDatas);
  61. // this.viewCom.height = _ui.m_grpTips.height;
  62. // this.viewCom.Center();
  63. Timers.inst.AddUpdate(CheckGuide);
  64. }
  65. protected override void OnHide()
  66. {
  67. GRoot.inst.touchable = true;
  68. if (approachView != null)
  69. {
  70. approachView.OnHide();
  71. }
  72. Timers.inst.Remove(CheckGuide);
  73. base.OnHide();
  74. }
  75. protected override void RemoveEventListener()
  76. {
  77. base.RemoveEventListener();
  78. EventAgent.RemoveEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  79. }
  80. private void UpdateBase()
  81. {
  82. if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
  83. {
  84. _ui.m_comBg.m_txtTitle.text = string.Format("{0} _{1}", itemCfg.Name, itemCfg.Id);
  85. }
  86. else
  87. {
  88. _ui.m_comBg.m_txtTitle.text = itemCfg.Name;
  89. }
  90. _ui.m_comTipsBase.m_txtOwned.SetVar("count", "" + ItemDataManager.GetItemNum(itemCfg.Id)).FlushVars();
  91. _ui.m_comTipsBase.m_txtDesc.text = string.IsNullOrEmpty(itemCfg.Desc) ? "暂无描述" : itemCfg.Desc;
  92. _ui.m_comTipsBase.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  93. _ui.m_comTipsBase.m_txtType.visible = itemCfg.ItemType == ConstItemType.DRESS_UP;
  94. if (itemCfg.ItemType == ConstItemType.DRESS_UP)
  95. {
  96. _ui.m_comTipsBase.m_txtType.text = CommonDataManager.Tables.TblItemTypeCfg.GetOrDefault(itemCfg.SubType).Name;
  97. }
  98. if ((viewData as object[]).Length >= 2)
  99. {
  100. _ui.m_comTipsBase.m_unlock.visible = !(bool)(viewData as object[])[2];
  101. }
  102. RarityIconController.UpdateRarityIcon(_ui.m_comTipsBase.m_loaRarity, itemCfg.Id, false);
  103. ET.Log.Debug(itemCfg.Name + " itemId:" + itemCfg.Id);
  104. }
  105. private void UpdateScore()
  106. {
  107. bool isDressUpOrCard = itemCfg.ItemType == ConstItemType.DRESS_UP || itemCfg.ItemType == ConstItemType.CARD;
  108. _ui.m_comTipsBase.m_loaRarity.visible = isDressUpOrCard;
  109. _ui.m_comTipsBase.m_grpScore.visible = isDressUpOrCard;
  110. if (!isDressUpOrCard) return;
  111. if (ItemDataManager.dataDicOfItemid(itemCfg.Id))
  112. {
  113. _ui.m_comTipsBase.m_txtGong.text = ItemDataManager.GetItemAdditionScore(itemCfg.Id, (int)ConstItemAttributeType.FENG).ToString();
  114. _ui.m_comTipsBase.m_txtShang.text = ItemDataManager.GetItemAdditionScore(itemCfg.Id, (int)ConstItemAttributeType.HUA).ToString();
  115. _ui.m_comTipsBase.m_txtJue.text = ItemDataManager.GetItemAdditionScore(itemCfg.Id, (int)ConstItemAttributeType.XUE).ToString();
  116. _ui.m_comTipsBase.m_txtZhi.text = ItemDataManager.GetItemAdditionScore(itemCfg.Id, (int)ConstItemAttributeType.YUE).ToString();
  117. }
  118. else {
  119. _ui.m_comTipsBase.m_txtGong.text = "" + itemCfg.Score1;
  120. _ui.m_comTipsBase.m_txtShang.text = "" + itemCfg.Score2;
  121. _ui.m_comTipsBase.m_txtJue.text = "" + itemCfg.Score3;
  122. _ui.m_comTipsBase.m_txtZhi.text = "" + itemCfg.Score4;
  123. }
  124. }
  125. private void UpdateTags()
  126. {
  127. _ui.m_comTipsBase.m_listTag.visible = itemCfg.Tags.Count > 0;
  128. _ui.m_comTipsBase.m_listTag.numItems = itemCfg.Tags.Count;
  129. }
  130. private void RenderListTagItem(int index, GObject obj)
  131. {
  132. UI_ListTagItem item = UI_ListTagItem.Proxy(obj);
  133. ItemUtil.UpdateTag(item.m_comTag.target, itemCfg.Tags[index].Name);
  134. item.m_txtTagScore.text = itemCfg.Tags[index].Val.ToString();
  135. UI_ListTagItem.ProxyEnd();
  136. }
  137. private void UpdateItems()
  138. {
  139. _ui.m_comTipsBase.m_grpComScaleList.visible = itemCfg.Items.Count > 0;
  140. _ui.m_comTipsBase.m_comScaleList.m_listItem.visible = itemCfg.Items.Count > 0;
  141. _ui.m_comTipsBase.m_comScaleList.m_listItem.numItems = itemCfg.Items.Count;
  142. }
  143. private void ListItemRenderer(int index, GObject obj)
  144. {
  145. ItemData itemData = ItemUtil.createItemData(itemCfg.Items[index].ToGfgGameItemParam());
  146. if (obj.data == null)
  147. {
  148. obj.data = new ItemView(obj as GComponent);
  149. }
  150. (obj.data as ItemView).SetData(itemData);
  151. (obj.data as ItemView).ChangeTxtCountStyle();
  152. }
  153. private void UpdateSourec(object[] sourceDatas)
  154. {
  155. _ui.m_comTipsApproach.target.visible = sourceDatas != null;
  156. if (sourceDatas == null) return;
  157. approachView.OnShow(sourceDatas);
  158. }
  159. private void CheckGuide(object param)
  160. {
  161. GRoot.inst.touchable = true;
  162. if ((_ui.m_comTipsApproach.m_list.numItems > 0 && (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0) || GuideDataManager.IsGuideFinish(ConstGuideId.CLOTHING_SYNTHETIC) <= 0))
  163. {
  164. UpdateToCheckGuide(null);
  165. }
  166. else
  167. {
  168. Timers.inst.Remove(CheckGuide);
  169. }
  170. }
  171. protected override void UpdateToCheckGuide(object param)
  172. {
  173. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  174. List<string[]> _approachDatas = _ui.m_comTipsApproach.m_list.data as List<string[]>;
  175. if (_approachDatas == null) return;
  176. GComponent obj = null;
  177. for (int i = 0; i < _approachDatas.Count; i++)
  178. {
  179. if (_approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_DIAN || _approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_HE_CHENG)
  180. {
  181. _ui.m_comTipsApproach.m_list.ScrollToView(i);
  182. UI_ListSourceItem item = UI_ListSourceItem.Proxy(_ui.m_comTipsApproach.m_list.GetChildAt(i));
  183. obj = item.m_btnGo.target;
  184. UI_ListSourceItem.ProxyEnd();
  185. break;
  186. }
  187. }
  188. GuideController.TryGuide(obj, ConstGuideId.BUY_CLOTHING, 4, "该物品可以在服装店购买,点开服装店看看。");
  189. GuideController.TryGuide(obj, ConstGuideId.CLOTHING_SYNTHETIC, 2, "该物品可以在绣坊-服装合成哦");
  190. }
  191. }
  192. }