LeagueTeaPartyShowView.cs 3.8 KB

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