OpenServerFightView.cs 6.6 KB

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