ApproachOfItemView.cs 13 KB

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