MatchingCompetitionSelectView.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.MatchingCompetition;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. class MatchingCompetitionSelectView : BaseWindow
  10. {
  11. private UI_MatchingCompetitionSelectUI _ui;
  12. private int _seasonIndex = 0;
  13. private bool isRefresh = false;
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. }
  20. _ui = null;
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_MatchingCompetitionSelectUI.PACKAGE_NAME;
  27. _ui = UI_MatchingCompetitionSelectUI.Create();
  28. this.viewCom = _ui.target;
  29. isReturnView = true;
  30. isfullScreen = true;
  31. _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
  32. _ui.m_select1.target.onClick.Add(OnClickBtnSelect1);
  33. _ui.m_select2.target.onClick.Add(OnClickBtnSelect2);
  34. _ui.m_ruleBtn.onClick.Add(MatchingCompetitionDataManager.Instance.OnClickBtnRule);
  35. }
  36. protected override void OnShown()
  37. {
  38. base.OnShown();
  39. _ui.m_bg.url = ResPathUtil.GetBgImgPath("gzs_fb_bj");
  40. _ui.m_BtnBack.touchable = true;
  41. _ui.m_titleText.text = JudgingRoundOpenCfgArray.Instance.dataArray[MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason - 1].Name;
  42. //isRefresh = (bool)this.viewData;
  43. UpdateView();
  44. UpdatePlayer();
  45. }
  46. protected override void OnHide()
  47. {
  48. base.OnHide();
  49. }
  50. protected override void AddEventListener()
  51. {
  52. base.AddEventListener();
  53. EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdatePlayer);
  54. }
  55. protected override void RemoveEventListener()
  56. {
  57. base.RemoveEventListener();
  58. EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdatePlayer);
  59. }
  60. private void UpdatePlayer()
  61. {
  62. _ui.m_playerShow1.m_playerImage.m_playerImage.texture = MatchingTwoDataManager.Instance.LeftRoleInfo.Ntexture;
  63. _ui.m_playerShow2.m_playerImage.m_playerImage.texture = MatchingTwoDataManager.Instance.RightRoleInfo.Ntexture;
  64. MatchingPhotoWorksData otherLeftdata = MatchingTwoDataManager.Instance.LeftRoleInfo;
  65. JudgingRoundRoleInfo otherLeftInfo = otherLeftdata.JudgingInfo;
  66. RoleInfoManager.Instance.UpdateHead(_ui.m_player1.m_head, otherLeftInfo.HeadItemId, otherLeftInfo.HeadBorderItemId);
  67. _ui.m_player1.m_nameText.text = otherLeftInfo.RoleName.ToString();
  68. _ui.m_select1.m_numText.visible = false;
  69. _ui.m_select1.m_numText.text = otherLeftInfo.Score.ToString();
  70. MatchingPhotoWorksData otherRightdata = MatchingTwoDataManager.Instance.RightRoleInfo;
  71. JudgingRoundRoleInfo otherRightInfo = otherRightdata.JudgingInfo;
  72. RoleInfoManager.Instance.UpdateHead(_ui.m_player2.m_head, otherRightInfo.HeadItemId, otherRightInfo.HeadBorderItemId);
  73. _ui.m_player2.m_nameText.text = otherRightInfo.RoleName.ToString();
  74. _ui.m_select2.m_numText.visible = false;
  75. _ui.m_select2.m_numText.text = otherRightInfo.Score.ToString();
  76. }
  77. private void UpdateView()
  78. {
  79. _ui.m_selectText1.alpha = 0;
  80. _ui.m_selectText2.alpha = 0;
  81. _ui.m_timeText.text = string.Format("剩余次数:{0}", MatchingCompetitionDataManager.Instance.MatchingRemainingTimes);
  82. }
  83. private void OnClickBtnBack()
  84. {
  85. _ui.m_BtnBack.touchable = true;
  86. ViewManager.GoBackFrom(typeof(MatchingCompetitionSelectView).FullName);
  87. }
  88. private async void OnClickBtnSelect1()
  89. {
  90. if(MatchingCompetitionDataManager.Instance.MatchingRemainingTimes<=0)
  91. {
  92. PromptController.Instance.ShowFloatTextPrompt("评选次数不足");
  93. return;
  94. }
  95. bool result = await MatchingCompetitionSproxy.ReqCheckMatchingCompetitionWork(
  96. MatchingTwoDataManager.Instance.LeftRoleInfo.JudgingInfo.WorksId,MatchingTwoDataManager.Instance.RightRoleInfo.JudgingInfo.WorksId
  97. ) ;
  98. if(result)
  99. {
  100. _ui.m_select1.m_c1.selectedIndex = 1;
  101. _ui.m_select1.m_numText.visible = true;
  102. _ui.m_select2.m_numText.visible = true;
  103. _ui.m_select1.m_numText.text = string.Format("心动值{0}", MatchingTwoDataManager.Instance.LeftRoleInfo.JudgingInfo.Score.ToString());
  104. _ui.m_timeText.text = string.Format("剩余次数:{0}", MatchingCompetitionDataManager.Instance.MatchingRemainingTimes);
  105. }
  106. _ui.m_t0.Play(async () =>
  107. {
  108. bool resulst = await MatchingCompetitionSproxy.ReqGetTwoPlayers();
  109. if (resulst)
  110. {
  111. UpdateView();
  112. UpdatePlayer();
  113. }
  114. });
  115. }
  116. private async void OnClickBtnSelect2()
  117. {
  118. if (MatchingCompetitionDataManager.Instance.MatchingRemainingTimes <= 0)
  119. {
  120. PromptController.Instance.ShowFloatTextPrompt("评选次数不足");
  121. return;
  122. }
  123. bool result = await MatchingCompetitionSproxy.ReqCheckMatchingCompetitionWork(
  124. MatchingTwoDataManager.Instance.RightRoleInfo.JudgingInfo.WorksId, MatchingTwoDataManager.Instance.LeftRoleInfo.JudgingInfo.WorksId
  125. );
  126. if (result)
  127. {
  128. _ui.m_select2.m_c1.selectedIndex = 1;
  129. _ui.m_select1.m_numText.visible = true;
  130. _ui.m_select2.m_numText.visible = true;
  131. _ui.m_select2.m_numText.text = string.Format("心动值{0}", MatchingTwoDataManager.Instance.RightRoleInfo.JudgingInfo.Score.ToString());
  132. _ui.m_timeText.text = string.Format("剩余次数:{0}", MatchingCompetitionDataManager.Instance.MatchingRemainingTimes);
  133. }
  134. _ui.m_t1.Play(async () =>
  135. {
  136. bool resulst = await MatchingCompetitionSproxy.ReqGetTwoPlayers();
  137. if (resulst)
  138. {
  139. UpdateView();
  140. UpdatePlayer();
  141. }
  142. });
  143. }
  144. }
  145. }