GoodsItemTipsView.cs 8.3 KB

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