LeagueTeaPartyView.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 LeagueTeaPartyView : BaseWindow
  10. {
  11. private UI_LeagueTeaPartyUI _ui;
  12. private List<UI_comTeaPartyItem> teaPartyItemList = new List<UI_comTeaPartyItem>();
  13. private List<RoleContainerProto> roleContainerList = new List<RoleContainerProto>();
  14. private List<TeapartyRoleCfg> teapartyRoleCfg;
  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_LeagueTeaPartyUI.PACKAGE_NAME;
  28. _ui = UI_LeagueTeaPartyUI.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. _ui.m_btnChat.onClick.Add(OnBtnChatClick);
  34. _ui.m_btnChallenge.onClick.Add(OnBtnChallengeClick);
  35. _ui.m_btnReward.onClick.Add(OnBtnRewardClick);
  36. _ui.m_teaPartyItemTips.target.onClick.Add(OnTeaPartyItemTipsClick);
  37. _ui.m_btnRule.onClick.Add(RuleController.ShowRuleView);
  38. _ui.m_btnRule.data = 300022;
  39. _ui.m_ListTeaParty.itemRenderer = ListTeaPartyItemRender;
  40. teapartyRoleCfg = TeapartyRoleCfgArray.Instance.GetCfgsByid(1); //LeagueDataManager.Instance.TeaPartyId
  41. }
  42. private void ListTeaPartyItemRender(int index, GObject obj)
  43. {
  44. UI_comTeaPartyItem itemObj = UI_comTeaPartyItem.Proxy(obj);
  45. Vector2 localpos = obj.position;//.LocalToGlobal();
  46. itemObj.m_btnDetail.data = localpos;
  47. itemObj.m_btnDetail.onClick.Add(OnBtnDetailClick);
  48. itemObj.m_iconRole.data = index;
  49. itemObj.m_iconRole.onClick.Add(OnBtnIconRoleClick);
  50. itemObj.m_txtRoleName.text = teapartyRoleCfg[index].name;
  51. //itemObj.m_txtMaxValue.text = roleContainerList[index].MaxScore.ToString();
  52. //itemObj.m_txtNumber.text = roleContainerList[index].PerNum.ToString();
  53. //itemObj.m_txtMaxName.text = roleContainerList[index].MaxScoreROleName.ToString();
  54. UI_comTeaPartyItem.ProxyEnd();
  55. }
  56. protected override void AddEventListener()
  57. {
  58. base.AddEventListener();
  59. }
  60. protected override void OnShown()
  61. {
  62. base.OnShown();
  63. var openCfg = TeapartyOpenCfgArray.Instance.GetCfg(1);//LeagueDataManager.Instance.TeaPartyId
  64. _ui.m_txtTeaName.text = openCfg.name;
  65. _ui.m_teaPartyItemTips.target.visible = false;
  66. int myPos = LeagueDataManager.Instance.GetMyPos();
  67. bool isLeader = myPos == LeaguePos.Owner || myPos == LeaguePos.SubOwner;
  68. _ui.m_btnChallenge.visible = isLeader;
  69. UpDataOverTime();
  70. //GetRoleContainerInfos();
  71. roleContainerList = LeagueDataManager.Instance.RoleContainerList;
  72. _ui.m_ListTeaParty.numItems = 6;
  73. }
  74. private void UpDataOverTime()
  75. {
  76. //_ui.m_txtOverTime.text = "挑战剩余时间:" + TimeUtil.GetTimeLeft(TimeInfo.Instance.ServerNow(), list[0].EndTime);
  77. }
  78. private async void GetRoleContainerInfos()
  79. {
  80. bool result = await LeagueSproxy.GetRoleContainerInfos();
  81. if (result)
  82. {
  83. roleContainerList = LeagueDataManager.Instance.RoleContainerList;
  84. _ui.m_ListTeaParty.numItems = 6;
  85. }
  86. }
  87. protected override void OnHide()
  88. {
  89. base.OnHide();
  90. }
  91. protected override void RemoveEventListener()
  92. {
  93. base.RemoveEventListener();
  94. }
  95. private void OnBtnChatClick()
  96. {
  97. ViewManager.Show<LeagueChatView>();
  98. }
  99. private void OnBtnChallengeClick()
  100. {
  101. string stroyStartID = "50001";
  102. ViewManager.Show<StoryDialogView>(new object[] { stroyStartID, false, new OnCompleteStoryDialogCall(OnCompletePriorStoryDialog),null,true }, null, true);
  103. //ViewManager.Show<LeagueTeaPartyOverView>();
  104. }
  105. private static void OnCompletePriorStoryDialog(bool isSkip, object param)
  106. {
  107. ViewManager.Show<LeagueTeaPartyOverView>();
  108. }
  109. private void OnBtnRewardClick()
  110. {
  111. ViewManager.Show<LeagueTeaPartyRewardView>();
  112. }
  113. private void OnBtnBackClick()
  114. {
  115. ViewManager.GoBackFrom(typeof(LeagueView).FullName);
  116. }
  117. private void OnBtnDetailClick(EventContext context)
  118. {
  119. GObject obj = context.sender as GObject;
  120. var pos = (Vector2)obj.data;
  121. //_ui.m_teaPartyItemTips.m_window.position = pos;
  122. _ui.m_teaPartyItemTips.target.visible = true;
  123. }
  124. private void OnTeaPartyItemTipsClick()
  125. {
  126. _ui.m_teaPartyItemTips.target.visible = false;
  127. }
  128. private void OnBtnIconRoleClick(EventContext context)
  129. {
  130. GObject obj = context.sender as GObject;
  131. LeagueDataManager.Instance.ChooseTeaPartId = (int)obj.data + 1;
  132. DressUpFightType dressUpFightType = new DressUpFightType();
  133. dressUpFightType.levelID = 0;
  134. dressUpFightType.teaPartID = LeagueDataManager.Instance.ChooseTeaPartId;
  135. ViewManager.Show<DressUpFightView>(dressUpFightType, new object[] { typeof(LeagueTeaPartyView).FullName, null }, true);
  136. }
  137. }
  138. }