ApproachOfItemView.cs 9.1 KB

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