ApproachView.cs 18 KB

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