ApproachOfItemView.cs 13 KB

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