ApproachOfItemView.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. if (levelCfg.subType == ConstInstanceZonesSubType.Normal)
  80. {
  81. listItem.target.text = string.Format(gameFunctionCfg.name, chapter, level);
  82. }
  83. else if (levelCfg.subType == ConstInstanceZonesSubType.Hard)
  84. {
  85. listItem.target.text = string.Format("精英" + gameFunctionCfg.name, chapter, level);
  86. }
  87. }
  88. else if (levelCfg.type == ConstInstanceZonesType.Studio)
  89. {
  90. var studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  91. listItem.target.text = levelCfg.name;
  92. }
  93. }
  94. else
  95. {
  96. listItem.target.text = gameFunctionCfg.name;
  97. }
  98. listItem.target.data = infos;
  99. }
  100. private void OnClickListApproachItem(EventContext context)
  101. {
  102. GObject listItem = context.data as GObject;
  103. string[] infos = listItem.data as string[];
  104. string functionId = infos[0];
  105. switch (functionId)
  106. {
  107. case ConstFunctionId.FU_ZHUANG_DIAN:
  108. this.Hide();
  109. object[] temp = viewData as object[];
  110. int count = temp.Length > 2 ? (int)temp[2] : 1;
  111. ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { null, null, _itemId, count }, _fromeViewDatas, true, true);
  112. break;
  113. case ConstFunctionId.FU_ZHUANG_DECOMPOSE:
  114. this.Hide();
  115. ViewManager.Show<ClothingDecomposeView>(null, _fromeViewDatas);
  116. break;
  117. case ConstFunctionId.JU_QING_GUAN_QIA:
  118. string value = infos[1];
  119. var levelCfgId = int.Parse(value);
  120. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  121. if (levelCfg.type == ConstInstanceZonesType.Story)
  122. {
  123. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(ViewName.STORY_CHAPTER_VIEW))
  124. {
  125. break;
  126. }
  127. if (!MainStoryDataManager.CheckLevelUnlock(levelCfgId))
  128. {
  129. PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
  130. break;
  131. }
  132. if ((string)_fromeViewDatas[0] == ViewName.DRESS_UP_FIGHT_VIEW)
  133. {
  134. //从战斗换装必需品来源跳转到剧情界面,在剧情界面点返回后直接返回章节界面,无需返回换装界面
  135. _fromeViewDatas = null;
  136. }
  137. ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, levelCfg.chapterId, _fromeViewDatas, true);
  138. }
  139. else if (levelCfg.type == ConstInstanceZonesType.Studio)
  140. {
  141. StudioCfg studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  142. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(studioCfg.funId))
  143. {
  144. break;
  145. }
  146. //TO DO
  147. List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgs(studioCfg.type, studioCfg.subType, studioCfg.id);
  148. StudioDataManager.Instance.IsCanFight(levelCfg.id, out bool canFight, out string content);
  149. if (!canFight)
  150. {
  151. PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
  152. break;
  153. }
  154. this.Hide();
  155. if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  156. {
  157. PromptController.Instance.ShowFloatTextPrompt("不在活动周期内");
  158. break;
  159. }
  160. int type = studioCfg.funId == typeof(StudioPropertyView).Name ? 1 : 0;
  161. string viewName = "GFGGame." + studioCfg.funId;
  162. ViewManager.Show(viewName, new object[] { type, 0 }, _fromeViewDatas);
  163. }
  164. StoryController.ShowLevelView(levelCfgId);
  165. break;
  166. case ConstFunctionId.FU_ZHUANG_HE_CHENG:
  167. int suitId = SuitCfgManager.Instance.GetItemSuitId(_itemId);
  168. if (suitId > 0)
  169. {
  170. this.Hide();
  171. ViewManager.Show(ViewName.CLOTHING_SYNTHETIC_VIEW, new object[] { suitId, _itemId }, _fromeViewDatas);
  172. }
  173. break;
  174. case ConstFunctionId.ZHAI_XING:
  175. this.Hide();
  176. ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, _fromeViewDatas);
  177. break;
  178. case ConstFunctionId.TAO_ZHUANG_TU_JIAN:
  179. if (ViewManager.isViewOpen(ViewName.SUIT_GUIDE_VIEW))
  180. {
  181. this.Hide();
  182. return;
  183. }
  184. this.Hide();
  185. ViewManager.Show(ViewName.SUIT_GUIDE_VIEW, null, _fromeViewDatas);
  186. break;
  187. case ConstFunctionId.TAO_ZHUANG_HE_CHENG:
  188. this.Hide();
  189. ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW);
  190. break;
  191. }
  192. }
  193. protected override void UpdateToCheckGuide(object param)
  194. {
  195. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  196. if (_approachDatas == null) return;
  197. int index = 0;
  198. for (int i = 0; i < _approachDatas.Count; i++)
  199. {
  200. if (_approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_DIAN)
  201. {
  202. index = i;
  203. break;
  204. }
  205. }
  206. GuideController.TryGuide(_ui.m_listApproach, ConstGuideId.BUY_CLOTHING, 4, "该物品可以在服装店购买,点开服装店看看", index, true, (int)(this.viewCom.y + this.viewCom.height + 10));
  207. }
  208. }
  209. }