LeagueTeaPartyShowView.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using ET;
  2. using FairyGUI;
  3. using Hutool;
  4. using System.Collections.Generic;
  5. using UI.League;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class LeagueTeaPartyShowView : BaseWindow
  10. {
  11. private UI_LeagueTeaPartyShowUI _ui;
  12. private List<UI_comTeaPartyOverItem> teaPartyOverItemList = new List<UI_comTeaPartyOverItem>();
  13. private List<TeapartyRoleCfg> teapartyRoleCfg;
  14. private int timeIndex = 3; //定时器时间计算
  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 OnInit()
  25. {
  26. base.OnInit();
  27. packageName = UI_LeagueTeaPartyShowUI.PACKAGE_NAME;
  28. _ui = UI_LeagueTeaPartyShowUI.Create();
  29. this.viewCom = _ui.target;
  30. isfullScreen = true;
  31. _ui.m_loaBg.url = ResPathUtil.GetDressUpPath("chahuibg");
  32. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  33. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem1);
  34. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem2);
  35. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem3);
  36. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem4);
  37. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem5);
  38. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem6);
  39. teapartyRoleCfg = TeapartyRoleCfgArray.Instance.GetCfgsByid(1); //LeagueDataManager.Instance.TeaPartyId
  40. }
  41. protected override void AddEventListener()
  42. {
  43. base.AddEventListener();
  44. }
  45. protected override void OnShown()
  46. {
  47. base.OnShown();
  48. timeIndex = 3;
  49. GetRoleContainerInfos();
  50. Timers.inst.Add(1, 3, UpdateTime);
  51. }
  52. protected override void OnHide()
  53. {
  54. base.OnHide();
  55. Timers.inst.Remove(UpdateTime);
  56. }
  57. protected override void RemoveEventListener()
  58. {
  59. base.RemoveEventListener();
  60. }
  61. private async void GetRoleContainerInfos()
  62. {
  63. bool result = await LeagueSproxy.GetRoleContainerInfos(RoleDataManager.roleId);
  64. if (result)
  65. {
  66. var roleContainerList = LeagueDataManager.Instance.RoleContainerList;
  67. for (int index = 0; index < teaPartyOverItemList.Count; index++)
  68. {
  69. teaPartyOverItemList[index].m_txtRoleName.text = teapartyRoleCfg[index].name;
  70. teaPartyOverItemList[index].m_txtGuildName.text = roleContainerList[index].MaxScoreRoleName;
  71. }
  72. }
  73. }
  74. private void OnBtnBackClick()
  75. {
  76. ViewManager.GoBackFrom(typeof(LeagueView).FullName);
  77. }
  78. private void openNextView()
  79. {
  80. if (LeagueDataManager.Instance.RoleContainerList.Count > 0)
  81. {
  82. string stroyStartID = "50001";
  83. ViewManager.Show<StoryDialogView>(new object[] { stroyStartID, false, new OnCompleteStoryDialogCall(OnCompletePriorStoryDialog), null, true }, null, true);
  84. }
  85. else
  86. ViewManager.Show<LeagueTeaPartyOverView>();
  87. }
  88. private static void OnCompletePriorStoryDialog(bool isSkip, object param)
  89. {
  90. ViewManager.Show<LeagueTeaPartyOverView>();
  91. }
  92. private void UpdateTime(object param)
  93. {
  94. timeIndex -= 1;
  95. _ui.m_txtCountdown.text = string.Format("将在{0}s后进入下一阶段", timeIndex);
  96. if (timeIndex <= 0) {
  97. openNextView();
  98. Timers.inst.Remove(UpdateTime);
  99. }
  100. }
  101. }
  102. }