OpenServerFightView.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. }
  41. protected override void AddEventListener()
  42. {
  43. base.AddEventListener();
  44. }
  45. protected override void OnShown()
  46. {
  47. base.OnShown();
  48. _activityType = (int)this.viewData;
  49. StudioDataManager.Instance.VIEW_NAME = typeof(OpenServerFightView).FullName;
  50. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _activityType;
  51. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_sdcy_gq");
  52. _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(_activityType);
  53. _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
  54. _activityFightCfg = ActivityFightCfgArray.Instance.GetCfg(_activityCfg.params3Arr[0]);
  55. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_activityFightCfg.type, _activityFightCfg.subType, _activityCfg.params3Arr[0]);
  56. _ui.m_list.numItems = _storyLevelCfgs.Count;
  57. UpdateItem();
  58. }
  59. protected override void OnHide()
  60. {
  61. base.OnHide();
  62. }
  63. protected override void RemoveEventListener()
  64. {
  65. base.RemoveEventListener();
  66. }
  67. private void OnClickBtnBack()
  68. {
  69. ViewManager.GoBackFrom(typeof(OpenServerFightView).FullName);
  70. }
  71. private void RenderListItem(int index, GObject obj)
  72. {
  73. // int _index = _storyLevelCfgs.Count - index - 1;
  74. UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
  75. //item.m_c1.selectedIndex = index % 2 == 0 ? 0 : 1;
  76. item.m_txtName.text = _storyLevelCfgs[index].name;
  77. bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID);
  78. string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2";
  79. //item.m_loaBg.url = string.Format("ui://Studio/{0}", resBg);
  80. if (isFight)
  81. {
  82. //item.m_loaBg.url = "ui://Studio/cyjd_di_1";
  83. item.m_loaIcon.visible = false;
  84. item.m_loaItem.visible = true;
  85. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  86. int itemId = storyFightCfg.bonusBaseArr[0][0];
  87. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  88. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  89. if (item.m_loaItem.data == null)
  90. {
  91. item.m_loaItem.onClick.Add(OnLoaItemClick);
  92. }
  93. item.m_loaItem.data = index;
  94. }
  95. else
  96. {
  97. //item.m_loaBg.url = "ui://Studio/cyjd_di_2";
  98. item.m_loaItem.visible = false;
  99. item.m_loaIcon.visible = true;
  100. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _activityFightCfg.res);
  101. }
  102. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  103. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  104. if (item.m_loaBg.data == null)
  105. {
  106. item.m_loaBg.onClick.Add(OnListItemClick);
  107. }
  108. item.m_loaBg.data = index;
  109. UI_ListLevelItem.ProxyEnd();
  110. }
  111. private void OnListItemClick(EventContext context)
  112. {
  113. GObject obj = context.sender as GObject;
  114. int index = (int)obj.data;
  115. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  116. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  117. {
  118. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  119. return;
  120. }
  121. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  122. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStudioStoryLevel);
  123. }
  124. private void OnLoaItemClick(EventContext context)
  125. {
  126. GObject obj = context.sender as GObject;
  127. int index = (int)obj.data;
  128. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  129. int itemId = storyFightCfg.bonusBaseArr[0][0];
  130. GoodsItemTipsController.ShowItemTips(itemId);
  131. }
  132. private void UpdateItem()
  133. {
  134. for (int i = 0; i < _ui.m_list.numChildren; i++)
  135. {
  136. _ui.m_list.GetChildAt(i).visible = false;
  137. }
  138. itemIndex = 0;
  139. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  140. }
  141. private void AddItemUpdate(object param)
  142. {
  143. _ui.m_list.GetChildAt(itemIndex).visible = true;
  144. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(itemIndex));
  145. item.m_Left.Play();
  146. itemIndex++;
  147. UI_ListLevelItem.ProxyEnd();
  148. }
  149. }
  150. }