OpenServerFightView.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 OpenServerFightView : BaseWindow
  9. {
  10. private UI_OpenServerFightUI _ui;
  11. private int itemIndex = 0;
  12. private List<StoryLevelCfg> _storyLevelCfgs;
  13. private ActivityFightCfg _activityFightCfg;
  14. private int _activityId;
  15. private int _activityType;
  16. private ActivityOpenCfg _activityCfg;
  17. public override void Dispose()
  18. {
  19. if (_ui != null)
  20. {
  21. _ui.Dispose();
  22. _ui = null;
  23. }
  24. base.Dispose();
  25. }
  26. protected override void Init()
  27. {
  28. base.Init();
  29. }
  30. protected override void OnInit()
  31. {
  32. base.OnInit();
  33. packageName = UI_OpenServerFightUI.PACKAGE_NAME;
  34. _ui = UI_OpenServerFightUI.Create();
  35. viewCom = _ui.target;
  36. isfullScreen = true;
  37. isReturnView = true;
  38. _ui.m_list.itemRenderer = RenderListItem;
  39. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  40. _ui.m_iconSuidAdd.onClick.Add(OnClickIconSuidAdd);
  41. }
  42. protected override void AddEventListener()
  43. {
  44. base.AddEventListener();
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. _activityType = (int)this.viewData;
  50. StudioDataManager.Instance.VIEW_NAME = typeof(OpenServerFightView).FullName;
  51. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _activityType;
  52. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_sdcy_gq");
  53. _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(_activityType);
  54. _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
  55. _activityFightCfg = ActivityFightCfgArray.Instance.GetCfg(_activityCfg.params3Arr[0]);
  56. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_activityFightCfg.type, _activityFightCfg.subType, _activityCfg.params3Arr[0]);
  57. _ui.m_list.numItems = _storyLevelCfgs.Count;
  58. UpdateItem();
  59. _ui.m_txtFreeNum.text = "10/11";
  60. }
  61. protected override void OnHide()
  62. {
  63. base.OnHide();
  64. }
  65. protected override void RemoveEventListener()
  66. {
  67. base.RemoveEventListener();
  68. }
  69. private void OnClickBtnBack()
  70. {
  71. ViewManager.GoBackFrom(typeof(OpenServerFightView).FullName);
  72. }
  73. private void OnClickIconSuidAdd()
  74. {
  75. ViewManager.Show<OpenServerSuitAdditionView>(new object[] { ConstLimitTimeActivityType.ActLimitStlyc, _storyLevelCfgs[0].id });
  76. }
  77. private void RenderListItem(int index, GObject obj)
  78. {
  79. UI_OpenSererFightItem item = UI_OpenSererFightItem.Proxy(obj);
  80. item.m_txtName.text = _storyLevelCfgs[index].name;
  81. item.m_loaIcon.visible = false;
  82. item.m_loaItem.visible = true;
  83. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  84. int itemId = storyFightCfg.bonusBaseArr[0][0];
  85. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  86. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  87. if (item.m_loaItem.data == null)
  88. {
  89. item.m_loaItem.onClick.Add(OnLoaItemClick);
  90. }
  91. item.m_loaItem.data = index;
  92. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  93. if (!item.m_grpLock.visible)
  94. item.m_comFirstPass.visible = !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index].id);
  95. else
  96. item.m_comFirstPass.visible = false;
  97. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  98. if (item.m_loaBg.data == null)
  99. {
  100. item.m_loaBg.onClick.Add(OnListItemClick);
  101. }
  102. item.m_loaBg.data = index;
  103. UI_OpenSererFightItem.ProxyEnd();
  104. }
  105. private void OnListItemClick(EventContext context)
  106. {
  107. GObject obj = context.sender as GObject;
  108. int index = (int)obj.data;
  109. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  110. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  111. {
  112. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  113. return;
  114. }
  115. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  116. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStudioStoryLevel);
  117. }
  118. private void OnLoaItemClick(EventContext context)
  119. {
  120. GObject obj = context.sender as GObject;
  121. int index = (int)obj.data;
  122. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  123. int itemId = storyFightCfg.bonusBaseArr[0][0];
  124. GoodsItemTipsController.ShowItemTips(itemId);
  125. }
  126. private void UpdateItem()
  127. {
  128. for (int i = 0; i < _ui.m_list.numChildren; i++)
  129. {
  130. _ui.m_list.GetChildAt(i).visible = false;
  131. }
  132. itemIndex = 0;
  133. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  134. }
  135. private void AddItemUpdate(object param)
  136. {
  137. _ui.m_list.GetChildAt(itemIndex).visible = true;
  138. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(itemIndex));
  139. item.m_Left.Play();
  140. itemIndex++;
  141. UI_ListLevelItem.ProxyEnd();
  142. }
  143. }
  144. }