MatchingCompetitionSelectView.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. //isRefresh = (bool)this.viewData;
  42. UpdateView();
  43. UpdatePlayer();
  44. }
  45. protected override void OnHide()
  46. {
  47. base.OnHide();
  48. }
  49. protected override void AddEventListener()
  50. {
  51. base.AddEventListener();
  52. EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdatePlayer);
  53. }
  54. protected override void RemoveEventListener()
  55. {
  56. base.RemoveEventListener();
  57. EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdatePlayer);
  58. }
  59. private void UpdatePlayer()
  60. {
  61. _ui.m_playerShow1.m_playerImage.m_playerImage.texture = MatchingTwoDataManager.Instance.LeftRoleInfo.Ntexture;
  62. _ui.m_playerShow2.m_playerImage.m_playerImage.texture = MatchingTwoDataManager.Instance.RightRoleInfo.Ntexture;
  63. MatchingPhotoWorksData otherLeftdata = MatchingTwoDataManager.Instance.LeftRoleInfo;
  64. JudgingRoundRoleInfo otherLeftInfo = otherLeftdata.JudgingInfo;
  65. RoleInfoManager.Instance.UpdateHead(_ui.m_player1.m_head, otherLeftInfo.HeadItemId, otherLeftInfo.HeadBorderItemId);
  66. _ui.m_player1.m_nameText.text = otherLeftInfo.RoleName.ToString();
  67. _ui.m_select1.m_numText.text = otherLeftInfo.Score.ToString();
  68. MatchingPhotoWorksData otherRightdata = MatchingTwoDataManager.Instance.RightRoleInfo;
  69. JudgingRoundRoleInfo otherRightInfo = otherRightdata.JudgingInfo;
  70. RoleInfoManager.Instance.UpdateHead(_ui.m_player2.m_head, otherRightInfo.HeadItemId, otherRightInfo.HeadBorderItemId);
  71. _ui.m_player2.m_nameText.text = otherRightInfo.RoleName.ToString();
  72. _ui.m_select2.m_numText.text = otherRightInfo.Score.ToString();
  73. }
  74. private void UpdateView()
  75. {
  76. _ui.m_selectText1.alpha = 0;
  77. _ui.m_selectText2.alpha = 0;
  78. _ui.m_timeText.text = string.Format("剩余次数:{0}", MatchingCompetitionDataManager.Instance.MatchingRemainingTimes);
  79. }
  80. private void OnClickBtnBack()
  81. {
  82. _ui.m_BtnBack.touchable = true;
  83. ViewManager.GoBackFrom(typeof(MatchingCompetitionSelectView).FullName);
  84. }
  85. private async void OnClickBtnSelect1()
  86. {
  87. if(MatchingCompetitionDataManager.Instance.MatchingRemainingTimes<=0)
  88. {
  89. PromptController.Instance.ShowFloatTextPrompt("评选次数不足");
  90. return;
  91. }
  92. bool result = await MatchingCompetitionSproxy.ReqCheckMatchingCompetitionWork(
  93. MatchingTwoDataManager.Instance.LeftRoleInfo.JudgingInfo.WorksId,MatchingTwoDataManager.Instance.RightRoleInfo.JudgingInfo.WorksId
  94. ) ;
  95. if(result)
  96. {
  97. _ui.m_select1.m_c1.selectedIndex = 1;
  98. _ui.m_select1.m_numText.text = string.Format("心动值{0}", MatchingTwoDataManager.Instance.LeftRoleInfo.JudgingInfo.Score.ToString());
  99. _ui.m_timeText.text = string.Format("剩余次数:{0}", MatchingCompetitionDataManager.Instance.MatchingRemainingTimes);
  100. _ui.m_BtnBack.touchable = false;
  101. _ui.m_t0.Play(() => OnClickBtnBack());
  102. }
  103. }
  104. private async void OnClickBtnSelect2()
  105. {
  106. if (MatchingCompetitionDataManager.Instance.MatchingRemainingTimes <= 0)
  107. {
  108. PromptController.Instance.ShowFloatTextPrompt("评选次数不足");
  109. return;
  110. }
  111. bool result = await MatchingCompetitionSproxy.ReqCheckMatchingCompetitionWork(
  112. MatchingTwoDataManager.Instance.RightRoleInfo.JudgingInfo.WorksId, MatchingTwoDataManager.Instance.LeftRoleInfo.JudgingInfo.WorksId
  113. );
  114. if (result)
  115. {
  116. _ui.m_select2.m_c1.selectedIndex = 1;
  117. _ui.m_select2.m_numText.text = string.Format("心动值{0}", MatchingTwoDataManager.Instance.RightRoleInfo.JudgingInfo.Score.ToString());
  118. _ui.m_timeText.text = string.Format("剩余次数:{0}", MatchingCompetitionDataManager.Instance.MatchingRemainingTimes);
  119. _ui.m_BtnBack.touchable = false;
  120. _ui.m_t1.Play(() => OnClickBtnBack());
  121. }
  122. }
  123. }
  124. }