OpenServerStoryView.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.OpenServerActivity;
  4. using UI.CommonGame;
  5. using System.Collections.Generic;
  6. namespace GFGGame
  7. {
  8. public class OpenServerStoryView : BaseWindow
  9. {
  10. private UI_OpenServerStoryUI _ui;
  11. private Dictionary<int,List<StoryLevelCfg>> _storyLevelCfgs = new Dictionary<int, List<StoryLevelCfg>>();
  12. private int _activityId;
  13. private int _activityType;
  14. private ActivityOpenCfg _activityCfg;
  15. public override void Dispose()
  16. {
  17. if (_ui != null)
  18. {
  19. _ui.Dispose();
  20. _ui = null;
  21. }
  22. base.Dispose();
  23. }
  24. protected override void Init()
  25. {
  26. base.Init();
  27. }
  28. protected override void OnInit()
  29. {
  30. base.OnInit();
  31. packageName = UI_OpenServerStoryUI.PACKAGE_NAME;
  32. _ui = UI_OpenServerStoryUI.Create();
  33. viewCom = _ui.target;
  34. isfullScreen = true;
  35. isReturnView = true;
  36. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  37. _ui.m_list.itemRenderer = RenderListItem;
  38. }
  39. protected override void AddEventListener()
  40. {
  41. base.AddEventListener();
  42. }
  43. protected override void OnShown()
  44. {
  45. base.OnShown();
  46. _activityType = (int)this.viewData;
  47. StudioDataManager.Instance.VIEW_NAME = typeof(OpenServerStoryView).FullName;
  48. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _activityType;
  49. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_sdcy_gq");
  50. _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(_activityType);
  51. _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
  52. _storyLevelCfgs.Clear();
  53. _ui.m_list.numItems = _activityCfg.params4Arr.Length;
  54. }
  55. protected override void OnHide()
  56. {
  57. base.OnHide();
  58. }
  59. protected override void RemoveEventListener()
  60. {
  61. base.RemoveEventListener();
  62. }
  63. private void OnClickBtnBack()
  64. {
  65. ViewManager.GoBackFrom(typeof(OpenServerStoryView).FullName);
  66. }
  67. private void RenderListItem(int index, GObject obj)
  68. {
  69. UI_StoryItem item = UI_StoryItem.Proxy(obj);
  70. var activityStoryCfg = ActivityStoryCfgArray.Instance.GetCfg(_activityCfg.params4Arr[index]);
  71. item.m_posType.selectedIndex = index % 2;
  72. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1][0].id))
  73. item.m_storyImageType.selectedIndex = 0;
  74. else
  75. item.m_storyImageType.selectedIndex = index+1;
  76. var storyLevelCfg = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(activityStoryCfg.type, activityStoryCfg.subType, _activityCfg.params4Arr[index]);
  77. _storyLevelCfgs.Add(index, storyLevelCfg);
  78. if (item.target.data == null)
  79. item.target.onClick.Add(OnClickBtnPlay);
  80. item.target.data = index;
  81. UI_StoryItem.ProxyEnd();
  82. }
  83. private void OnClickBtnPlay(EventContext context)
  84. {
  85. GObject obj = context.sender as GObject;
  86. int index = (int)obj.data;
  87. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index][0];
  88. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1][0].id))
  89. {
  90. PromptController.Instance.ShowFloatTextPrompt("Ðèͨ¹ØÇ°Öùؿ¨");
  91. return;
  92. }
  93. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  94. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStudioStoryLevel);
  95. }
  96. }
  97. }