ApproachOfItemView.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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 if (functionId == ConstFunctionId.FU_ZHUANG_DIAN)
  95. {
  96. int shopId = int.Parse(infos[1]);
  97. if (shopId == ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID)
  98. {
  99. listItem.target.text = "活动商店";
  100. }
  101. else if (shopId == ConstStoreId.LUCKY_BOX_STORE_ID)
  102. {
  103. listItem.target.text = "落星商店";
  104. }
  105. else
  106. {
  107. listItem.target.text = "服装店";
  108. }
  109. }
  110. else
  111. {
  112. listItem.target.text = gameFunctionCfg.name;
  113. }
  114. listItem.target.data = infos;
  115. }
  116. private void OnClickListApproachItem(EventContext context)
  117. {
  118. GObject listItem = context.data as GObject;
  119. string[] infos = listItem.data as string[];
  120. string functionId = infos[0];
  121. bool isJump = true;
  122. switch (functionId)
  123. {
  124. case ConstFunctionId.FU_ZHUANG_DIAN:
  125. this.Hide();
  126. object[] temp = viewData as object[];
  127. int count = temp.Length > 2 ? (int)temp[2] : 0;
  128. int shopId = int.Parse(infos[1]);
  129. if (shopId == ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID)
  130. {
  131. PromptController.Instance.ShowFloatTextPrompt("活动暂未开启");
  132. break;
  133. }
  134. isJump = ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { shopId, null, _itemId, count }, _fromeViewDatas, true, true);
  135. break;
  136. case ConstFunctionId.FU_ZHUANG_DECOMPOSE:
  137. this.Hide();
  138. isJump = ViewManager.Show<ClothingDecomposeView>(null, _fromeViewDatas);
  139. break;
  140. case ConstFunctionId.SHOP_GIFT_BAG:
  141. this.Hide();
  142. int giftBagValue = int.Parse(infos[1]);
  143. isJump = ViewManager.Show<RechargeStoreView>(giftBagValue, _fromeViewDatas);
  144. break;
  145. case ConstFunctionId.SHOP_EXCHANGE:
  146. this.Hide();
  147. int exchangeValue = int.Parse(infos[1]);
  148. isJump = ViewManager.Show<RechargeStoreView>(exchangeValue, _fromeViewDatas);
  149. break;
  150. case ConstFunctionId.JU_QING_GUAN_QIA:
  151. string value = infos[1];
  152. var levelCfgId = int.Parse(value);
  153. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  154. isJump = false;
  155. if (levelCfg.type == ConstInstanceZonesType.Story)
  156. {
  157. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(ViewName.STORY_CHAPTER_VIEW))
  158. {
  159. break;
  160. }
  161. if (!MainStoryDataManager.CheckLevelUnlock(levelCfgId))
  162. {
  163. PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
  164. break;
  165. }
  166. if ((string)_fromeViewDatas[0] == ViewName.DRESS_UP_FIGHT_VIEW)
  167. {
  168. //从战斗换装必需品来源跳转到剧情界面,在剧情界面点返回后直接返回章节界面,无需返回换装界面
  169. _fromeViewDatas = null;
  170. }
  171. isJump = ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, levelCfg.chapterId, _fromeViewDatas, true);
  172. InstanceZonesController.ShowLevelView(levelCfgId, StudioDataManager.Instance.OnFinishStoryLevel);
  173. }
  174. else if (levelCfg.type == ConstInstanceZonesType.Studio)
  175. {
  176. StudioCfg studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  177. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(studioCfg.funId))
  178. {
  179. break;
  180. }
  181. //TO DO
  182. List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgs(studioCfg.type, studioCfg.subType, studioCfg.id);
  183. StudioDataManager.Instance.IsCanFight(levelCfg.id, out bool canFight, out string content);
  184. if (!canFight)
  185. {
  186. PromptController.Instance.ShowFloatTextPrompt("关卡未开启");
  187. break;
  188. }
  189. this.Hide();
  190. if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  191. {
  192. PromptController.Instance.ShowFloatTextPrompt("不在活动周期内");
  193. break;
  194. }
  195. int type = studioCfg.funId == typeof(StudioPropertyView).Name ? 1 : 0;
  196. StudioDataManager.Instance.TYPE_SELECT_INDEX = type;
  197. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = 0;
  198. if (studioCfg.funId == typeof(StudioPropertyView).Name)
  199. {
  200. List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgs(typeof(StudioPropertyView).Name);
  201. for (int i = 0; i < studioCfgs.Count; i++)
  202. {
  203. if (studioCfgs[i].id == studioCfg.id)
  204. {
  205. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = i;
  206. break;
  207. }
  208. }
  209. }
  210. string viewName = "GFGGame." + studioCfg.funId;
  211. ViewManager.Show(viewName, new object[] { type, 0 }, _fromeViewDatas);
  212. StudioDataManager.Instance.VIEW_NAME = studioCfg.funId; ;
  213. InstanceZonesController.ShowLevelView(levelCfgId, StudioDataManager.Instance.OnFinishStoryLevel);
  214. isJump = true;
  215. break;
  216. }
  217. isJump = true;
  218. StoryController.ShowLevelView(levelCfgId);
  219. // StoryController.ShowLevelView(levelCfgId);
  220. break;
  221. case ConstFunctionId.FU_ZHUANG_HE_CHENG:
  222. isJump = false;
  223. int suitId = SuitCfgManager.Instance.GetItemSuitId(_itemId);
  224. if (suitId > 0)
  225. {
  226. this.Hide();
  227. isJump = ViewManager.Show(ViewName.CLOTHING_SYNTHETIC_VIEW, new object[] { suitId, _itemId }, _fromeViewDatas);
  228. }
  229. break;
  230. case ConstFunctionId.ZHAI_XING:
  231. this.Hide();
  232. isJump = ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, _fromeViewDatas, true);
  233. break;
  234. case ConstFunctionId.TAO_ZHUANG_TU_JIAN:
  235. isJump = false;
  236. if (ViewManager.isViewOpen(ViewName.SUIT_GUIDE_VIEW))
  237. {
  238. this.Hide();
  239. return;
  240. }
  241. this.Hide();
  242. isJump = ViewManager.Show(ViewName.SUIT_GUIDE_VIEW, null, _fromeViewDatas);
  243. break;
  244. case ConstFunctionId.TAO_ZHUANG_HE_CHENG:
  245. this.Hide();
  246. isJump = ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW);
  247. break;
  248. case ConstFunctionId.SUIT_FOSTER:
  249. this.Hide();
  250. isJump = ViewManager.Show<SuitListView>(null, _fromeViewDatas);
  251. break;
  252. }
  253. if (isJump)
  254. {
  255. EventAgent.DispatchEvent(ConstMessage.JUMP_TO_SOURCE);
  256. }
  257. }
  258. protected override void UpdateToCheckGuide(object param)
  259. {
  260. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  261. if (_approachDatas == null) return;
  262. int index = 0;
  263. for (int i = 0; i < _approachDatas.Count; i++)
  264. {
  265. if (_approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_DIAN)
  266. {
  267. index = i;
  268. break;
  269. }
  270. }
  271. GuideController.TryGuide(_ui.m_listApproach, ConstGuideId.BUY_CLOTHING, 4, "该物品可以在服装店购买,点开服装店看看", index, true, (int)(this.viewCom.y + this.viewCom.height + 10));
  272. }
  273. }
  274. }