ApproachOfItemView.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using UI.CommonGame;
  2. using System.Collections.Generic;
  3. using FairyGUI;
  4. namespace GFGGame
  5. {
  6. /// <summary>
  7. /// 获取途径
  8. /// </summary>
  9. public class ApproachOfItemView : BaseWindow
  10. {
  11. private UI_ApproachOfItemUI _ui;
  12. private List<string[]> _approachDatas;
  13. private int _itemId;
  14. private object[] _fromeViewDatas;
  15. protected override void OnInit()
  16. {
  17. base.OnInit();
  18. _ui = UI_ApproachOfItemUI.Create();
  19. this.viewCom = _ui.target;
  20. this.viewCom.Center();
  21. this.modal = true;
  22. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  23. _ui.m_listApproach.itemRenderer = ListApproachItemRenderer;
  24. _ui.m_listApproach.onClickItem.Add(OnClickListApproachItem);
  25. }
  26. protected override void OnShown()
  27. {
  28. base.OnShown();
  29. object[] temp = viewData as object[];
  30. _itemId = (int)temp[0];
  31. _fromeViewDatas = temp[1] as object[];
  32. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
  33. _ui.m_txtName.text = itemCfg.name;
  34. _ui.m_listApproach.RemoveChildrenToPool();
  35. if (itemCfg.approach.Length > 0)
  36. {
  37. _ui.m_txtNone.visible = false;
  38. string[] approachStrs = itemCfg.approach.Split(';');
  39. _approachDatas = new List<string[]>();
  40. foreach (string approachStr in approachStrs)
  41. {
  42. if (approachStr.Length > 0)
  43. {
  44. string[] infos = approachStr.Split('=');
  45. _approachDatas.Add(infos);
  46. }
  47. }
  48. _ui.m_listApproach.numItems = _approachDatas.Count;
  49. // _ui.m_listApproach.ResizeToFit();
  50. }
  51. else
  52. {
  53. _ui.m_txtNone.visible = true;
  54. // _ui.m_listApproach.height = 162;
  55. }
  56. }
  57. protected override void OnHide()
  58. {
  59. base.OnHide();
  60. _fromeViewDatas = null;
  61. }
  62. private void ListApproachItemRenderer(int index, GObject item)
  63. {
  64. UI_ButtonApproach listItem = UI_ButtonApproach.Proxy(item);
  65. string[] infos = _approachDatas[index];
  66. string functionId = infos[0];
  67. GameFunctionCfg gameFunctionCfg = GameFunctionCfgArray.Instance.GetCfg(functionId);
  68. if (functionId == ConstFunctionId.JU_QING_GUAN_QIA)
  69. {
  70. string value = infos[1];
  71. var levelCfgId = int.Parse(value);
  72. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  73. if (levelCfg.type == ConstInstanceZonesType.Story)
  74. {
  75. var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(levelCfg.chapterId);
  76. string chapter = NumberUtil.GetChiniseNumberText(chapterCfg.order);
  77. string level = NumberUtil.GetChiniseNumberText(levelCfg.order);
  78. listItem.target.text = string.Format(gameFunctionCfg.name, chapter, level);
  79. }
  80. else if (levelCfg.type == ConstInstanceZonesType.Studio)
  81. {
  82. var studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  83. listItem.target.text = studioCfg.name;
  84. }
  85. }
  86. else
  87. {
  88. listItem.target.text = gameFunctionCfg.name;
  89. }
  90. listItem.target.data = infos;
  91. }
  92. private void OnClickListApproachItem(EventContext context)
  93. {
  94. GObject listItem = context.data as GObject;
  95. string[] infos = listItem.data as string[];
  96. string functionId = infos[0];
  97. switch (functionId)
  98. {
  99. case ConstFunctionId.FU_ZHUANG_DIAN:
  100. this.Hide();
  101. object[] temp = viewData as object[];
  102. int count = temp.Length > 2 ? (int)temp[2] : 1;
  103. ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { null, null, _itemId, count }, _fromeViewDatas, true, true);
  104. break;
  105. case ConstFunctionId.JU_QING_GUAN_QIA:
  106. string value = infos[1];
  107. var levelCfgId = int.Parse(value);
  108. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  109. if (!MainStoryDataManager.CheckLevelUnlock(levelCfgId))
  110. {
  111. PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
  112. break;
  113. }
  114. if (levelCfg.type == ConstInstanceZonesType.Story)
  115. {
  116. if ((string)_fromeViewDatas[0] == ViewName.DRESS_UP_FIGHT_VIEW)
  117. {
  118. //从战斗换装必需品来源跳转到剧情界面,在剧情界面点返回后直接返回章节界面,无需返回换装界面
  119. _fromeViewDatas = null;
  120. }
  121. ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, levelCfg.chapterId, _fromeViewDatas, true);
  122. }
  123. else if (levelCfg.type == ConstInstanceZonesType.Studio)
  124. {
  125. //TO DO
  126. }
  127. StoryController.ShowLevelView(levelCfgId);
  128. break;
  129. case ConstFunctionId.FU_ZHUANG_HE_CHENG:
  130. int suitId = SuitCfgManager.Instance.GetItemSuitId(_itemId);
  131. if (suitId > 0)
  132. {
  133. this.Hide();
  134. ViewManager.Show(ViewName.CLOTHING_SYNTHETIC_VIEW, new object[] { suitId, _itemId }, _fromeViewDatas);
  135. }
  136. break;
  137. case ConstFunctionId.ZHAI_XING:
  138. this.Hide();
  139. ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, _fromeViewDatas);
  140. break;
  141. case ConstFunctionId.TAO_ZHUANG_TU_JIAN:
  142. if (ViewManager.isViewOpen(ViewName.SUIT_GUIDE_VIEW))
  143. {
  144. this.Hide();
  145. return;
  146. }
  147. this.Hide();
  148. ViewManager.Show(ViewName.SUIT_GUIDE_VIEW, null, _fromeViewDatas);
  149. break;
  150. case ConstFunctionId.TAO_ZHUANG_HE_CHENG:
  151. this.Hide();
  152. ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW);
  153. break;
  154. }
  155. }
  156. protected override void UpdateToCheckGuide(object param)
  157. {
  158. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  159. if (_approachDatas == null) return;
  160. int index = 0;
  161. for (int i = 0; i < _approachDatas.Count; i++)
  162. {
  163. if (_approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_DIAN)
  164. {
  165. index = i;
  166. break;
  167. }
  168. }
  169. GuideController.TryGuide(_ui.m_listApproach, ConstGuideId.BUY_CLOTHING, 2, "该物品可以在服装店购买,点开服装店看看", index, true, (int)(this.viewCom.y + this.viewCom.height + 10));
  170. }
  171. }
  172. }