OpenServerFightView.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.OpenServerActivity;
  4. using UI.CommonGame;
  5. using System.Collections.Generic;
  6. using cfg.GfgCfg;
  7. namespace GFGGame
  8. {
  9. public class OpenServerFightView : BaseWindow
  10. {
  11. private UI_OpenServerFightUI _ui;
  12. private int itemIndex = 0;
  13. private List<StoryLevelCfg> _storyLevelCfgs;
  14. private ActivityFightCfg _activityFightCfg;
  15. private int _activityId;
  16. private int _activityType;
  17. private ActivityOpenCfg _activityCfg;
  18. public override void Dispose()
  19. {
  20. if (_ui != null)
  21. {
  22. _ui.Dispose();
  23. _ui = null;
  24. }
  25. base.Dispose();
  26. }
  27. protected override void Init()
  28. {
  29. base.Init();
  30. }
  31. protected override void OnInit()
  32. {
  33. base.OnInit();
  34. packageName = UI_OpenServerFightUI.PACKAGE_NAME;
  35. _ui = UI_OpenServerFightUI.Create();
  36. this.viewCom = _ui.target;
  37. isfullScreen = true;
  38. isReturnView = true;
  39. _ui.m_list.itemRenderer = RenderListItem;
  40. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  41. _ui.m_iconSuidAdd.onClick.Add(OnClickIconSuidAdd);
  42. }
  43. protected override void OnShown()
  44. {
  45. base.OnShown();
  46. _activityType = (int)this.viewData;
  47. StudioDataManager.Instance.VIEW_NAME = typeof(OpenServerFightView).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 = CommonDataManager.Tables.TblActivityOpenCfg.GetOrDefault(_activityId);
  52. _activityFightCfg = CommonDataManager.Tables.TblActivityFightCfg.GetOrDefault(_activityCfg.Params1[0]);
  53. _storyLevelCfgs = StoryLevelConfigManager.GetConfigs(_activityFightCfg.Type, _activityFightCfg.SubType, _activityCfg.Params3[0]);
  54. _ui.m_list.numItems = _storyLevelCfgs.Count;
  55. UpdateItem();
  56. RefreshTxtFreeNum();
  57. _ui.m_txtTitle.SetVar("name", _activityCfg.ThemeName).FlushVars();
  58. }
  59. private void RefreshTxtFreeNum()
  60. {
  61. RoleLimitData limitData = RoleLimitDataManager.GetLimitData(_activityFightCfg.Limit);
  62. int time = limitData.TotalPlayMax - limitData.PlayTimes;
  63. _ui.m_txtFreeNum.text = time + "/" + limitData.TotalPlayMax;
  64. }
  65. protected override void OnHide()
  66. {
  67. base.OnHide();
  68. }
  69. protected override void AddEventListener()
  70. {
  71. base.AddEventListener();
  72. EventAgent.AddEventListener(ConstMessage.FIGHT_QUICKLY, RefreshTxtFreeNum);
  73. }
  74. protected override void RemoveEventListener()
  75. {
  76. base.RemoveEventListener();
  77. EventAgent.RemoveEventListener(ConstMessage.FIGHT_QUICKLY, RefreshTxtFreeNum);
  78. }
  79. private void OnClickBtnBack()
  80. {
  81. ViewManager.GoBackFrom(typeof(OpenServerFightView).FullName);
  82. }
  83. private void OnClickIconSuidAdd()
  84. {
  85. ViewManager.Show<OpenServerSuitAdditionView>(new object[] { ConstLimitTimeActivityType.ActLimitStlyc, _storyLevelCfgs[0].Id });
  86. }
  87. private void RenderListItem(int index, GObject obj)
  88. {
  89. UI_OpenSererFightItem item = UI_OpenSererFightItem.Proxy(obj);
  90. item.m_txtName.text = _storyLevelCfgs[index].Name;
  91. item.m_loaIcon.visible = false;
  92. item.m_loaItem.visible = true;
  93. StoryFightCfg storyFightCfg = CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(_storyLevelCfgs[index].FightID));
  94. int itemId = storyFightCfg.BonusBase[0].ItemId;
  95. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemId);
  96. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  97. if (item.m_loaItem.data == null)
  98. {
  99. item.m_loaItem.onClick.Add(OnLoaItemClick);
  100. }
  101. item.m_loaItem.data = index;
  102. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].Id);
  103. if (!item.m_grpLock.visible)
  104. item.m_comFirstPass.visible = !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index].Id);
  105. else
  106. item.m_comFirstPass.visible = false;
  107. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].Id);
  108. if (item.m_loaBg.data == null)
  109. {
  110. item.m_loaBg.onClick.Add(OnListItemClick);
  111. }
  112. item.m_loaBg.data = index;
  113. UI_OpenSererFightItem.ProxyEnd();
  114. }
  115. private void OnListItemClick(EventContext context)
  116. {
  117. GObject obj = context.sender as GObject;
  118. int index = (int)obj.data;
  119. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  120. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].Id))
  121. {
  122. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  123. return;
  124. }
  125. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.Id;
  126. InstanceZonesController.ShowLevelView(storyLevelCfg.Id, StudioDataManager.Instance.OnFinishStudioStoryLevel);
  127. }
  128. private void OnLoaItemClick(EventContext context)
  129. {
  130. GObject obj = context.sender as GObject;
  131. int index = (int)obj.data;
  132. StoryFightCfg storyFightCfg = CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(_storyLevelCfgs[index].FightID));
  133. int itemId = storyFightCfg.BonusBase[0].ItemId;
  134. GoodsItemTipsController.ShowItemTips(itemId);
  135. }
  136. private void UpdateItem()
  137. {
  138. for (int i = 0; i < _ui.m_list.numChildren; i++)
  139. {
  140. _ui.m_list.GetChildAt(i).visible = false;
  141. }
  142. itemIndex = 0;
  143. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  144. }
  145. private void AddItemUpdate(object param)
  146. {
  147. _ui.m_list.GetChildAt(itemIndex).visible = true;
  148. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(itemIndex));
  149. item.m_Left.Play();
  150. itemIndex++;
  151. UI_ListLevelItem.ProxyEnd();
  152. }
  153. }
  154. }