LeagueTeaPartyShowView.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. isReturnView = true;
  32. _ui.m_loaBg.url = ResPathUtil.GetDressUpPath("chahuibg");
  33. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  34. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem1);
  35. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem2);
  36. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem3);
  37. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem4);
  38. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem5);
  39. teaPartyOverItemList.Add(_ui.m_TeaPartyOverItem6);
  40. teapartyRoleCfg = TeapartyRoleCfgArray.Instance.GetCfgsByid(1); //LeagueDataManager.Instance.TeaPartyId
  41. }
  42. protected override void AddEventListener()
  43. {
  44. base.AddEventListener();
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. timeIndex = 3;
  50. _ui.m_txtCountdown.text = string.Format("将在[color=#FF6600]{0}s[/color]后进入下一阶段", timeIndex);
  51. GetRoleContainerInfos();
  52. Timers.inst.Add(1, 3, UpdateTime);
  53. }
  54. protected override void OnHide()
  55. {
  56. base.OnHide();
  57. Timers.inst.Remove(UpdateTime);
  58. }
  59. protected override void RemoveEventListener()
  60. {
  61. base.RemoveEventListener();
  62. }
  63. private async void GetRoleContainerInfos()
  64. {
  65. bool result = await LeagueSproxy.GetRoleContainerInfos(RoleDataManager.roleId);
  66. if (result)
  67. {
  68. var roleContainerList = LeagueDataManager.Instance.RoleContainerList;
  69. for (int index = 0; index < teaPartyOverItemList.Count; index++)
  70. {
  71. teaPartyOverItemList[index].m_txtRoleName.text = teapartyRoleCfg[index].name;
  72. teaPartyOverItemList[index].m_txtGuildName.text = roleContainerList[index].MaxScoreRoleName;
  73. }
  74. }
  75. }
  76. private void OnBtnBackClick()
  77. {
  78. ViewManager.GoBackFrom(typeof(LeagueTeaPartyShowView).FullName);
  79. }
  80. private void openNextView()
  81. {
  82. var openCfg = TeapartyOpenCfgArray.Instance.GetCfg(LeagueDataManager.Instance.TeaPartyId);
  83. string stroyStartID = openCfg.storyId.ToString();
  84. ViewManager.Show<StoryDialogView>(new object[] { stroyStartID, false, new OnCompleteStoryDialogCall(OnCompletePriorStoryDialog), null, true }, null, true);
  85. }
  86. private static void OnCompletePriorStoryDialog(bool isSkip, object param)
  87. {
  88. ViewManager.Show<LeagueTeaPartyOverView>(null, new object[] { typeof(LeagueView).FullName, null });
  89. }
  90. private void UpdateTime(object param)
  91. {
  92. timeIndex -= 1;
  93. _ui.m_txtCountdown.text = string.Format("将在[color=#FF6600]{0}s[/color]后进入下一阶段", timeIndex);
  94. if (timeIndex <= 0) {
  95. openNextView();
  96. Timers.inst.Remove(UpdateTime);
  97. }
  98. }
  99. }
  100. }