ApproachView.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. using System.Collections.Generic;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. namespace GFGGame
  5. {
  6. public class ApproachView
  7. {
  8. private UI_ComTipsApproach _ui;
  9. private object[] _viewData;
  10. private int _itemId;
  11. private object[] _fromeViewDatas;
  12. private int _needCount;//需求总量
  13. private List<string[]> _approachDatas = new List<string[]>();
  14. public void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. _ui = null;
  20. }
  21. UI_ComTipsApproach.ProxyEnd();
  22. }
  23. public void OnHide()
  24. {
  25. // _ui.m_list.onClickItem.Remove(OnClickListApproachItem);
  26. if (_ui.m_list.numItems > 0)
  27. {
  28. _ui.m_list.ScrollToView(0);
  29. _ui.m_list.numItems = 0;
  30. }
  31. _approachDatas.Clear();
  32. _fromeViewDatas = null;
  33. }
  34. public void OnInit(GComponent component)
  35. {
  36. _ui = UI_ComTipsApproach.Proxy(component);
  37. _ui.m_list.itemRenderer = ListApproachItemRenderer;
  38. }
  39. public void OnShow(object[] viewData)
  40. {
  41. _viewData = viewData;
  42. _itemId = (int)viewData[0];
  43. _fromeViewDatas = viewData[1] as object[];
  44. // _needCount = viewData.Length > 2 ? (int)viewData[2] : 0;
  45. int needCount = viewData.Length > 2 ? (int)viewData[2] : 0;
  46. _needCount = (int)needCount;
  47. SetData();
  48. UpdateView();
  49. }
  50. private void SetData()
  51. {
  52. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
  53. if (string.IsNullOrEmpty(itemCfg.approach)) return;
  54. string[] approachStrs = itemCfg.approach.Split(';');
  55. foreach (string approachStr in approachStrs)
  56. {
  57. if (string.IsNullOrEmpty(approachStr)) continue;
  58. string[] infos = approachStr.Split('=');
  59. _approachDatas.Add(infos);
  60. }
  61. }
  62. private void UpdateView()
  63. {
  64. _ui.m_txtNone.visible = _approachDatas.Count == 0;
  65. _ui.m_list.numItems = _approachDatas.Count;
  66. _ui.m_list.data = _approachDatas;
  67. }
  68. private void ListApproachItemRenderer(int index, GObject item)
  69. {
  70. UI_ListSourceItem listItem = UI_ListSourceItem.Proxy(item);
  71. string[] infos = _approachDatas[index];
  72. string functionId = infos[0];
  73. GameFunctionCfg gameFunctionCfg = GameFunctionCfgArray.Instance.GetCfg(functionId);
  74. // FunctionOpenCfg functionOpenCfg = FunctionOpenCfgArray.Instance.GetCfg(gameFunctionCfg.functionId);
  75. // listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(functionOpenCfg.res);
  76. if (functionId == ConstFunctionId.JU_QING_GUAN_QIA)
  77. {
  78. var levelCfgId = int.Parse(infos[1]);
  79. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  80. if (levelCfg.type == ConstInstanceZonesType.Story)
  81. {
  82. var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(levelCfg.chapterId);
  83. string chapter = NumberUtil.GetChiniseNumberText(chapterCfg.order);
  84. string level = NumberUtil.GetChiniseNumberText(levelCfg.order);
  85. if (levelCfg.subType == ConstInstanceZonesSubType.Normal)
  86. {
  87. listItem.m_txtSourceName.text = string.Format(gameFunctionCfg.name, chapter, level);
  88. }
  89. else if (levelCfg.subType == ConstInstanceZonesSubType.Hard)
  90. {
  91. listItem.m_txtSourceName.text = string.Format("精英" + gameFunctionCfg.name, chapter, level);
  92. }
  93. }
  94. else if (levelCfg.type == ConstInstanceZonesType.Studio)
  95. {
  96. var studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  97. listItem.m_txtSourceName.text = levelCfg.name;
  98. }
  99. }
  100. else if (functionId == ConstFunctionId.FU_ZHUANG_DIAN)
  101. {
  102. int shopId = int.Parse(infos[1]);
  103. if (shopId == ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID)
  104. {
  105. listItem.m_txtSourceName.text = "活动商店";
  106. }
  107. else if (shopId == ConstStoreId.LUCKY_BOX_STORE_ID)
  108. {
  109. listItem.m_txtSourceName.text = "落星商店";
  110. }
  111. else if (shopId == ConstStoreId.GALLERY_STORE_ID)
  112. {
  113. listItem.m_txtSourceName.text = "画廊商店";
  114. }
  115. else
  116. {
  117. listItem.m_txtSourceName.text = "服装店";
  118. }
  119. }
  120. else if (functionId == ConstFunctionId.STORE)
  121. {
  122. int storeTabId = int.Parse(infos[1]);
  123. int storeSubId = int.Parse(infos[2]);
  124. listItem.m_txtSourceName.text = StoreTabCfgArray.Instance.GetCfg(storeTabId).subTabArr[storeSubId][0];
  125. }
  126. else
  127. {
  128. listItem.m_txtSourceName.text = gameFunctionCfg.name;
  129. }
  130. if (listItem.target.data == null)
  131. {
  132. listItem.m_btnGo.target.onClick.Add(OnClickListApproachItem);
  133. }
  134. listItem.m_btnGo.target.data = infos;
  135. UI_ListSourceItem.ProxyEnd();
  136. }
  137. private void OnClickListApproachItem(EventContext context)
  138. {
  139. GObject btnGo = context.sender as GObject;
  140. string[] infos = btnGo.data as string[];
  141. string functionId = infos[0];
  142. long hasNum = ItemDataManager.GetItemNum(_itemId);
  143. long needCount = 0;
  144. bool isJump = true;
  145. switch (functionId)
  146. {
  147. case ConstFunctionId.FU_ZHUANG_DIAN:
  148. // this.Hide();
  149. needCount = (_needCount - hasNum) <= 0 ? 1 : _needCount - hasNum;
  150. int shopId = int.Parse(infos[1]);
  151. // if (shopId == ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID)
  152. // {
  153. // PromptController.Instance.ShowFloatTextPrompt("活动暂未开启");
  154. // isJump = false;
  155. // break;
  156. // }
  157. isJump = ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { shopId, null, _itemId, needCount }, _fromeViewDatas, true, true);
  158. break;
  159. case ConstFunctionId.FU_ZHUANG_DECOMPOSE:
  160. // this.Hide();
  161. isJump = ViewManager.Show<ClothingDecomposeView>(null, _fromeViewDatas);
  162. break;
  163. case ConstFunctionId.STORE:
  164. int storeTabId = int.Parse(infos[1]);
  165. int storeSubId = int.Parse(infos[2]);
  166. isJump = ViewManager.Show<StoreView>(new object[] { storeTabId, storeSubId });
  167. break;
  168. // case ConstFunctionId.SHOP_GIFT_BAG:
  169. // // this.Hide();
  170. // int giftBagValue = int.Parse(infos[1]);
  171. // isJump = ViewManager.Show<StoreView>(new object[] { ConstFunctionId.STORE_CHARGE, giftBagValue }, _fromeViewDatas);
  172. // break;
  173. // case ConstFunctionId.SHOP_EXCHANGE:
  174. // // this.Hide();
  175. // int exchangeValue = int.Parse(infos[1]);
  176. // isJump = ViewManager.Show<StoreView>(new object[] { ConstFunctionId.STORE_CHARGE, exchangeValue }, _fromeViewDatas);
  177. // break;
  178. case ConstFunctionId.JU_QING_GUAN_QIA:
  179. string value = infos[1];
  180. var levelCfgId = int.Parse(value);
  181. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  182. isJump = false;
  183. if (levelCfg.type == ConstInstanceZonesType.Studio)
  184. {
  185. StudioCfg studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  186. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(studioCfg.funId))
  187. {
  188. break;
  189. }
  190. //TO DO
  191. List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(studioCfg.type, studioCfg.subType, studioCfg.id);
  192. StudioDataManager.Instance.IsCanFight(levelCfg.id, out bool canFight, out string content);
  193. if (!canFight)
  194. {
  195. PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
  196. break;
  197. }
  198. if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  199. {
  200. PromptController.Instance.ShowFloatTextPrompt("不在活动周期内");
  201. break;
  202. }
  203. if (studioCfg.funId == typeof(StudioFilingView).Name)
  204. {
  205. StudioDataManager.Instance.filingChapterId = studioCfg.id;
  206. ViewManager.Show<StudioFilingView>(null, _fromeViewDatas);
  207. MainStoryDataManager.currentLevelCfgId = levelCfg.id;
  208. InstanceZonesController.ShowLevelView(levelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel, _itemId, _needCount);
  209. isJump = true;
  210. }
  211. else
  212. {
  213. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = 0;
  214. if (studioCfg.funId == typeof(StudioPropertyView).Name)
  215. {
  216. List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  217. for (int i = 0; i < studioCfgs.Count; i++)
  218. {
  219. if (studioCfgs[i].id == studioCfg.id)
  220. {
  221. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = i;
  222. break;
  223. }
  224. }
  225. }
  226. string viewName = "GFGGame." + studioCfg.funId;
  227. ViewManager.Show(viewName, StudioDataManager.Instance.PROPERTY_SELECT_INDEX, _fromeViewDatas);
  228. StudioDataManager.Instance.VIEW_NAME = viewName;
  229. InstanceZonesController.ShowLevelView(levelCfgId, StudioDataManager.Instance.OnFinishStudioStoryLevel, _itemId, _needCount);
  230. isJump = true;
  231. }
  232. break;
  233. }
  234. else
  235. {
  236. // if (levelCfg.type == ConstInstanceZonesType.Story)
  237. // {
  238. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(ViewName.STORY_CHAPTER_VIEW))
  239. {
  240. break;
  241. }
  242. if (!MainStoryDataManager.CheckLevelUnlock(levelCfgId))
  243. {
  244. PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
  245. break;
  246. }
  247. if ((string)_fromeViewDatas[0] == ViewName.DRESS_UP_FIGHT_VIEW)
  248. {
  249. //从战斗换装必需品来源跳转到剧情界面,在剧情界面点返回后直接返回章节界面,无需返回换装界面
  250. _fromeViewDatas = null;
  251. }
  252. isJump = ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, levelCfg.chapterId, _fromeViewDatas, true);
  253. StoryController.ShowLevelView(levelCfgId, _itemId, _needCount);
  254. break;
  255. }
  256. case ConstFunctionId.FU_ZHUANG_HE_CHENG:
  257. isJump = false;
  258. int suitId = SuitCfgArray.Instance.GetSuitIdOfItem(_itemId);
  259. if (suitId > 0)
  260. {
  261. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  262. bool isPass = InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId);
  263. if (suitCfg.syntheticStoryLevelId > 0 && !isPass)
  264. {
  265. isJump = ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW, suitId, _fromeViewDatas);
  266. }
  267. else
  268. {
  269. isJump = ViewManager.Show(ViewName.CLOTHING_SYNTHETIC_VIEW, new object[] { suitId, _itemId }, _fromeViewDatas);
  270. }
  271. }
  272. break;
  273. case ConstFunctionId.ZHAI_XING:
  274. // this.Hide();
  275. isJump = ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, _fromeViewDatas, true);
  276. break;
  277. case ConstFunctionId.TAO_ZHUANG_TU_JIAN:
  278. isJump = false;
  279. if (ViewManager.isViewOpen(ViewName.SUIT_GUIDE_VIEW))
  280. {
  281. return;
  282. }
  283. isJump = ViewManager.Show(ViewName.SUIT_GUIDE_VIEW, null, _fromeViewDatas);
  284. break;
  285. case ConstFunctionId.TAO_ZHUANG_HE_CHENG:
  286. isJump = ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW);
  287. break;
  288. case ConstFunctionId.SUIT_FOSTER:
  289. isJump = ViewManager.Show<ClothingListView>(null, _fromeViewDatas);
  290. break;
  291. case ConstFunctionId.DAILY_TASK:
  292. isJump = ViewManager.Show<TaskView>(null, _fromeViewDatas);
  293. break;
  294. case ConstFunctionId.LEAGUE_PRAY:
  295. isJump = ViewManager.Show<LeaguePrayView>(null, _fromeViewDatas);
  296. break;
  297. case ConstFunctionId.LEAGUE_ANSWER:
  298. if (LeagueDataManager.Instance.Type == LeagueJoinType.Join)
  299. {
  300. ViewManager.Show<LeagueView>(null, _fromeViewDatas);
  301. isJump = ViewManager.Show<LeagueAnswerView>();
  302. }
  303. else
  304. {
  305. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(nameof(LeagueView))) return;
  306. PromptController.Instance.ShowFloatTextPrompt("暂未加入雅集");
  307. }
  308. break;
  309. }
  310. if (isJump)
  311. {
  312. EventAgent.DispatchEvent(ConstMessage.JUMP_TO_SOURCE);
  313. }
  314. }
  315. }
  316. }