ApproachOfItemView.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using UI.CommonGame;
  2. using System.Collections.Generic;
  3. using FairyGUI;
  4. namespace GFGGame
  5. {
  6. /// <summary>
  7. /// 获取途径
  8. /// </summary>
  9. public class ApproachOfItemView : BaseWindow
  10. {
  11. private UI_ApproachOfItemUI _ui;
  12. private List<string[]> _approachDatas;
  13. private int _itemId;
  14. private object[] _fromeViewDatas;
  15. protected override void OnInit()
  16. {
  17. base.OnInit();
  18. _ui = UI_ApproachOfItemUI.Create();
  19. this.viewCom = _ui.target;
  20. this.viewCom.Center();
  21. this.modal = true;
  22. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  23. _ui.m_listApproach.itemRenderer = ListApproachItemRenderer;
  24. _ui.m_listApproach.onClickItem.Add(OnClickListApproachItem);
  25. }
  26. protected override void OnShown()
  27. {
  28. base.OnShown();
  29. object[] temp = viewData as object[];
  30. _itemId = (int)temp[0];
  31. _fromeViewDatas = temp[1] as object[];
  32. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
  33. _ui.m_txtName.text = itemCfg.name;
  34. _ui.m_listApproach.RemoveChildrenToPool();
  35. if (itemCfg.approach.Length > 0)
  36. {
  37. _ui.m_txtNone.visible = false;
  38. string[] approachStrs = itemCfg.approach.Split(';');
  39. _approachDatas = new List<string[]>();
  40. foreach (string approachStr in approachStrs)
  41. {
  42. if (approachStr.Length > 0)
  43. {
  44. string[] infos = approachStr.Split('=');
  45. _approachDatas.Add(infos);
  46. }
  47. }
  48. _ui.m_listApproach.numItems = _approachDatas.Count;
  49. _ui.m_listApproach.ResizeToFit();
  50. }
  51. else
  52. {
  53. _ui.m_txtNone.visible = true;
  54. _ui.m_listApproach.height = 162;
  55. }
  56. GuideController.TryGuideApproachOfItemViewList(_ui.m_listApproach);
  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. string[] values = value.Split('_');
  73. int chapterInt = int.Parse(values[0]);
  74. int levelInt = int.Parse(values[1]);
  75. string chapter = NumberUtil.GetChiniseNumberText(chapterInt);
  76. string level = NumberUtil.GetChiniseNumberText(levelInt);
  77. listItem.target.text = string.Format(gameFunctionCfg.name, chapter, level);
  78. }
  79. else
  80. {
  81. listItem.target.text = gameFunctionCfg.name;
  82. }
  83. listItem.target.data = infos;
  84. }
  85. private void OnClickListApproachItem(EventContext context)
  86. {
  87. GuideController.HideGuide();
  88. GObject listItem = context.data as GObject;
  89. string[] infos = listItem.data as string[];
  90. string functionId = infos[0];
  91. switch (functionId)
  92. {
  93. case ConstFunctionId.FU_ZHUANG_DIAN:
  94. this.Hide();
  95. ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { null, null, _itemId }, null, false, true);
  96. break;
  97. case ConstFunctionId.JU_QING_GUAN_QIA:
  98. string value = infos[1];
  99. string[] values = value.Split('_');
  100. int chapterInt = int.Parse(values[0]);
  101. int levelInt = int.Parse(values[1]);
  102. if ((string)_fromeViewDatas[0] == ViewName.DRESS_UP_FIGHT_VIEW)
  103. {
  104. //从战斗换装必需品来源跳转到剧情界面,在剧情界面点返回后直接返回章节界面,无需返回换装界面
  105. _fromeViewDatas = null;
  106. }
  107. ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, chapterInt, _fromeViewDatas, true);
  108. StoryController.ShowLevelView(chapterInt, levelInt);
  109. break;
  110. case ConstFunctionId.FU_ZHUANG_HE_CHENG:
  111. int suitId = SuitCfgManager.Instance.GetItemSuitId(_itemId);
  112. if (suitId > 0)
  113. {
  114. this.Hide();
  115. ViewManager.Show(ViewName.CLOTHING_SYNTHETIC_VIEW, suitId);
  116. }
  117. break;
  118. case ConstFunctionId.ZHAI_XING:
  119. this.Hide();
  120. ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, _fromeViewDatas);
  121. break;
  122. case ConstFunctionId.TAO_ZHUANG_TU_JIAN:
  123. this.Hide();
  124. ViewManager.Show(ViewName.SUIT_GUIDE_VIEW);
  125. break;
  126. case ConstFunctionId.TAO_ZHUANG_HE_CHENG:
  127. this.Hide();
  128. ViewManager.Show(ViewName.SUIT_SYNTHETIC_LIST_VIEW);
  129. break;
  130. }
  131. }
  132. }
  133. }